first steps in lua: mana restore break in <onLeaveCombat>

Runes of Magic/Radiant Arcana (http://www.runesofmagic.com)
Post Reply
Message
Author
d003232
Posts: 1252
Joined: Wed Jun 03, 2009 4:27 pm

first steps in lua: mana restore break in <onLeaveCombat>

#1 Post by d003232 » Fri Jun 05, 2009 5:34 am

I'm trying my first steps in LUA. I want to do a break for mana restoring after I falls under a certain level. Becaus I dont want to invest in to much mana potions.

So I take some code I found in the main BOT post (I only get read the first 20 pages. It is really big :-) ) and look for the right variables in the player.lua.

But it seems that I cant access the needed variables 'self.mana'??

I put that code in after >onLeaveCombat>. How do I have to declare the variables to get access? I dont want to do that modification within the player.lua

Code: Select all

    <onLeaveCombat>-- Additional Lua code to execute after killing an enemy
        -- Take break for mana restore. Exit if we get attacked.
	if( (self.Mana/self.MaxMana*100) < 60 ) then
	        for i = 1, 30 do
	          yrest(1000);
	          player:update();
	          if( player:haveTarget() ) then
	            i = 30;
	          end;
	          if( (self.Mana/self.MaxMana*100) > 98 ) then
	            i = 30;
	          end;
   
	          player:checkSkills(); -- check if we need to cast buffs/heals.
	        end
	end
    </onLeaveCombat>
The RoM Bot Online Wiki needs your help!

Zilvermoon
Posts: 104
Joined: Mon Jan 05, 2009 8:19 am

Re: first steps in lua: mana restore break in <onLeaveCombat>

#2 Post by Zilvermoon » Fri Jun 05, 2009 7:14 am

I think you need to do something like this:

Code: Select all

<onLeaveCombat>-- Additional Lua code to execute after killing an enemy
	-- Take break for mana restore. Exit if we get attacked.
	if( (player.Mana/player.MaxMana*100) < 60 ) then
		for i = 1, 30 do
			yrest(1000);
			player:update();
			if( player:haveTarget() ) then
				i = 30;
			end;
			if( (player.Mana/player.MaxMana*100) > 98 ) then
				i = 30;
			end;
			player:checkSkills(); -- check if we need to cast buffs/heals.
		end
	end
</onLeaveCombat>
I must admit that I didn't test this code, but think your problem was the "self" ... which I think should be "player" due to the way this code is parsed to the bot...

Zilvermoon

d003232
Posts: 1252
Joined: Wed Jun 03, 2009 4:27 pm

Re: first steps in lua: mana restore break in <onLeaveCombat>

#3 Post by d003232 » Fri Jun 05, 2009 7:16 am

Thx for your fast comment. I will just test it.
The RoM Bot Online Wiki needs your help!

d003232
Posts: 1252
Joined: Wed Jun 03, 2009 4:27 pm

Re: first steps in lua: mana restore break in <onLeaveCombat>

#4 Post by d003232 » Fri Jun 05, 2009 7:30 am

No. I always get a parser error. I thougt it's something wrong with the ';' but cant find anything.
Attachments
error.gif
The RoM Bot Online Wiki needs your help!

d003232
Posts: 1252
Joined: Wed Jun 03, 2009 4:27 pm

Re: first steps in lua: mana restore break in <onLeaveCombat>

#5 Post by d003232 » Fri Jun 05, 2009 8:17 am

Grr. I dont unterstand whats wrong??? If I write:

Code: Select all

   if( (player.Mana/player.MaxMana*100) = 60 ) then
I dont get a parser error. If I write:

Code: Select all

   if( (player.Mana/player.MaxMana*100) < 60 ) then
I get the parser error. But for me it seems to be the right syntax? Just a little '<'.
The RoM Bot Online Wiki needs your help!

Zilvermoon
Posts: 104
Joined: Mon Jan 05, 2009 8:19 am

Re: first steps in lua: mana restore break in <onLeaveCombat>

#6 Post by Zilvermoon » Fri Jun 05, 2009 8:24 am

d003232 wrote:Grr. I dont unterstand whats wrong??? If I write:

Code: Select all

   if( (player.Mana/player.MaxMana*100) = 60 ) then
I dont get a parser error. If I write:

Code: Select all

   if( (player.Mana/player.MaxMana*100) < 60 ) then
I get the parser error. But for me it seems to be the right syntax? Just a little '<'.
Then try this:

Code: Select all

   if( 60 > (player.Mana/player.MaxMana*100)) then

d003232
Posts: 1252
Joined: Wed Jun 03, 2009 4:27 pm

Re: first steps in lua: mana restore break in <onLeaveCombat>

#7 Post by d003232 » Fri Jun 05, 2009 8:36 am

lol, thats it, its working now. And I dont understand why??? :-)

Now my working code is:

Code: Select all

<onLeaveCombat>

if( 60 > (player.Mana/player.MaxMana*100)) then
      printf("waiting for full mana");
      for i = 1, 30 do
         yrest(1000);
         player:update();
         if( player:haveTarget() ) then
            i = 30;
         end;
         if( (player.Mana/player.MaxMana*100) > 98 ) then
            i = 30;
         end;
         player:checkSkills(); -- check if we need to cast buffs/heals.
      end;
   end;

</onLeaveCombat>
THX a lot.
The RoM Bot Online Wiki needs your help!

User avatar
Administrator
Site Admin
Posts: 5307
Joined: Sat Jan 05, 2008 4:21 pm

Re: first steps in lua: mana restore break in <onLeaveCombat>

#8 Post by Administrator » Fri Jun 05, 2009 9:02 am

Using the < symbol confuses the XML parser. It thinks you're opening (a broken) new tag. You can type < as a replacement for that symbol. ie. if( player.HP < 100 ) would be the same as if( player.HP < 100 ).

Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests