He Barnski, I'm using your plugin for the ability to handle different entities in my game, but I'm having some problems controlling them.
Here is the Lua code (which compiles fine):
--AntiGravity Entity
function antiGravity(obj, x, y, z, sx, sy, sz)
--Create object
DBPro.Call("MakeObjectCylinder", obj, 100)
DBPro.Call("ScaleObject", obj, sx, sy, sz)
DBPro.Call("PositionObject", obj, x, y, z)
--Change Appearance
DBPro.Call("ColorObject", obj, DBPro.Call("Rgb", 0, 0, 205))
DBPro.Call("GhostObjectOn", obj)
end
--Control AntiGravity Entity
function controlAntiGravity(pobj, obj)
--Get Positions of anti gravity field
opx = DBPro.Call("ObjectPositionX", obj)
opy = DBPro.Call("ObjectPositionY", obj)
opz = DBPro.Call("ObjectPositionZ", obj)
--Get sizes
osx = DBPro.Call("ObjectSizeX", obj, 1)
osy = DBPro.Call("ObjectSizeY", obj, 1)
osz = DBPro.Call("ObjectSizeZ", obj, 1)
--Get positions of player
px = DBPro.Call("ObjectPositionX", pobj)
py = DBPro.Call("ObjectPositionY", pobj)
pz = DBPro.Call("ObjectPositionZ", pobj)
--Get required distance
rdist = DBPro.Call("Sqrt", (osx*osx) + (osz*osz) )
--Get actual distance
dist = DBPro.Call("Sqrt", ((px - opx) * (px - opx)) + ((pz - opz) * (pz - opz)))
--If inside anti gravity field
if dist < rdist then
--Add up force
return 200.0
else
return 0.0
end
end
The antiGravity function creates and positions an "anti gravity" field. The controlAntiGravity function checks if the player is inside the feild, and returns an upward force, which is used in the actual game.
This is the DBPro code for calling the controlAntiGravity function:
lua push function "controlAntiGravity"
lua push int _player.Obj
error = lua call function(1,1)
upfrc# = lua pop float()
That's inside the main loop. Obviously the upward force isnt being applied yet. My problem is, that with that code, my game crashes. I'm having a bad feeling that there's a stack overload or something, but I can't be sure. Do you know what's happening? Thanks.
P.S. If I put that code outside the loop, it runs fine.