How do I teleport a platform?

Place to get help with not working mods / modding interface.
Phleem
Burner Inserter
Burner Inserter
Posts: 6
Joined: Sat Feb 18, 2017 7:15 am
Contact:

How do I teleport a platform?

Post 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.
Muche
Smart Inserter
Smart Inserter
Posts: 1006
Joined: Fri Jun 02, 2017 6:20 pm
Contact:

Re: How do I teleport a platform?

Post 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.
Phleem
Burner Inserter
Burner Inserter
Posts: 6
Joined: Sat Feb 18, 2017 7:15 am
Contact:

Re: How do I teleport a platform?

Post 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...
Muche
Smart Inserter
Smart Inserter
Posts: 1006
Joined: Fri Jun 02, 2017 6:20 pm
Contact:

Re: How do I teleport a platform?

Post 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").
Phleem
Burner Inserter
Burner Inserter
Posts: 6
Joined: Sat Feb 18, 2017 7:15 am
Contact:

Re: How do I teleport a platform?

Post 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?
User avatar
Silari
Filter Inserter
Filter Inserter
Posts: 565
Joined: Sat Jan 27, 2018 10:04 pm
Contact:

Re: How do I teleport a platform?

Post 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.
Post Reply

Return to “Modding help”