How to use if+useitem+checkbuff command in script

Runes of Magic/Radiant Arcana (http://www.runesofmagic.com)
Post Reply
Message
Author
jonmatt
Posts: 5
Joined: Sun Dec 16, 2012 7:10 pm

How to use if+useitem+checkbuff command in script

#1 Post by jonmatt »

Hi all,
Right now I'm trying to use those 3 fuctions in one step like : checkbuff(X) , if buff (X) return(false) then useitem(X) which is in inventory, but I really dont know how to do it because i barely understand the if fonction and mine isn't working.

I've got something else wich is also not working , if you can please help me ;)

Code: Select all

if( inventory:itemTotalCount(214536) > 59 ) then
player:mount();
in this one I'm trying to make the bot check the inventory and if there is more than 59 items in it ,then mount and go back to town

Code: Select all

if( player:mount(false) ) then
player:mount();
in this one I'm trying to prevent the bot from walking without mount to the town.

my whole script looks like this:

Code: Select all

<?xml version="1.0" encoding="utf-8"?><waypoints>
	<!-- #  1 --><waypoint x="-16535" z="190" y="948">	</waypoint>
	<!-- #  2 --><waypoint x="-16392" z="344" y="964">	</waypoint>
	<!-- #  3 --><waypoint x="-16282" z="580" y="978">	</waypoint>
	<!-- #  4 --><waypoint x="-16384" z="786" y="993">	</waypoint>
	<!-- #  5 --><waypoint x="-16586" z="891" y="1005">	</waypoint>
	<!-- #  6 --><waypoint x="-16796" z="814" y="1033">	</waypoint>
	<!-- #  7 --><waypoint x="-17002" z="670" y="1022">	</waypoint>
	<!-- #  8 --><waypoint x="-17104" z="441" y="1028">	</waypoint>
	<!-- #  9 --><waypoint x="-16997" z="235" y="1005">	</waypoint>
	<!-- # 10 --><waypoint x="-16780" z="110" y="962">	</waypoint>
	<!-- # 11 --><waypoint x="-16561" z="195" y="948">	</waypoint>
if( inventory:itemTotalCount(214536) > 59 ) then
player:mount();
if( player:mount(false) ) then
player:mount();
__WPL:setDirection(WPT_FORWARD);
	<!-- # 12 --><waypoint x="-16501" z="31" y="934" type="TRAVEL">	</waypoint>
	<!-- # 13 --><waypoint x="-16331" z="-125" y="932" type="TRAVEL">	</waypoint>
	<!-- # 14 --><waypoint x="-16105" z="-253" y="922" type="TRAVEL">	</waypoint>
	<!-- # 15 --><waypoint x="-15874" z="-337" y="928" type="TRAVEL">	</waypoint>
	<!-- # 16 --><waypoint x="-15699" z="-302" y="909" type="TRAVEL">	</waypoint>
	<!-- # 17 --><waypoint x="-15613" z="-182" y="872" type="TRAVEL">	</waypoint>
	<!-- # 18 --><waypoint x="-15516" z="-172" y="840" type="TRAVEL">	</waypoint>
	<!-- # 19 --><waypoint x="-15500" z="-49" y="810" type="TRAVEL">	</waypoint>
	<!-- # 20 --><waypoint x="-15350" z="-4" y="773" type="TRAVEL">	</waypoint>
	<!-- # 21 --><waypoint x="-15123" z="-97" y="756" type="TRAVEL">	</waypoint>
	<!-- # 22 --><waypoint x="-14952" z="-58" y="765" type="TRAVEL">	</waypoint>
	<!-- # 23 --><waypoint x="-14765" z="-68" y="757"  type="TRAVEL">	</waypoint>
	<!-- # 24 --><waypoint x="-14592" z="-133" y="758" type="TRAVEL">	</waypoint>
	<!-- # 25 --><waypoint x="-14440" z="-219" y="777" type="TRAVEL">	</waypoint>
	<!-- # 26 --><waypoint x="-14323" z="-338" y="803" type="TRAVEL">	</waypoint>
	<!-- # 27 --><waypoint x="-14228" z="-500" y="804" type="TRAVEL">	</waypoint>
	<!-- # 28 --><waypoint x="-14128" z="-691" y="779" type="TRAVEL">	</waypoint>
	<!-- # 29 --><waypoint x="-13940" z="-833" y="774" type="TRAVEL">	</waypoint>
if( player:mount(false) ) then
player:mount();
	<!-- # 30 --><waypoint x="-13885" z="-808" y="780">		player:target_NPC("Ilana");
__WPL:setDirection(WPT_BACKWARD);
	</waypoint>
</waypoints>
User avatar
lisa
Posts: 8332
Joined: Tue Nov 09, 2010 11:46 pm
Location: Australia

Re: How to use if+useitem+checkbuff command in script

#2 Post by lisa »

for every "if" you need an "end"

Code: Select all

if( inventory:itemTotalCount(214536) > 59 ) then
player:mount();
end
if( player:mount(false) ) then
player:mount();
end
__WPL:setDirection(WPT_FORWARD);
Remember no matter you do in life to always have a little fun while you are at it ;)

