Jump to content

SetY Troubles


Kjulo

Recommended Posts

To test it out, i made this code

Kmod_Addition_Traits.OnPlayerUpdate= function(player)	getPlayer():setY(getPlayer():getY() + 1); --move playerend

But the player dosen't move or change cordinates. I have even tried setting it to 0 instead of adding, but nothing happens.

Link to comment
Share on other sites

http://theindiestone.com/forums/index.php/topic/734-

 

dida had the same problem, but blindcoder helped him apparently:

function hack.doWarp(x, y)    if hack.warp == true then        -- special thanks to blindcoder for this line        local wx, wy = ISCoordConversion.ToWorld(x, y, getPlayer():getZ());        getPlayer():setY(wy);        getPlayer():setX(wx);    endend
Link to comment
Share on other sites

 

http://theindiestone.com/forums/index.php/topic/734-

 

dida had the same problem, but blindcoder helped him apparently:

function hack.doWarp(x, y)    if hack.warp == true then        -- special thanks to blindcoder for this line        local wx, wy = ISCoordConversion.ToWorld(x, y, getPlayer():getZ());        getPlayer():setY(wy);        getPlayer():setX(wx);    endend
		local wx, wy = ISCoordConversion.ToWorld(getPlayer():getX() + 1, getPlayer():getY() + 1, getPlayer():getZ());        getPlayer():setY(wy);        getPlayer():setX(wx);

Do i translate it into this? still can't seem to get it working

Link to comment
Share on other sites

Ah I see... I just noticed that he uses the Mouse Click Event hence he has to convert the coordinates! Sorry, my bad :(

 

I had played around with teleporting too, but I guess it is a bit harder than setting the coordinates of the player. Can't help you unfortunately :(

Link to comment
Share on other sites

 

When is this function called? Anything in the log?

It looks like it should work.

 

setY(0); will cause the game to crash.

Events.OnPlayerUpdate.Add(Kmod_Addition_Traits.OnPlayerUpdate);

 

I'm not quite sure whet OnPlayerUpdate is triggered.

Try adding a print() or pzdebug() statement to check if the function is called at all.

Link to comment
Share on other sites

OnPlayerUpdate is called quite often (maybe strapped to the FPS), but certainly not as frequent as OnTick.

 

OnPlayerUpdate is called quite often (maybe strapped to the FPS), but certainly not as frequent as OnTick.

I've tried moving the SetX, and onTick is also incredibly useful.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...