Modding Help An item which kills all currently-out captive monsters, making them drop their filled pod/teleports

Discussion in 'Starbound Modding' started by wolfboyft, May 19, 2015.

  1. wolfboyft

    wolfboyft Pangalactic Porcupine

    I have two items I wish to create:
    The Pet Teleporter and the Pet Retreiver.

    The teleporter teleports all your currently out captive monsters to you.
    The retriever kills all your currently out captive monsters, making them drop their filled pod.

    These are craft-able at the creature capture station. You simply click with whatever hand its in (they're one handed) and it does its job.

    I can follow some simple tutorials about how to add the craft-able base items with textures and such, but how do I add the functionality?

    Any help appreciated,

    -wolfboyft
     
  2. Kayuko

    Kayuko Oxygen Tank

    Best Answer
    ... if distance > captiveState.teleportDistance then
    movement = 0
    if world.entityHandItem(self.entityOwnerId, "primary") == "monsterWhistle" then
    mcontroller.setPosition(ownerPosition)
    end
    elseif ...

    if( entityHandItem(ownerID, 'monsterWhistle');
    {monster.die()}

    If anything:

    if distance > captiveState.teleportDistance and world.entityHandItem(self.ownerEntityId, 'monsterWhistle') then
    movement = 0
    mcontroller.setPosition(ownerPosition)
    elseif distance < captiveState.closeDistance then
    stateData.running = false
    movement = 0

    *inserts usual I think quote*

    One does not simply call two ifs in that manner, I shall add.
     
    The | Suit likes this.
  3. Peelz

    Peelz Giant Laser Beams

    I imagine you'd have to attach a Lua script that would find all nearby monsters and deal lethal damage to them. I'm not sure how you would specify only captive monsters though.
     
  4. Kayuko

    Kayuko Oxygen Tank

    You could look the "how" up in captiveState or capturePod.lua, it should definetly be defined in one of them.
     
    Peelz likes this.
  5. wolfboyft

    wolfboyft Pangalactic Porcupine

    Hm... trying the teleport whistle first... wait, no, pet telporter. :D

    Code:
     local movement
      if distance > captiveState.teleportDistance then
        movement = 0
        mcontroller.setPosition(ownerPosition)
    See that code there? I need the last line, don't I?
     
  6. Kayuko

    Kayuko Oxygen Tank

    Guess so... not good at lua, but thats the only thing that makes sense.
    No clue why mcontroller is used for so many things tho.
     
  7. wolfboyft

    wolfboyft Pangalactic Porcupine

    It's... so... magical... what is it? :D

    But seriously though...

    Do you know whether there's a way to detect, in captivestate.lua, if the owner has used a certain item? I can go from there by using that fantastic line.
     
  8. Kayuko

    Kayuko Oxygen Tank

    There isn't, however, there are lots of other scripts defining if the player used an item. You should be able to put that in, lemme get an example.
    (COMPLETELY NO GUARANTEE, SINCE Lua (for @Kawa, my dear) NOOB ) D:
     
  9. wolfboyft

    wolfboyft Pangalactic Porcupine

    I think we could use t
    You CERTAIN?

    local ownerPosition = world.entityPosition(self.ownerEntityId)

    We could... take the owner... and... eh. Ok.
     
  10. Kayuko

    Kayuko Oxygen Tank

    Wow, I couldn't find anything. (Y U down Lua Docs)
    However, one workaround would be adding an item that applies an effect.
    You can base the script off that, so when the effect ends the pet is teleported to you.

    Btw, checked the other thread alrdy? x:
    Not sure if you got the alert.
     
  11. wolfboyft

    wolfboyft Pangalactic Porcupine

    Hmm... could you elaborate? Wait, do you mean... you give the pet the effect now, then... you stick it to get stuck in a hole, run away, then when its effect ends it teleports to you? Or have I totally misunderstood?
     
  12. Kayuko

    Kayuko Oxygen Tank

    Lol.
    I... well... I'll just pretend that didn't happen.

    Consume Item.
    Call code thats basically saying:

    if (inserteffect) wears off,
    teleport (pet entry) to (owner entry)
     
  13. wolfboyft

    wolfboyft Pangalactic Porcupine

    OH! The effect is on the PLAYER! D'oh.

    Or have I boobed again? :D
     
  14. Kayuko

    Kayuko Oxygen Tank

    Nono, that's what I meant.
    You could also do it on the pet, but well, on getting controlled statusEffects on the player is a lot easier. x:
     
  15. wolfboyft

    wolfboyft Pangalactic Porcupine

    [​IMG] My brain right now. I feel... well, it won't start. NOT RESPONDING -- Oh! There. I feel like a total idiot.

    Anyway. So you're saying that when a status effect ends, you have access to a player's pet ID's, letting you teleport them to the player?
     
  16. Kayuko

    Kayuko Oxygen Tank

    You always have access to both positions.
    Just found something else.

    if status.statPositive("breathProtection")

    Example, keep that in mind.

    So, in logic-language (since I can't do that in code, cuz noob).

    local movement
    if status.statPositive("YourStat") then
    movement = 0
    mcontroller.setPosition(ownerPosition)

    Don't pin me on that tho, didn't study sb-lua yet.
     
  17. wolfboyft

    wolfboyft Pangalactic Porcupine

    Found out that I'm not so keen on Status Effects...

    Maybe... is there... like... another thing...? Ah-ha...? You know here...
    Code:
    {
      "itemName" : "teleportwhistle",
      "rarity" : "Rare",
      "price" : 50,
      "inventoryIcon" : "tele.png",
      "description" : "Use this to teleport all pets on the map to you!",
      "shortdescription" : "Pet Teleporter",
      "handPosition" : [8, 0],
    "effects" : [
               
                             ],
      "emote" : "",
      "emitters" : [ "stimuse" ]
    }
    The empty effects space, could we get it to simply trigger an event (lua!) that the pets are listening out for?
     
  18. Kayuko

    Kayuko Oxygen Tank

    Thats... how all that stuff above works... x:
    There are a lot of ways to go for it.
    Modifying player resources would work too.
    Just attach the written lua to this item.
    (Not in the effects bracket tho)
     
  19. wolfboyft

    wolfboyft Pangalactic Porcupine

    Found a way. Storage and self.

    If only I could figure out how to retrieve some storage from the owner...
     
  20. Kayuko

    Kayuko Oxygen Tank

    Why would you use storage? @.@ I'm slightly confused.
     
  21. wolfboyft

    wolfboyft Pangalactic Porcupine

    The retrieve, in the captivestate.lua for the pet, would say
    elseif self.ownerEntityId.storage.iwantyoutoteleporttome == true then
    mcontroller.setPosition(ownerPosition)
    Or some such.[DOUBLEPOST=1432003364][/DOUBLEPOST]
    Self then. It would... basically, I'm just trying to get the player to have some self variable go into him, called tele or whatever, and then the pet be listening for that. Then when it finds one, it will teleport.
     

Share This Page