You can use Spring.XXX functions in unitscripts, too.I understand that solution a would be a gadget, with lots of overhead, yes?
(If you need unitID as parameter, the unitID of the unit which runs the script is already stored in a variable named "unitID")
Something like
Code: Select all
script.Create()
StartThread (waterCheck)
end
function waterCheck()
while (true)
local x,y,z = Spring.GetUnitPosition(unitID)
groundHeight = Spring.GetGroundHeight(x,z)
if groundHeight < 0 then --water always at y==0
...is on water...
else
...on land...
Sleep (100)
end
Make testscript and look what it outputs when you drive around.
Code: Select all
function script.setSFXoccupy (terrainType)
Spring.Echo (terrainType)
end
I do not understand what you are doing with "hovers that can move underwater"...