Page 1 of 1
Player object inside ABM

Posted:
Sun Nov 20, 2016 13:44
by ErrorNull
How can i access the player object inside an ABM? I'm creating an abm that will automatically generate a new special node several positions behind the player every 60 seconds, but i need to somehow get the position of the player. Is there something simple I'm overlooking?
Re: Player object inside ABM

Posted:
Sun Nov 20, 2016 14:59
by pithy
An ABM is a bad way to do that.
I would use minetest.register_globalstep(func(dtime)) and minetest.get_connected_players().
Re: Player object inside ABM

Posted:
Sun Nov 20, 2016 22:01
by ErrorNull
Hmm.. thanks pithy. i also agree that globalstep and get_connected_players could be alternative way to implement what i mentioned. but let's say an unrelated situation where i must use an ABM (like for mob spawning or farming) ... is there any way to have access to a player's position from inside an ABM?
Re: Player object inside ABM

Posted:
Mon Nov 21, 2016 00:25
by pithy
You can still use minetest.get_connected_players() in an ABM.
If you only want nearby players, use minetest.get_objects_inside_radius(pos, radius).
Then use is_player() to check if it is a player.
Re: Player object inside ABM

Posted:
Mon Nov 21, 2016 02:20
by ErrorNull
ok. i'll try that thanks!