-
Ego95
- Posts: 564
- Joined: Tue Feb 28, 2012 12:38 pm
-
Contact:
#1
Post
by Ego95 » Sun Apr 14, 2013 5:09 pm
Hi again
I didn't know where to search for so I decided to start a topic for my question.
What i want to know is if it is possible to create for example five different routes which are ending at the same place and then let the bot chose one of the five routes.
Waypoint 1 -- Chose Route A = 20%, Route B = 20%, Route C = 20%, Route D = 20%, Route E = 20%
Is something like this possible to do in lua?
AlterEgo95
-
wps
- Posts: 74
- Joined: Tue Feb 05, 2013 11:11 am
#2
Post
by wps » Sun Apr 14, 2013 5:47 pm
I don't really know the random of lua is real or not
you could use math.random(100)
then according to the return value to decide which path to use
-
lisa
- Posts: 8332
- Joined: Tue Nov 09, 2010 11:46 pm
- Location: Australia
#3
Post
by lisa » Sun Apr 14, 2013 6:50 pm
math.random(100)
is a random number from 1 to 100, just make it simple and do
math.random(5)
Code: Select all
Command> for i = 1,10 do print(math.random(5)) end
2
4
1
4
1
2
4
4
2
4
-
Ego95
- Posts: 564
- Joined: Tue Feb 28, 2012 12:38 pm
-
Contact:
#4
Post
by Ego95 » Fri May 10, 2013 4:16 pm
I wanted to use this now. But how to use it? Something like
Code: Select all
if math.random(5) == 1 then __WPL:setWaypointIndex(1); end
AlterEgo95
-
rock5
- Posts: 12173
- Joined: Tue Jan 05, 2010 3:30 am
- Location: Australia
#5
Post
by rock5 » Sat May 11, 2013 7:39 am
Each time you call math.random it generates a new number so, to check it against a few values, you will have to save it first. And I would use tags as well.
Code: Select all
local rnd = math.random(5)
if rnd == 1 then
__WPL:setWaypointIndex(__WPL:findWaypointTag("path1"))
elseif rnd == 2 then
__WPL:setWaypointIndex(__WPL:findWaypointTag("path2"))
elseif rnd == 3 then
__WPL:setWaypointIndex(__WPL:findWaypointTag("path3"))
elseif rnd == 4 then
__WPL:setWaypointIndex(__WPL:findWaypointTag("path4"))
else
__WPL:setWaypointIndex(__WPL:findWaypointTag("path5"))
end
- 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.”
-
Ego95
- Posts: 564
- Joined: Tue Feb 28, 2012 12:38 pm
-
Contact:
#6
Post
by Ego95 » Sat May 11, 2013 12:45 pm
Thank you
![Smile :)](./images/smilies/icon_e_smile.gif)
works great. Now I'm able to use different ways to ks.
AlterEgo95
Who is online
Users browsing this forum: Ahrefs [Bot] and 4 guests