Modding Help Item swapping tech

Discussion in 'Starbound Modding' started by Tuesday's Eyebrow, Nov 10, 2014.

Thread Status:
Not open for further replies.
  1. Tuesday's Eyebrow

    Tuesday's Eyebrow Phantasmal Quasar

    So, here's my question: Is it possible to make a tech check for a specific item and swap it for another one? if so, how might this be done. I know that there's a way to make it check for weapons, because of the Weapon Tech mod... but how about other items?
     
  2. Peelz

    Peelz Giant Laser Beams

    I believe you can have a LUA script check the contents of a container and add/remove items from that container. I don't believe this works with the player's inventory though.

    As far as the player goes, the API only has functions for checking what item is currently held by the player. I think. I could be wrong though.
     
    severedskullz likes this.
  3. Riuny

    Riuny Big Damn Hero

    Okay, I just read your thread in my discussion section and I'll give you my opinion.

    1.As far as I know, the only way to make users to have TRULY unique(literally) item in this game, is to give them an un-craftable item as a default inventory(Right at the beginning of the game).

    2.I haven't tried this yet but, what I'm thinking, is that you might be able to change specific item in your hand with LUA script. I searched up and found this code strip at wiki.

    entity.setItemSlot
    Sets specified slot to contain the specific item.
    Currently, there are only the following slots:
    • primary, alt - Left and right hand.
    • slot0 to slot9 - on-hand items.
    • sheathed0 to sheathed9 - off-hand items.
    Additional Information:
    Available to: npcs.
    Parameters:
    • slot: (string) The slot to change.
    • item: (table<Item>) The item to be assigned to that slot.
    Usage:
    entity.setItemSlot (string slot, table item)

    So, my opinion is, that you could create tech module which requires certain weapon in your hand to use abilities, and set an input key to swap between available weapons. This is just a theory. You probably have to run some experiments with this to actualize what you want to make.
     
  4. You overlooked a very important note in your own reply. You cannot run most commands on players (With the exceptions being the ones in the Tech library). Only queries.
     
  5. Riuny

    Riuny Big Damn Hero

    Well, you can always try to see if it really works or not.(Since I haven't tried it myself, yet) At least in my opinion, experimentalism is not bad, even if it is a proven truth.
     
  6. Tuesday's Eyebrow

    Tuesday's Eyebrow Phantasmal Quasar

    Thanks guys. I'll have to give this a try when I have some time to experiment. Life's just caught up to me at the moment, so it might be awhile. Also, where did you find the code strip? It sounds like I could do allot of my own research there. < Nevermind, I found it fairly quick.
     
  7. Tuesday's Eyebrow

    Tuesday's Eyebrow Phantasmal Quasar

    Okay, so I tried it and so far it doesn't work (Well, when I press "F" the game lags for a half a second). Here's my lua, just in case I did something wrong and you know how to fix it: http://pastebin.com/veMaMwun
     
  8. Riuny

    Riuny Big Damn Hero

    It'll be better to use world.entityHandItem rather than entity.getItemSlot. Checking part of the code should be like this.
    Code:
    if world.entityHandItem(tech.parentEntityId(),"primary") == "kingdomkeykeychain" then
    Also, entity codes work a little bit different compare to other codes. You have call world.callScriptedEntity first to use it. So, the changing part of the script would be somewhat like below.
    Code:
    world.callScriptedEntity(tech.parentEntityID(),"entity.setItemSlot","primary","kingdomkey")
    I might be wrong about the quotation of the variables used in callScriptedEntity, but I'm sure you can find what is faulty in the error log if game lags or crashes. If this doesn't work, then you might have to come up with new idea. So good luckX3
     
  9. As I said before... you cannot call functions on the player. The only thing you can do is query it. The entity library is not available to the player or the tech.
    The only library you have access to is "world". That's it.
     
  10. Tuesday's Eyebrow

    Tuesday's Eyebrow Phantasmal Quasar

    Okay then, Maybe you could suggest a solution as well. All I need is some way to let people have only one of the "keyblade" item type unless otherwise stated. They would have to also be able to change which one they have. So, if there some magical solution, like giving an item a slot of its own, then I would love to hear it, otherwise I may have to resort to roundabout ways of doing this, like turning the weapon into a Placeable item that, when interacted with, drops a base and a Keychain (Like how crops can drop more than one type of item.). I just wanted something a little more... Elegant?... Graceful... Subtle maybe?
     
  11. If there was a solution, I would have suggested it already. The closest thing you can do is use a placeable object and use the storage API to swap out the item when it is put inside the placeable object. Anything short of that is not possible. You are not able to modify the players inventory. You are not able to pull up interfaces via tech, and you are unable to manually swap hand items as the query is read only.
     
  12. Ecafymtoohs

    Ecafymtoohs Big Damn Hero

    Perhaps scripts\items\rotting.lua could bring some light to this?
     
  13. The | Suit

    The | Suit Agent S. Forum Moderator

    Its been 4 years, Severed Skullz has left a while ago.
     
Thread Status:
Not open for further replies.

Share This Page