2 Questions about LUA scripting

Runes of Magic/Radiant Arcana (http://www.runesofmagic.com)
Post Reply
Message
Author
FactorY
Posts: 7
Joined: Sun Aug 02, 2009 9:00 pm

2 Questions about LUA scripting

#1 Post by FactorY » Thu Oct 01, 2009 3:49 am

Code: Select all

<waypoints>
	<!-- #  1 --><waypoint x="-432" z="-5974">	
		local test1, test2, test3 = RoMScript("GetBagItemInfo(3);");
		if(test3 == "Sharp Bear Claw") then
			sendMacro("PickupBagItem( %test3 );");   <----HERE 1
			sendMacro("PickupBagItem(5);");
		else
			sendMacro("SendChatMessage("Not Found","SAY");");   <---- HERE 2
		end
		yrest(5000);
	</waypoint>
</waypoints>
Hi guys
About the code I've made up above...

HERE 1
how do i write local variables into text?
I've seen in the actual bot/player/etc lua codes, that a % seems to be placed infront of a variable name in a string if you want to replace it with an actual variable value.

HERE 2
Secondly, what happens in the case you need to send a Macro which relies on "random stuff" to be written within its function? I've tried double ' etc but to no avail

User avatar
droppen
Posts: 179
Joined: Mon Aug 03, 2009 10:32 pm

Re: 2 Questions about LUA scripting

#2 Post by droppen » Thu Oct 01, 2009 4:19 am

FactorY wrote:

Code: Select all

<waypoints>
	<!-- #  1 --><waypoint x="-432" z="-5974">	
		local test1, test2, test3 = RoMScript("GetBagItemInfo(3);");
		if(test3 == "Sharp Bear Claw") then
			sendMacro("PickupBagItem( %test3 );");   <----HERE 1
			sendMacro("PickupBagItem(5);");
		else
			sendMacro("SendChatMessage("Not Found","SAY");");   <---- HERE 2
		end
		yrest(5000);
	</waypoint>
</waypoints>
Hi guys
About the code I've made up above...

HERE 1
how do i write local variables into text?
I've seen in the actual bot/player/etc lua codes, that a % seems to be placed infront of a variable name in a string if you want to replace it with an actual variable value.

HERE 2
Secondly, what happens in the case you need to send a Macro which relies on "random stuff" to be written within its function? I've tried double ' etc but to no avail
here1: sendMacro("PickupBagItem( "..test3..");");
here2: what random stuff? how random?

FactorY
Posts: 7
Joined: Sun Aug 02, 2009 9:00 pm

Re: 2 Questions about LUA scripting

#3 Post by FactorY » Thu Oct 01, 2009 4:24 am

I phrased my question badly sorry =p

eg.
sendMacro("SendChatMessage("Not Found","SAY");");

I want to use the Function SendChatMessage, but the above will not work due to multiple " " " " ....
U get my meaning? xD

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

Re: 2 Questions about LUA scripting

#4 Post by d003232 » Thu Oct 01, 2009 1:46 pm

FactorY wrote:I phrased my question badly sorry =p

eg.
sendMacro("SendChatMessage("Not Found","SAY");");

I want to use the Function SendChatMessage, but the above will not work due to multiple " " " " ....
U get my meaning? xD

Code: Select all

sendMacro("SendChatMessage('Not Found');");

or 

sendMacro("SendChatMessage(\"Not Found\");");

or

local string = "what I want to say";
sendMacro("SendChatMessage("..string..");");
The RoM Bot Online Wiki needs your help!

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Bing [Bot] and 3 guests