Page 1 of 1

LuaEntity.speed for asteroids

Posted: Fri Jun 27, 2025 8:40 pm
by egladil
It would be useful to be able to read and modify the speed of asteroids at runtime. This could be used i.e. for making tractor beam turrets or deflector shields.

An alternative to having it be writable would be something similar to PushBackTriggerEffectItem that modifies speed instead of position. (And works on asteroids, which PushBackTriggerEffectItem does not seem to do?)

Re: LuaEntity.speed for asteroids

Posted: Mon Sep 08, 2025 9:06 pm
by egladil
A small bump on this in case it was missed during summer

Re: LuaEntity.speed for asteroids

Posted: Mon Sep 08, 2025 9:42 pm
by Rseding91
Asteroids don’t have an internal speed value. They have an internal movement per tick value which is a 2D vector that gets added to the asteroid position each tick.

So if this was exposed it would need to be as a new value: “movement” or such.

Re: LuaEntity.speed for asteroids

Posted: Tue Sep 09, 2025 4:30 pm
by egladil
Right, I must have misread the documentation for speed. I assumed that was a 2d vector as well. Having "movement" exposed as read/write to script would indeed solve this for me

Re: LuaEntity.speed for asteroids

Posted: Thu Sep 11, 2025 5:07 pm
by Bilka
Okay, I added LuaEntity::get_movement() and set_movement() for 2.0.67.

Re: LuaEntity.speed for asteroids

Posted: Thu Sep 11, 2025 5:47 pm
by egladil
Thanks!