Modding Help Spawning item on player interaction

Discussion in 'Starbound Modding' started by projectmayhem, Jul 22, 2017.

  1. projectmayhem

    projectmayhem Spaceman Spiff

    Ok, so trying to work on a vending machine that removes an item from the players inventory and spawns an item once it takes the item. Is there anything in the vanilla code I can look at to figure out how this is done? I was thinking maybe digging through the quest files. I'm sure they hold some sort of clue to losing item and gaining an item.
     
  2. Errors4l

    Errors4l Spaceman Spiff

    Although I have no idea if there is an easier and more "intended" way to accomplish this, I know it would be possible by using a ScriptPane interface. You may wish to wait for someone else to offer a better solution.

    The idea is to open an invisible interface that runs all code in the init function, and then closes itself. To check for, take and give items you'll want to check out the player Lua documentation in your Starbound folder.
    For a working example of such an invisible interface that closes itself automatically, you can take a look at the load outfit files in the below link (specifically the empty ScriptPane configuration and the init function of the script dismissing itself automatically).

    https://github.com/Silverfeelin/Starbound-StoredOutfits/tree/master/interface/storedOutfits

    To make the object open this interface, set these parameters:
    Code:
    "interactAction" : "ScriptPane",
    "interactData" : "/path/to/interface.config"
    
     
    IHart likes this.

Share This Page