-
ZZZZZ
- Posts: 513
- Joined: Sun Oct 21, 2012 1:42 am
#1
Post
by ZZZZZ » Thu Apr 25, 2013 12:30 am
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.
-
Romplayer
- Posts: 120
- Joined: Wed Jan 11, 2012 10:07 am
#2
Post
by Romplayer » Thu Apr 25, 2013 12:38 am
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>
-
ZZZZZ
- Posts: 513
- Joined: Sun Oct 21, 2012 1:42 am
#3
Post
by ZZZZZ » Thu Apr 25, 2013 2:42 am
Thats what I have already, I mean the player.Name etc doesnt seem to work. I'll copy-paste my code in a min.
-
lisa
- Posts: 8332
- Joined: Tue Nov 09, 2010 11:46 pm
- Location: Australia
#4
Post
by lisa » Thu Apr 25, 2013 2:55 am
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
-
ZZZZZ
- Posts: 513
- Joined: Sun Oct 21, 2012 1:42 am
#5
Post
by ZZZZZ » Thu Apr 25, 2013 4:55 am
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 ^.^
-
rock5
- Posts: 12173
- Joined: Tue Jan 05, 2010 3:30 am
- Location: Australia
#6
Post
by rock5 » Thu Apr 25, 2013 5:56 am
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.
- 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.”
Who is online
Users browsing this forum: Bing [Bot] and 0 guests