wiki here http://www.solarstrike.net/wiki/index.php?title=Manual
User avatar
rock5
Posts: 12173
Joined: Tue Jan 05, 2010 3:30 am
Location: Australia

Re: How to use if+useitem+checkbuff command in script

#3 Post by rock5 »

Also player:mount() and player:mount(false) do the same thing, mount. And player:mount doesn't return a value so you can't do "if player:mount() then". If you want to make sure you are mounted then try

Code: Select all

local c=0
repeat
    c=c+1
    player:mount()
    yrest(500)
until player.Mounted or c > 10
I put a limit on the number of times it tries just in case there is some reason you can't mount, so it wont get stuck in the loop.
  • Please consider making a small donation to me to support my continued contributions to the bot and this forum. Thank you. Donate
  • I check all posts before reading PMs. So if you want a fast reply, don't PM me but post a topic instead. PM me for private or personal topics only.
  • How to: copy and paste in micromacro
    ________________________
    Quote:
    • “They say hard work never hurt anybody, but I figure, why take the chance.”
          • Ronald Reagan
jonmatt
Posts: 5
Joined: Sun Dec 16, 2012 7:10 pm

Re: How to use if+useitem+checkbuff command in script

#4 Post by jonmatt »

Thanks for those advices , I'm trying to apply them to my code , so now it looks like that

Code: Select all

local c=0
repeat
    c=c+1
    player:mount()
    yrest(500)
until c > 2;
I tried with the player.Mounted but he keeps trying to mount undefinitely

that way it tryes to mount 2 times then loop to boting spot,but is there a way to make him check before if he is monted or not with the check function ?

and how should I start with the check buff function ?

(sorry for my bad english, I'm french, I'm still trying to improve my english) ;)
User avatar
rock5
Posts: 12173
Joined: Tue Jan 05, 2010 3:30 am
Location: Australia

Re: How to use if+useitem+checkbuff command in script

#5 Post by rock5 »

jonmatt wrote:I tried with the player.Mounted but he keeps trying to mount undefinitely
Do you mean only with player.Mounted without c > 10? If you don't have a mount it would loop indefinately. Is this without a mount?
jonmatt wrote:is there a way to make him check before if he is monted or not with the check function ?
Yes. A 'repeat' loop checks at the end of the loop so always does it at least once. What you want is a 'while' loop which checks at the begining.

Code: Select all

player:update()
local c = 0
while player.Mounted == false and 2 >= c do
    c=c+1
    player:mount()
    yrest(500)
end
  • Please consider making a small donation to me to support my continued contributions to the bot and this forum. Thank you. Donate
  • I check all posts before reading PMs. So if you want a fast reply, don't PM me but post a topic instead. PM me for private or personal topics only.
  • How to: copy and paste in micromacro
    ________________________
    Quote:
    • “They say hard work never hurt anybody, but I figure, why take the chance.”
          • Ronald Reagan
