Page 1 of 1
If statements involving player.
Posted: Thu Apr 25, 2013 12:30 am
by ZZZZZ
Just been trying to get an If statement that will allow me to do different things depending on what character is logged in....
Been trying to use something like
Code: Select all
If player.Name == ("example") then
--- goes to different waypoint
end
I have looked through forum and the RoM bot wiki and found nothing that works so far....any help would be great.
Re: If statements involving player.
Posted: Thu Apr 25, 2013 12:38 am
by Romplayer
try using the waypoint tags.
Code: Select all
<!-- # 4 --><waypoint x="3948" z="3107" tag="Main">
If player.Name == ("example") then
--- goes to different waypoint
__WPL:setWaypointIndex(__WPL:findWaypointTag("Player1"));
end
</waypoint>
<!-- # 4 --><waypoint x="3948" z="3107" tag="Player1">
</waypoint>
Re: If statements involving player.
Posted: Thu Apr 25, 2013 2:42 am
by ZZZZZ
Thats what I have already, I mean the player.Name etc doesnt seem to work. I'll copy-paste my code in a min.
Re: If statements involving player.
Posted: Thu Apr 25, 2013 2:55 am
by lisa
If player.Name == ("example") then
If should be if and I would get rid of the brackets
Code: Select all
if player.Name == "Charsname" then
Re: If statements involving player.
Posted: Thu Apr 25, 2013 4:55 am
by ZZZZZ
lisa wrote:If player.Name == ("example") then
If should be if and I would get rid of the brackets
Code: Select all
if player.Name == "Charsname" then
ah thanks, that worked lol.
Also how would you make it an or statement, eg
Code: Select all
if player.Name == "example" or if player.Name == "example2" then
--- do something
end
Can't figure that one out ^.^
Re: If statements involving player.
Posted: Thu Apr 25, 2013 5:56 am
by rock5
A standard 'if' statement takes the form of
A condition is something like
- variable == variable
variable > value
function(value) == "string"
To name just a few.
An 'if' statement with multiple conditions still has only 1 'if' and 1 'then'. It would look like this.
- if condition or condition then
end
Of course 'if' statements can be a lot more complex. Here is the reference for the 'if' statement
http://www.lua.org/manual/5.2/manual.html#3.3.4. It's not very newby friendly. Try doing a search online for 'if then' examples or look through the bot files.