Modding Help player.species() not working

Discussion in 'Starbound Modding' started by Nerd_Duk, Sep 21, 2018.

  1. Nerd_Duk

    Nerd_Duk Intergalactic Tourist

    I want to make race-specific bonuses but player.species() isn't working

    Code:
    function doMultiJump()
      mcontroller.controlJump(true)
      mcontroller.setYVelocity(math.max(0, mcontroller.yVelocity()))
      self.multiJumps = self.multiJumps - 1
      sb.logInfo(tostring(player.species()))
    
    end
    
    But then In the log, I get this
    Code:
    [15:27:41.036] [Error] Exception while invoking lua function 'update'. (LuaException) Error code 2, [string "/tech/jump/Flight.lua"]:50: attempt to index a nil value (global 'player')
    stack traceback:
        [C]: in metamethod '__index'
        [string "/tech/jump/Flight.lua"]:50: in global 'doMultiJump'
        [string "/tech/jump/Flight.lua"]:15: in function <[string "/tech/jump/Flight.lua"]:8>
    Please help
     
  2. The Avelon

    The Avelon Phantasmal Quasar

    Tech files don't have access to the player table, unfortunately. You won't be able to directly use any player.foo or world.foo entries in a tech.

    Race-specific bonuses can be applied via workaround for some things - a status effect can modify your base speed and jump for example, and techs can be written to be additive to base stats meaning one race can dash faster or further compared to another race by doing some math.
     
    bk3k likes this.
  3. bk3k

    bk3k Oxygen Tank

    It may interest you to know that I added species specific tech support in my tech helper mod. A couple of the optional parameters here -
    An example patch for using that mod.
    Code:
    [
      [
        {
          "op" : "test",
          "path" : "/modTech",
          "inverse" : true
        },
        {
          "op" : "add",
          "path" : "/modTech",
          "value" : []
        }
      ],
    
      [
        {
          "op" : "add",
          "path" : "/modTech/-",
          "value" : {
            "name" : "example_tech3",
            "adminEnable" : true,
            "unlockOnly" : true,
            "requirements" : {
              "species" : [ "hylotl" ],
              "excludeSpecies" : [ "glitch" ],
              "universeFlag" : "outpost_mission1",
              "quest" : "human_mission1",
              "allow_activeQuest" : true,
              "techUnlocked" : "dash",
              "techEnabled" : "sprint"
            }
          }
        }
      ]
    ]
    
    All the supported requirements are optional. Just use the ones you want to control for. But that easily allow you to make 2 versions of a tech - 1 for a specific species (or group of species) and another for everyone else. That won't stop you from using the same description for both techs thus giving the impression of 1 tech.
     
    The Avelon likes this.
  4. The Avelon

    The Avelon Phantasmal Quasar

    Can you disable/make unavailable a tech as well? I was just thinking for the Take All Hotkey mod I could use TechHelper to give and equip the player with a basic tech that enables take all and then remove it once they get either Dodge (FU users) or Dash (Vanilla) if so.

    Reading the overview I'm also highly interested in the potential for extra tech slots... I'm going to try my hand at that, since that would also neatly solve my problem and would be a fantastic base for other mods. If I get it working I'd like to just pass it to you to merge into TechHelper.

    EDIT: poked around a lot and could not find any way to add a new slot. I mean, one could be made visible, selectable, et cetera, but no techs would be able to be filtered to it because I think the tech database is hardcoded with only 3 slots available. I tried some common names like default and innate but even adding entries to techupgradegui.config (which would let you all BUT make a real fourth tech slot) doesn't make a fourth tech type work. Bummer...
     
    Last edited: Sep 23, 2018

Share This Page