jonmatt
Posts: 5
Joined: Sun Dec 16, 2012 7:10 pm

Re: How to use if+useitem+checkbuff command in script

#6 Post by jonmatt »

hey! thanks for those advices ;) i managed to get it work as i wanted.

but now i'm reaching a new problem , how should i do to get this to work , micro macro tells me it's not "well-formed" at line 15

Code: Select all

if player:hasBuff("Burrito à la viande") == false then 
repeat inventory:useItem("Burrito à la viande")
until player:hasBuff("Burrito à la viande") == true ;
end
User avatar
rock5
Posts: 12173
Joined: Tue Jan 05, 2010 3:30 am
Location: Australia

Re: How to use if+useitem+checkbuff command in script

#7 Post by rock5 »

What's not well formed? Usually it says. And which line is 15?
  • Please consider making a small donation to me to support my continued contributions to the bot and this forum. Thank you. Donate
  • I check all posts before reading PMs. So if you want a fast reply, don't PM me but post a topic instead. PM me for private or personal topics only.
  • How to: copy and paste in micromacro
    ________________________
    Quote:
    • “They say hard work never hurt anybody, but I figure, why take the chance.”
          • Ronald Reagan
jonmatt
Posts: 5
Joined: Sun Dec 16, 2012 7:10 pm

Re: How to use if+useitem+checkbuff command in script

#8 Post by jonmatt »

here is my whole code

Code: Select all

<?xml version="1.0" encoding="utf-8"?><waypoints>

	<!-- #  1 --><waypoint x="-16535" z="190" y="948">	</waypoint>
	<!-- #  2 --><waypoint x="-16392" z="344" y="964">	</waypoint>
	<!-- #  3 --><waypoint x="-16282" z="580" y="978">	</waypoint>
	<!-- #  4 --><waypoint x="-16384" z="786" y="993">	</waypoint>
	<!-- #  5 --><waypoint x="-16586" z="891" y="1005">	</waypoint>
	<!-- #  6 --><waypoint x="-16796" z="814" y="1033">	</waypoint>
	<!-- #  7 --><waypoint x="-17002" z="670" y="1022">	</waypoint>
	<!-- #  8 --><waypoint x="-17104" z="441" y="1028">	</waypoint>
	<!-- #  9 --><waypoint x="-16997" z="235" y="1005">	</waypoint>
	<!-- # 10 --><waypoint x="-16780" z="110" y="962">	</waypoint>
	<!-- # 11 --><waypoint x="-16561" z="195" y="948">	</waypoint>

if player:hasBuff("Burrito ࡬a viande") == false then <!-- here is line 15 according to notepad ++
repeat inventory:useItem("Burrito ࡬a viande")
until player:hasBuff("Burrito ࡬a viande") == true ;
end

if( inventory:itemTotalCount(214536) > 59 ) then
player:update()
local c = 0
while player.Mounted == false and 2 >= c do
    c=c+1
    player:mount()
    yrest(500)
end

