ID:1740327
 
(See the best response by Kaiochao.)
I've been trying to figure out how to do this since I posted that post. However, despite being told how to do it, I cannot actually begin program any of it. I was wondering if I could have a head start.

I've taken a look at the SwapMaps Housing, and I understand half of it.

EDIT: I'd preferably like to click on the ship and warp from there, rather than spawning an invisible turf (since unlike houses, ships are dynamic).
Best response
What part of the housing demo do you not understand?

It's helpful to keep in mind that the ship exterior moves while the interior doesn't, but you still have to connect them somehow.
//bumped code
atom
proc/Bumped(atom/movable/o)
return 0

movable/Bump(atom/a)
a.Bumped(src)

return ..(a)

mob/player
var
swapmap/map
Savedx
Savedy
Savedz
Location
dead

verb
CreateShip()
map = SwapMaps_Find("[src.ckey] ship")
if(map)
Savedx = x
Savedy = y
Savedz = z

var/obj/Ship/S = new/obj/Ship(src.loc)
S.Owner = src.ckey
S.name = "[src]'s ship"

src.loc = locate(map.x1+12, map.y1+1,map.z1)
src.Location = "[S.Owner] ship"
else
Savedx = x
Savedy = y
Savedz = z

var/obj/Ship/S = new/obj/Ship(src.loc)
S.Owner = src.ckey
S.name = "[src]'s ship"

src.map = SwapMaps_CreateFromTemplate("shipmap")
map.id = "[src.ckey] ship"

src.loc = locate(map.x1+12, map.y1+1,map.z1)
src.Location = "[S.Owner] ship"


obj
Ship
//icon = 'ship.dmi'
//icon_state = "ship"
density = 1

var/Owner = null

Bumped(var/mob/player/M) // when the player bumps into the ship
M.Savedx = src.x
M.Savedy = src.y-1
M.Savedz = src.z
var/swapmap/SM = SwapMaps_Find("[Owner] ship")
if(SM)
M.loc = locate(SM.x1+12,SM.y1+1,SM.z1)
M.Location = "[Owner] ship"

else
SM = SwapMaps_Load("[Owner] ship")
M.loc = locate(SM.x1+12,SM.y1+1,SM.z1)
M.Location = "[Owner] ship"

Del()
for(var/mob/player/P)
if(P.Location == "[Owner] ship")
P.loc = locate("Afterlife")
P.dead = 1
var/swapmap/SM = SwapMaps_Find("[Owner] ship")
if(SM)
del(SM)
SwapMaps_DeleteFile("[Owner] ship")




turf
ShipExit
//icon = 'ship.dmi'
//icon_state = "ship exit"
Entered(var/mob/player/M)
M.loc = locate(M.Savedx, M.Savedy, M.Savedz)
if(M.Location)
M.map = SwapMaps_Find("[M.Location]")
if(M.map)
if(M.map.InUse())
M.map.Save()
else
M.map.Unload()


M.Location = null

mob/player
Logout()
if(Location)
map = SwapMaps_Find("[Location]")
if(map)
if(map.InUse())
map.Save()
else
map.Unload()
..()


Login()
if(Location)
map = SwapMaps_Find("[Location]")
if(map)
loc = locate(map.x1+12,map.y1+1,map.z1)
else
map = SwapMaps_Load("[Location]")
if(map)
loc = locate(map.x1+12,map.y1+1,map.z1)
else
loc = locate("Afterlife")
dead = 1
..()


I didn't test it, prolly a few mistakes in there. Though that should show you roughly what you need to do.

Keep in mind, if you have any sort of teleportation skill you're going to have to change their Location var to the place that they teleported to(only if you tp in/out of ship). Location is only for ships, if you're not in a ship it should always be null.