Scripts / Why does this script not work?

Author
Message
Mortt
8
Years of Service
User Offline
Joined: 16th May 2016
Location:
Posted: 6th Jul 2019 10:35
[_code]
function testthis_init(e)

end

function testthis_main(e)
PlayerDist = GetPlayerDistance(e)
if PlayerDist < 300 then
boxAx = 500
boxBz = 500
boxx = g_Entity[e]["x"] + boxAx
boxz = g_Entity[e]["z"] + boxBz
boxy = GetGroundHeight(g_Entity[e]['x'],g_Entity[e]['z'])
SetPosition(e,boxx,boxy,boxz)
end

end

[_/code]

Can some one explain why this is not working and how can I get it working.
I have tried various ways of doing it but it just does not work.
I think it should work, but guess I am missing something.

What it should do is move an object when the player gets close.

Also why is only (MoveUp(e, v), MoveForward(e,v), MoveBackward(e,v)) in the globals?
Where is MoveLeft and MoveRight?


(Custom) Intel i7 3.3 Mhz. 16 GB fast ram. EVGA Nvidia 1050 Ti 4GB. Dell US27 2560 x 1440. Dell 24 1920 x 1080. Awesome.
Next G. Card EVGA GeForce GTX 970 Superclocked ACX 2.0 Gaming 4GB GDDR5 PCIe3.0 Graphics Card.
Would Like EVGA NVIDIA GeForce GTX 1080 8GB GDDR5X PCIe3.0 Graphics Card
PM
AmenMoses
GameGuru Master
8
Years of Service
User Offline
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 6th Jul 2019 11:11 Edited at: 6th Jul 2019 11:46
Add a Prompt in there to make sure the script is actually getting called.

Try the attached.
Been there, done that, got all the T-Shirts!

Attachments

Login to view attachments
PM
smallg
Community Leader
19
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 6th Jul 2019 12:26
turn off physics or you can't reposition objects without updating the physics
you can also do that in code like so
lua guide for GG
https://steamcommunity.com/sharedfiles/filedetails/?id=398177770
windows 10
i5 @4ghz, 8gb ram, AMD R9 200 series , directx 11
Mortt
8
Years of Service
User Offline
Joined: 16th May 2016
Location:
Posted: 7th Jul 2019 16:19
Ah. Yes. I see that Collision would still be on.
Thanks so much AmenMoses and smallg.
Its funny, when you try and sort stuff the obvious seems to get missed.
Thanks a bunch.
(Custom) Intel i7 3.3 Mhz. 16 GB fast ram. EVGA Nvidia 1050 Ti 4GB. Dell US27 2560 x 1440. Dell 24 1920 x 1080. Awesome.
Next G. Card EVGA GeForce GTX 970 Superclocked ACX 2.0 Gaming 4GB GDDR5 PCIe3.0 Graphics Card.
Would Like EVGA NVIDIA GeForce GTX 1080 8GB GDDR5X PCIe3.0 Graphics Card
PM

Login to post a reply

Server time is: 2024-12-22 14:27:59
Your offset time is: 2024-12-22 14:27:59