__WPL:setDirection(WPT_FORWARD);
	<!-- # 12 --><waypoint x="-16501" z="31" y="934" type="TRAVEL">	</waypoint>
	<!-- # 13 --><waypoint x="-16331" z="-125" y="932" type="TRAVEL">	</waypoint>
	<!-- # 14 --><waypoint x="-16105" z="-253" y="922" type="TRAVEL">	</waypoint>
	<!-- # 15 --><waypoint x="-15874" z="-337" y="928" type="TRAVEL">	</waypoint>
	<!-- # 16 --><waypoint x="-15699" z="-302" y="909" type="TRAVEL">	</waypoint>
	<!-- # 17 --><waypoint x="-15613" z="-182" y="872" type="TRAVEL">	</waypoint>
	<!-- # 18 --><waypoint x="-15516" z="-172" y="840" type="TRAVEL">	</waypoint>
	<!-- # 19 --><waypoint x="-15500" z="-49" y="810" type="TRAVEL">	</waypoint>
	<!-- # 20 --><waypoint x="-15350" z="-4" y="773" type="TRAVEL">	</waypoint>
	<!-- # 21 --><waypoint x="-15123" z="-97" y="756" type="TRAVEL">	</waypoint>
	<!-- # 22 --><waypoint x="-14952" z="-58" y="765" type="TRAVEL">	</waypoint>
	<!-- # 23 --><waypoint x="-14765" z="-68" y="757"  type="TRAVEL">	</waypoint>
	<!-- # 24 --><waypoint x="-14592" z="-133" y="758" type="TRAVEL">	</waypoint>
	<!-- # 25 --><waypoint x="-14440" z="-219" y="777" type="TRAVEL">	</waypoint>
	<!-- # 26 --><waypoint x="-14323" z="-338" y="803" type="TRAVEL">	</waypoint>
	<!-- # 27 --><waypoint x="-14228" z="-500" y="804" type="TRAVEL">	</waypoint>
	<!-- # 28 --><waypoint x="-14128" z="-691" y="779" type="TRAVEL">	</waypoint>
	<!-- # 29 --><waypoint x="-13940" z="-833" y="774" type="TRAVEL">	</waypoint>
	<!-- # 30 --><waypoint x="-13885" z="-808" y="780">		player:merchant("Ilana");

if player:hasBuff("Burrito ࡬a viande") == false then 
repeat inventory:useItem("Burrito ࡬a viande")
until player:hasBuff("Burrito ࡬a viande") == true ;
end

player:update()
local c = 0
while player.Mounted == false and 2 >= c do
    c=c+1
    player:mount()
    yrest(500)
end
__WPL:setDirection(WPT_BACKWARD);

	</waypoint>
</waypoints>
and here is what micromacro says


I think that the problem come from the "à" but i dont know how to fix it

Edit: I've fixed the problem , now i've got a problem line 30 but I dont know what it is :s
Nouvelle image bitmap.jpg
User avatar
lisa
Posts: 8332
Joined: Tue Nov 09, 2010 11:46 pm
Location: Australia

Re: How to use if+useitem+checkbuff command in script

#9 Post by lisa »

notice the writing is green? that is a bad thing, it means it is "commented" out as such.

example of code that does work.

Code: Select all

<!-- #  5 --><waypoint x="4245" z="904" y="679">	bagcheck()	</waypoint>
notice all of the code is after the > and before the </
Remember no matter you do in life to always have a little fun while you are at it ;)

wiki here http://www.solarstrike.net/wiki/index.php?title=Manual
jonmatt
Posts: 5
Joined: Sun Dec 16, 2012 7:10 pm

Re: How to use if+useitem+checkbuff command in script

#10 Post by jonmatt »

here is my code right now, it seems to work fine for the moment ,still waiting for my bag to be full,to check if the return path travel works as i expetc from it ,do U have any idea about how can i improve my code ? and one more question, how can i create a function that contain the killing spot and a second one that contain the "return to town" path?

Code: Select all

<?xml version="1.0" encoding="utf-8"?><waypoints>
	
if( inventory:itemTotalCount(214536) > 59 ) == true then
player:update()
local c = 0
while player.Mounted == false and 2 >= c do
    c=c+1
    player:mount()
    yrest(500)
	elseif ( inventory:itemTotalCount(214536) > 59 ) == false then
	<!-- #  1 --><waypoint x="-16535" z="190" y="948">	</waypoint>
	<!-- #  2 --><waypoint x="-16392" z="344" y="964">	</waypoint>
	<!-- #  3 --><waypoint x="-16282" z="580" y="978">	</waypoint>
	<!-- #  4 --><waypoint x="-16384" z="786" y="993">	</waypoint>
	<!-- #  5 --><waypoint x="-16586" z="891" y="1005">	</waypoint>
	<!-- #  6 --><waypoint x="-16796" z="814" y="1033">	</waypoint>
	<!-- #  7 --><waypoint x="-17002" z="670" y="1022">	</waypoint>
	<!-- #  8 --><waypoint x="-17104" z="441" y="1028">	</waypoint>
	<!-- #  9 --><waypoint x="-16997" z="235" y="1005">	</waypoint>
	<!-- # 10 --><waypoint x="-16780" z="110" y="962">	</waypoint>
	<!-- # 11 --><waypoint x="-16561" z="195" y="948">	</waypoint>
