Modding Help Mod a tech

Discussion in 'Starbound Modding' started by FireFoxLP, Nov 16, 2017.

Tags:
  1. FireFoxLP

    FireFoxLP Void-Bound Voyager

    Hey guys , I was wondering if someone wanna help me out to mod a Tech :)
    I already Made One but I cant Select it ingame . I Need help , like how i can use it ingame :/

    ~Lucky
     
  2. bk3k

    bk3k Oxygen Tank

    You can make a quest to enable it, just like vanilla. You can also hook the vanilla tech interface's scripts to enable your techs too. There would probably be other ways if I stopped to think of them but I'm satisfied hooking into the interface scripts. I'd say you can look at my tech mod to see what I mean about the second option, but I have a better version of that in the works that supports different conditions for unlocking including just unlocking for admins.

    edit:

    The related part of the code I'm patching in
    /interface/scripted/techupgrade/bk3k_addTechs.lua

    Code:
    local addTechs_init = init
    --I'm copying whatever init function existed before, redifining it, running my own,
      --and finally running whatever was there before
    local extra_parseTech
     
     
    function init()
      local modTech = config.getParameter("modTech", {})
      for _, addedTech in ipairs(modTech) do
        extra_parseTech(addedTech)
      end
     
      addTechs_init()
    end
    
    
    extra_parseTech = function(tech)
      --This can accept a tech name in the form of a string
      --in which case the tech will simply unlock and be enabled
      --or you can set more detailed unlock requirements by passing a table
     
      --player.availableTechs()
      if type(tech) == "string" then
        player.makeTechAvailable(tech)
        player.enableTech(tech)
      else
        local pass
        local enabledTechs = player.enabledTechs()
        local unlockedTechs = player.availableTechs()
        local requirements = tech.requirements
         
        if tech.adminEnable and player.isAdmin() then
          --administrators drink for free
          player.makeTechAvailable(tech.name)
          player.enableTech(tech.name)
          return
        end
       
        if requirements == nil then
          requirements = {}
          pass = true
        end
               
        if requirements.techEnabled then
          for _, whatTech in ipairs(enabledTechs) do
            if requirements.techEnabled == whatTech then
              pass = true
              break
            end
          end
         
          pass = pass or false
        end
       
        if requirements.techUnlocked then
          for _, whatTech in ipairs(unlockedTechs) do
            if requirements.techUnlocked == whatTech then
              pass = (pass ~= false) and true
              break
            end
          end
         
          pass = (pass ~= false)
        end
           
        if requirements.quest then
          if requirements.allow_activeQuest then
            local goodEnough = player.hasCompletedQuest(requirements.quest) or player.hasQuest(requirements.quest)
            pass = (pass ~= false) and goodEnough
            player.hasQuest()
          else
            pass = (pass ~= false) and player.hasCompletedQuest(requirements.quest)
          end
        end
       
        if requirements.universeFlag then
          pass = (pass ~= false) and world.universeFlagSet(requirements.universeFlag)
        end
       
        if requirements.species then
          local species = player.species()
          local match = false
         
          for k, whatSpecies in ipairs(requirements.species) do
            if species == whatSpecies then
              match = true
              break
            end
          end
         
          pass = (pass ~= false) and match
        end
       
        if pass then
          if tech.unlockOnly then
            player.makeTechAvailable(tech.name)
          else
            player.makeTechAvailable(tech.name)
            player.enableTech(tech.name)
          end
        end
      end
    end
    
    And the current patch itself looks like this - excuse the chaos.
    /interface/scripted/techupgrade/techupgradegui.config.patch

    Code:
    [
      [
        {
          "op" : "add",
          "path" : "/scripts/-",
          "value" : "/interface/scripted/techupgrade/bk3k_addTechs.lua"
        }
      ],
     
      [
        {
          "op" : "test",
          "path" : "/modTech",
          "inverse" : true
        },
        {
          "op" : "add",
          "path" : "/modTech",
          "value" : []
        }
      ],
     
      //"implant"
     
      [
        {
          "op" : "add",
          "path" : "/modTech/-",
          "value" : {
            "name" : "bk3k_dash",
            "adminEnable" : true,
            "unlockOnly" : true
          }
        },
        {
          "op" : "add",
          "path" : "/modTech/-",
          "value" : {
            "name" : "bk3k_doubleDash",
            "adminEnable" : true,
            "unlockOnly" : true,
            "requirements" : {
              //"species" : [],
              //"universeFlag" : "",
              //"quest" : "",
              //"allow_activeQuest" : true,
              //"techUnlocked" : "bk3k_dash",
              "techEnabled" : "bk3k_dash"
            }
          }
        },
        {
          "op" : "add",
          "path" : "/modTech/-",
          "value" : {
            "name" : "bk3k_insaneDash",
            "adminEnable" : true,
            "unlockOnly" : true,
            "requirements" : {
              //"species" : [],
              //"universeFlag" : "",
              //"quest" : "",
              //"allow_activeQuest" : true,
              //"techUnlocked" : "bk3k_dash",
              "techEnabled" : "bk3k_doubleDash"
            }
          }
        },
        {
          "op" : "add",
          "path" : "/modTech/-",
          "value" : {
            "name" : "bk3k_ftlboost",
            "adminEnable" : true,
            "unlockOnly" : true,
            "requirements" : {
              //"species" : [],
              //"universeFlag" : "",
              //"quest" : "",
              //"allow_activeQuest" : true,
              //"techUnlocked" : "bk3k_dash",
              "techEnabled" : "bk3k_insaneDash"
            }
          }
        },
        {
          "op" : "add",
          "path" : "/modTech/-",
          "value" : "bk3k_multijump"
        }
        /*
        {
          "op" : "add",
          "path" : "/modTech/-",
          "value" : "bk3k_multijump_plusBoost_10"
        }
        */
      ]
    ]
     
    Last edited: Nov 16, 2017
  3. FireFoxLP

    FireFoxLP Void-Bound Voyager

    Thank you very much , I'd like to ask you if could help me sometimes with my Codes:) Because you seem pretty Good at modding c:
     
  4. bk3k

    bk3k Oxygen Tank

    Oh I edited my old response and you replied in the mean time. I was trying to avoid double posting. Now I should post again so you see I added more.

    That patch is WIP and has lots of commented out code so it is something of a mess. You could use what I posted though, only swapping in your own techs into the patch. You can use simple tech names strings(like what the currently uploaded version does) or use JSON objects like my patch is doing now. I don't mind helping if you need it.
     
  5. FireFoxLP

    FireFoxLP Void-Bound Voyager

    Wow Thank you so much!
    Im a newbie xD
    If you have discord or something , I would Really like to write with you and ask question , if u have no problem with that just reply with a yes or smth and i can text you my discord (if you have it xD )
    Thank you anyway you Made my life easier ^^
     
  6. bk3k

    bk3k Oxygen Tank

    I've never used discord. You can send a pm here though. I check fairly often.
     

Share This Page