Page 1 of 1
Chose waypoint by random
Posted: Sun Apr 14, 2013 5:09 pm
by Ego95
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
Re: Chose waypoint by random
Posted: Sun Apr 14, 2013 5:47 pm
by wps
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
Re: Chose waypoint by random
Posted: Sun Apr 14, 2013 6:50 pm
by lisa
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
Re: Chose waypoint by random
Posted: Fri May 10, 2013 4:16 pm
by Ego95
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
Re: Chose waypoint by random
Posted: Sat May 11, 2013 7:39 am
by rock5
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
Re: Chose waypoint by random
Posted: Sat May 11, 2013 12:45 pm
by Ego95
Thank you

works great. Now I'm able to use different ways to ks.
AlterEgo95