end


__WPL:setDirection(WPT_FORWARD);
	<!-- # 12 --><waypoint x="-16501" z="31" y="934" type="RUN">	    </waypoint>
	<!-- # 13 --><waypoint x="-16331" z="-125" y="932" type="RUN">	</waypoint>
	<!-- # 14 --><waypoint x="-16105" z="-253" y="922" type="RUN">	</waypoint>
	<!-- # 15 --><waypoint x="-15874" z="-337" y="928" type="RUN">	</waypoint>
	<!-- # 16 --><waypoint x="-15699" z="-302" y="909" type="RUN">	</waypoint>
	<!-- # 17 --><waypoint x="-15613" z="-182" y="872" type="RUN">	</waypoint>
	<!-- # 18 --><waypoint x="-15516" z="-172" y="840" type="RUN">	</waypoint>
	<!-- # 19 --><waypoint x="-15500" z="-49" y="810" type="RUN">	</waypoint>
	<!-- # 20 --><waypoint x="-15350" z="-4" y="773" type="RUN">	</waypoint>
	<!-- # 21 --><waypoint x="-15123" z="-97" y="756" type="RUN">	</waypoint>
	<!-- # 22 --><waypoint x="-14952" z="-58" y="765" type="RUN">	</waypoint>
	<!-- # 23 --><waypoint x="-14765" z="-68" y="757"  type="RUN">	</waypoint>
	<!-- # 24 --><waypoint x="-14592" z="-133" y="758" type="RUN">	</waypoint>
	<!-- # 25 --><waypoint x="-14440" z="-219" y="777" type="RUN">	</waypoint>
	<!-- # 26 --><waypoint x="-14323" z="-338" y="803" type="RUN">	</waypoint>
	<!-- # 27 --><waypoint x="-14228" z="-500" y="804" type="RUN">	</waypoint>
	<!-- # 28 --><waypoint x="-14128" z="-691" y="779" type="RUN">	</waypoint>
	<!-- # 29 --><waypoint x="-13940" z="-833" y="774" type="RUN">	</waypoint>
	<!-- # 30 --><waypoint x="-13885" z="-808" y="780">		player:merchant("Ilana");
	
	inventory:useItem("Burrito à la viande");
function buff_item()
 inventory:useItem("Burrito à la viande");
 end
 registerTimer("myTimer",900000,buff_item);	

 player:update()
local c = 0
while player.Mounted == false and 2 >= c do
    c=c+1
    player:mount()
    yrest(500)
end
__WPL:setDirection(WPT_BACKWARD);

	</waypoint>
</waypoints>
User avatar
lisa
Posts: 8332
Joined: Tue Nov 09, 2010 11:46 pm
Location: Australia

Re: How to use if+useitem+checkbuff command in script

#11 Post by lisa »

I can't see how that code you posted would work at all, you need to start with learning the basics of WP coding.


1. Any code you add in should be between a > and </, as I said above
example

Code: Select all

<onload>function blahblah() some code end</onload>
<waypoint some stuff > blahblah() some other code</waypoint>
2. functions go in the onload "section" as the example above, only have 1 onload section in a waypoint file.

I was going to write more but to be honest you should do some reading, check other posted waypoint files as examples and start there.
Remember no matter you do in life to always have a little fun while you are at it ;)

wiki here http://www.solarstrike.net/wiki/index.php?title=Manual
Post Reply