Firstly, I'm new to Lua. That will be quite obvious when you see the problem I'm having [8|]
I want to place a ship in a random spot within a certain grid position. In my mind the following should work in the 'latitude' and 'longitude' variables for ScenEdit_AddUnit
Code: Select all
latitude="S34.(math.random(0,59)).(math.random(0,59))", longitude="E152.(math.random(0,59)).(math.random(0,59))"
I have tried a few work arounds, including defining a variable (which I haven't been able to get to work with concatenation) but it seems like my limited knowledge of Lua is really holding me back from coming up with a solution myself.
Can anyone help out?
EDIT:
Turns out I was missing some brackets. The following worked:
Code: Select all
ScenEdit_AddUnit({type = 'Ship', name = 'HMAS Newcastle', dbid = 2608, side = 'Australia', Lat=("S34." .. math.random(0,59) .. "." .. math.random(0,59)),Lon=("E152." .. math.random(0,59) .. "." .. math.random(0,59))})