PDA

View Full Version : Custom Variables



jorgeriva1
09-01-2016, 10:41 PM
Hi,

My question is, how do I edit custom variables in lua?

I know that in Elfbot you could make any custom variable e.g. $customvariable, and then you could change the value of it using action waypoints e.g. set $customvariable 1. I know that I can create custom variables and set their values at the start of a lua script in XenoBot e.g. local customvariable = 1, but what would I then insert to change the value of it once something has happened?


local customvariable = 0

Module.New(Function()
if(customvariable = 0) then
Self.Say('Example')
set customvariable = 1
end
end

Something like this.

Thanks in advance.

Elvang
09-01-2016, 11:35 PM
Hi,

My question is, how do I edit custom variables in lua?

I know that in Elfbot you could make any custom variable e.g. $customvariable, and then you could change the value of it using action waypoints e.g. set $customvariable 1. I know that I can create custom variables and set their values at the start of a lua script in XenoBot e.g. local customvariable = 1, but what would I then insert to change the value of it once something has happened?


local customvariable = 0

Module.New(Function()
if(customvariable = 0) then
Self.Say('Example')
set customvariable = 1
end
end

Something like this.

Thanks in advance.

Just take out the 'set' and it should work fine.

jorgeriva1
09-02-2016, 06:32 AM
Hi, thanks for that but it's still not working for me, I guess there must be something wrong with the rest of the script. Can you take a look at it please?


local spawn1 = "0"
local spawn2 = "0"

registerEventListener(WALKER_SELECTLABEL, "onWalkerSelectLabel")

function onWalkerSelectLabel(labelName)
if (labelName == "TPRCheck") then
Walker.ConditionalGoto((Self.Position().x == 739), "TPRoom", "Start")

elseif (labelName == ("WhichSpawn")) then
if (spawn1 == 0) then
spawn1 = 1
Walker.Goto("Spawn1")

elseif (spawn2 == 0) then
spawn2 = 1
Walker.Goto("Spawn2")
end
end
end

shadowart
09-02-2016, 06:49 AM
"0" is not equal to 0.

jorgeriva1
09-02-2016, 08:11 AM
Cheers, I'll try it when I get home.

jorgeriva1
09-02-2016, 03:10 PM
It worked, thanks a lot.

I now have another question. In Elfbot there was the variable $monstersaround.1 which would count the number of monsters around you in a 1 sqm radius. Is there something like that for lua?

Cheers

Trykon
09-02-2016, 03:17 PM
Yup. Don't remember functions but you can launch loop around monsters on screen/any dist

jorgeriva1
09-02-2016, 03:26 PM
I appreciate the help, but that means absolutely nothing to me. Can you put it into terms that someone who started scripting-ish about a week ago can understand?

Elvang
09-02-2016, 08:19 PM
I appreciate the help, but that means absolutely nothing to me. Can you put it into terms that someone who started scripting-ish about a week ago can understand?

If you go into C:\Program Files (x86)\XenoBot\Data and open the latest .lua file (look at the dates) in this case it's 'xb.0025.15.11.28.1265.lua'

Search for 'creature' you'll find things like:


Creature.New(value)
Creature:DistanceFromSelf()
Creature:isAdjacent()


Another thread that might help
Utamo and Exit when x number of monsters. (http://forums.xenobot.net/showthread.php?43577-utamo-and-exit-when-x-amount-of-x-monsters-on-screen&highlight=list+monsters)

Trykon
09-02-2016, 11:01 PM
http://forums.xenobot.net/showthread.php
My old thread. Follow script also contains the function you asked about ;)

jorgeriva1
09-02-2016, 11:48 PM
Thanks for the replies guys, I'll take a look at them

Elvang
09-03-2016, 12:29 AM
http://forums.xenobot.net/showthread.php
My old thread. Follow script also contains the function you asked about ;)

The link didn't work.

Trykon
09-03-2016, 12:51 AM
The link didn't work.

http://forums.xenobot.net/showthread.php?42709-TRK-Scripts-taking-requests
This one... sorry ;)