Radom position for surf unit initaite
Posted: Mon Jan 10, 2022 2:54 pm
Good evening,
I'm trying to do some with random. Small steps.
I got something from another thread, thx.
I made somthing and the random position is the same for both units, no doubt logical.
Is there a way to give both a different position?
local Side = 'Civilian'
local EnvType = 'ship'
local Spd = math.random(1,10)
local Hdg = math.random(1,360,3)
local lat_var = math.random(1,(10^13))
local lon_var = math.random(1,(10^13))
v_lat = math.random(-6,8) + (lat_var/(10^13))
v_lon = math.random(90,125) + (lon_var/(10^13))
ScenEdit_AddUnit({side=Side, type=EnvType, name='test1', DBID=2355, speed=Spd, heading=Hdg, latitude=v_lat, longitude=v_lon})
ScenEdit_AddUnit({side=Side, type=EnvType, name='test2', DBID=1787, speed=Spd, heading=Hdg, latitude=v_lat, longitude=v_lon})
local u1 = ScenEdit_GetUnit({side='Civilian', name='test1'})
print (u1.latitude)
print (u1.longitude)
best regards GJ
I'm trying to do some with random. Small steps.
I got something from another thread, thx.
I made somthing and the random position is the same for both units, no doubt logical.
Is there a way to give both a different position?
local Side = 'Civilian'
local EnvType = 'ship'
local Spd = math.random(1,10)
local Hdg = math.random(1,360,3)
local lat_var = math.random(1,(10^13))
local lon_var = math.random(1,(10^13))
v_lat = math.random(-6,8) + (lat_var/(10^13))
v_lon = math.random(90,125) + (lon_var/(10^13))
ScenEdit_AddUnit({side=Side, type=EnvType, name='test1', DBID=2355, speed=Spd, heading=Hdg, latitude=v_lat, longitude=v_lon})
ScenEdit_AddUnit({side=Side, type=EnvType, name='test2', DBID=1787, speed=Spd, heading=Hdg, latitude=v_lat, longitude=v_lon})
local u1 = ScenEdit_GetUnit({side='Civilian', name='test1'})
print (u1.latitude)
print (u1.longitude)
best regards GJ