Modding Discussion Request/Help: Local-Body Teleportation

Discussion in 'Starbound Modding' started by demongoat, Apr 19, 2017.

  1. demongoat

    demongoat Void-Bound Voyager

    Hey Starbound Forums!

    I'm looking for a way to limit teleportation to only allow players to teleport when certain conditions are met.
    Starbound's default teleportation system is great, but a common complaint is the ease at which the universe can be explored and monopolized. I'm starting a session with friends and would like to change that, and it seems there's an opening for a mod that does just this!

    What I'm looking for would most likely be a .lua script run when a player attempts to teleport, or a GUI modification of the teleport dialogue.

    Ideally, I would like a mod/method that meets all of these criteria;
    • Beam Down: unaffected - maintain standard behaviour
    • Beam Up: RESTRICTED - only allow if the ship is orbiting the same celestial body the player is visiting.
    • Bookmark Teleportation: RESTRICTED - only allow if the marker is located upon the same celestial body the player is visiting
    • Missions/Gates & 'Environmental': unaffected - ideally maintain standard behaviour in story environments
    • Teleport Player To Ship: RESTRICTED - only allow if the ship is orbiting the same celestial body the target is visiting/stranded upon

    Without advanced modding knowledge, I'd assume this is possible through a method like this;
    1. Player activates teleport station/'Beam Up/Down' prompt.
    2. Code GETS player celestial body name/'coordinates' (x) and target celestial body name/'coordinates' (y)
    3. IF x == y THEN (standard functionality) ELSE DoNothing

    I know for sure the bookmark's celestial bodies are exposed through the teleporter, at least in the GUI. If it's possible to retrieve that data the only real problem becomes checking the ship's location, which could be stored locally within a file or by checking a player's save data (since I believe SHIPDATA maintains the ship's location??).

    Further expansions on this mod could include pixel teleport fees for travel monopolies (pixels >= TeleportFee THEN standard functionality + remove pixels from user, add pixels to owner) or 'Local System Teleportation', allowing players to teleport anywhere within the same system - theoretically possible and even simple if the standard method is also possible. If the mod was done in the form of a GUI modification, it could also be possible to gray-out inaccessible bookmarks.

    This would have some pretty fun ramifications on normal gameplay.
    Players could become stranded through careless teleportation use or destruction of passages back, relying on a rescue team to arrive before their supplies run out - ambushes could be laid to destroy teleporters, trapping players on a hostile planetoid - emergent gameplay of this sort is what makes Starbound great, but the current teleportation limits examples such as these. Let's fix that! Obviously this sort of mod isn't for everyone and works best when playing with a trusted group of friends, which is why this is a mod and not a feature (and I totally understand why they made it like this but hey I want my space bear grylls 100 days experience)!

    So what happens when a teleport fails?
    Well, the idea is this would intercept standard gameplay and run before the normal teleportation. If the conditions aren't met, nothing happens. Nothing whatsoever. Maybe a little "EH-OHH" error sound or something, but honestly that's just for aesthetics. What really matters is the effect on gameplay!

    If anyone would like to give this a go I'd love to help out!
    My modding knowledge for Starbound is pretty basic right now, but I have made mods for my own personal use in Starbound and other games. Of course whoever made it for me would get the honour of uploading to the forums/steam workshop under their own name and crediting! I just want to make my Starbound the ultimate 2D space exploration sandbox I've been looking for.

    If you don't feel like making it, but think you know how I might start doing this please PLEASE let me know! Even knowing where to start would be a huge help.

    Thanks for your time!
    -goat
     
    Last edited: Apr 19, 2017
  2. Cyel

    Cyel Zero Gravity Genie

    I think this would only be possible if you were to rewrite the whole teleporter UI, as the default one is hardcoded, and I don't think it'd be possible to rewrite it, as we cannot access one's bookmark list.

    Here's an example of only things we can configure for teleporters:
    Code:
    {
      "canBookmark" : false,
      "includePartyMembers" : true,
      "includePlayerBookmarks" : true,
      "destinations" : [
      {
      "name" : "Beam Down",
      "planetName" : "current orbited world",
      "warpAction" : "OrbitedWorld",
      "icon" : "beamdown"
      }
      ]
    }
    One way to do it would be to simply make your own bookmark system, unrelated to the vanilla one, which could be feasible but troublesome (and I'm somewhat tempted to try)
    Reworking the teleport system could also lead to some interesting features, such as sharing bookmarks as objects with other players

    Also note that the next update will rework space travel. Also, a bit related: there are workshop mods to extend the shipt's travel time: http://steamcommunity.com/sharedfiles/filedetails/?id=816488288
     
    Last edited: Apr 19, 2017
  3. demongoat

    demongoat Void-Bound Voyager

    Thanks for the reply Cyel! Love your blueprint on scan mod.

    Thanks for the heads-up about the space update. That got me hyped - and now I have to uninstall the space station mod... ah well! Looks like I chose the right time to start getting into Starbound. The idea of sharing bookmarks with players sounds pretty awesome! Maybe even a 'specify coordinates' mode to teleport to a precise location.. if you know precisely where you need to be. Hype!

    I dug around in the files for a bit and it seems like the teleporter stuff is all pretty exposed except for the whole bookmarks thing, dang it. Here's what I found;

    Destinations
    • OwnShip - the player's ship
    • InstanceWorld: (world) - any of the instanced worlds ie. the Outpost
    • OrbitedWorld - the world the player's ship is currently orbiting
    • CelestialWorld.(coordinates) - a specific world by its coordinates, and you seem to be able to add x and y to make the teleport more specific
    Functions
    • Teleport - get Destination and go there (duh!), though sometimes listed as 'warp' in the game. Confusing!!
    Something interesting in the 'beamout.lua' file...

    (The config it's talking about is the hidden status effect applied just before teleportation that causes the beam to appear)

    So the beam is a status effect that leads into a .lua calling a 'performteleport' function that likely runs the original 'Teleport' called by the dialogue. Cool! NOW WHERE THE HECK IS THAT FUNCTION?!!

    Bah again! Well anyway, from the looks of things it doesn't look too heinous of a task to make custom teleporters to replace the default ones. The main trouble seems to be storing bookmark stuff - the rest seems like pretty simple 'get coordinate' jazz. I'll see if I can't work out a way to fiddle with disabling 'Beam Up' based on OrbitedWorld != (Player Celestial Location), most likely in the same way underground teleport disabling is handled since I KNOW it's possible to turn that one off. One step at a time, right?

    UPDATE: Underground beam-up toggling appears to be hardcoded. I WILL DESTROY STARBOUND.

    Just kidding, I'm not giving up yet! I will find a way!
     
    Last edited: Apr 19, 2017
  4. Cyel

    Cyel Zero Gravity Genie

    What I had in mind was to make a "teleporter data chip" (that could be edited via a station, like storm's Macrochips, and have the gui script read it) and/or a "handheld teleporter" device (to avoid issues with vanilla clients? Might not be necessary, and could just patch all teleporters instead), where bookmark data would be stored in. I've played a bit with the idea, and the main problem is that, apparently, there's no way to know, from the planet, what world the ship is orbitting around. I was thinking that I could make a script run and gather data when leaving the ship, but since I didn't found a way to know, from the ship, what world the ship is orbitting around either... (there's /whoami, but there's no Lua equivalent??)

    Otherwise, I think it'd be possible to fake most of the functions of the usual teleporters; I've got it to teleport up and down, the rest just seems to be a matter of deciding where to store bookmark datas, and how to access them. I haven't yet played with how to teleport to party members, but worst-case scenario, I could make it teleport to any player in the server.

    (the warp function is
    Code:
    #### `void` player.warp(`String` warpAction, [`String` animation])
    Immediately warps the player to the specified warp target, optionally using the specified warp animation.
    Code:
    "Valid warp action formats include: OwnShip, OrbitedWorld, CelestialWorld:celestialcoordinates, InstanceWorld:worldid:<uuid>:<level>, ClientShipWorld:playeruuid, Player:playeruuid, Nowhere (current world). Most warp actions can have =xcoordinate.ycoordinate added to specify a position within that world."
    Vanilla bookmarks are stored on the player's file, under the format
    Code:
    [
      server1-UUID,
        [
          {
            "type" : "teleport",
            "name" : "Outpost - Ark Ruins",
            "planetName" : "",
            "icon" : "outpost",
            "targetWorld" : "InstanceWorld:outpost:-:-",
            "spawnTarget" : "arkteleporter"
          },
          {...}
      ],
      server2-UUID,
    [[...]]
    ]
    
    And most(? I can't find a way to get the planet 's Name) of these are gatherable via the API, so creating vanilla-identical bookmarks is probably possible

    I'm hoping for some juicy spacetime-related things in the Lua API in the next update
     
    Last edited: Apr 21, 2017
  5. demongoat

    demongoat Void-Bound Voyager

    So what we've got confirmed working or possible right now is:
    • Beaming up and down directly to ship via a device
    • Storing data within a device
    • Custom GUI
    Not working/needs work around:
    • Getting coordinates
    I'll do some digging when I get home and see if I can't figure out some way to jigger this into working somehow. This is honestly so simple in theory it's a *cough* shame we don't have functions to make it easier. *cough* Pls ship coordinates in space update chucklefish
     

Share This Page