Page 1 of 1

How do I teleport a platform?

Posted: Tue Feb 25, 2025 7:27 pm
by Phleem
I want to teleport my platform that reached Shattered Planet back home rather than waiting for it to fly back. Rsedding mentioned teleporting platforms in a post awhile back, so I believe it is possible, but I couldn't find an example of how to do it. I assume it's something like game.platform("platformname or id").teleport(<some way to identify Nauvis orbig>)?

I would really rather not run for 10+ more hours at 20 UPS which is the best this system can do while it manages a bajillion asteroid chunks around the returning ship.

Re: How do I teleport a platform?

Posted: Tue Feb 25, 2025 7:48 pm
by Muche

Code: Select all

game.surfaces[pid].platform.space_location=game.planets.nauvis.prototype
seems to work, where pid is the id of the platform's surface.

Re: How do I teleport a platform?

Posted: Tue Feb 25, 2025 8:10 pm
by Phleem
Thanks for the reply.

What is the platform pid?

I tried a variety of things including the "platform-8" displayed in the editor surfaces tab and got a variety of errors, including some stuff about something being read only...

Re: How do I teleport a platform?

Posted: Tue Feb 25, 2025 9:06 pm
by Muche
Not sure whether there is a simpler way, but this works:

Code: Select all

pid = (function(platformname) for surface_name, surface in pairs(game.surfaces) do if surface.platform and surface.platform.name == platformname then return surface_name end end end)("foobar")
where foobar is the platform's name.
But as this returns platform-N, I would have expected the platform-8 you tried to work (that is, pid="platform-8").

Re: How do I teleport a platform?

Posted: Tue Feb 25, 2025 9:37 pm
by Phleem
When I used "platform-8" it gave this error:

Lua_SpacePlatform::space_location is read only.

I thought it might be because I was hosting in multiplayer but I got the same error when I loaded it up single player. Is there some extended cheating mode I need to enable?

Re: How do I teleport a platform?

Posted: Tue Feb 25, 2025 10:37 pm
by Silari
Phleem wrote: Tue Feb 25, 2025 9:37 pm When I used "platform-8" it gave this error:

Lua_SpacePlatform::space_location is read only.

I thought it might be because I was hosting in multiplayer but I got the same error when I loaded it up single player. Is there some extended cheating mode I need to enable?
You need to be on the experimental branch to set the location as writing was only added in 2.0.34. Stable is still only using 2.0.32 which won't let you write it.