Modding Help Is it possible to ...

Discussion in 'Starbound Modding' started by Lulero, Dec 18, 2013.

  1. Lulero

    Lulero Space Hobo

    Hi !

    Just added a suggestion to the appropriate forum and decided to mod it for experimental purpose.

    However, before I start getting my hand dirty, I'd like to know if it's doable with the tools available.

    What I need and feel is missing at the moment:
    • Ability to teleport the player upon activation of a specific item.
    • Ability to access current planet data to decide on the destination (or denial if lack of).
    Lulero

    Edit: I realize it would be more appropriate with the "Modding discussion" tag, but couldn't figure out how to change it.
     
  2. lonesurvivor

    lonesurvivor Big Damn Hero

    I don't think you can manually teleport the player at the moment, at least there is no way I know of.

    Edit: nevermind, there is actually a way. With a tech, you can call tech.translate(translation) to move the player by a certain distance.
     
    Last edited: Dec 18, 2013
  3. Lulero

    Lulero Space Hobo

    Thank for the answer.

    What I want to do is to teleport the player from a custom made pad to another in a set direction (up, down, right or left) depending on the starting one. As a way to reach/leave an underground complex for example. You'd beam down from your ship as you do now then use one of those pads to reach the underground. Start and destination pads have to be perfectly aligned for it to work. You could also use those to fast travel on a planet on the X axis as long as you can make sure all needed pads are on the exact same height, like in a mega straight forward tunnel.

    As far as I understand from your post, since tech.translate(...) takes only an integer as argument it moves the player according to the direction he's facing, right? So no up/down directions.
    And regarding the second requirement, can I scan the map for the destination pad? Thinking about it, even if possible it's probably limited to what parts of the planet is currently loaded, maybe, maybe not.
     
  4. hitachihex

    hitachihex Void-Bound Voyager

    there is definitely a way to teleport the player, even if you can't find a way to do it in a lua script

    teleporting the player simply involves modifying your X,Z coords in memory. just the same as they would change if you were to move manually with the default controls. the only thing that would prevent you from doing so would be a server detection method (distance interpolation likely, notice a sudden change and blip you back, or auto boot you).

    in singleplayer there would be no such thing to stop you, just for reference.

    i suggest looking here:
    http://starbounder.org/Modding/Lua

    see entity.Position? try getting a reference to your player entity and modifying that from within your lua script

    edit: for debugging savy:

    Code:
    0081AF60  $ 85D2          TEST EDX, EDX        ; lua_pcallk
    
    eax = lua_state (would have to use inline assembly to put the state into eax)
    
    0081AF60 is current address for current version
    
    
    Code:
    0081EB4F  |. C70424 50D2810>MOV DWORD PTR SS:[ESP],starboun.0081D250                ;  ; l_alloc
    0081EB56  |. E8 15690000    CALL starboun.00825470                                  ;  ; lua_newstate
    0081EB5B  |. 85C0          TEST EAX,EAX                  ;  ; eax = lua_state
    
    
    0081EB4F - 0081EB5B is current address(s) for current version
    
    
    
    you'll have to either loadstring or loadfileex first before using pcallK, and probably do some setfenv'ing
    but this way you could toss in your own lua code without using an object to test things.

    hooking 0081EB5B and getting the result of eax is good enough for getting the lua state for the interpreter
     
    Last edited: Dec 18, 2013
    lonesurvivor and Lulero like this.

Share This Page