Jump to content

Recommended Posts

My companion for my mod is acting a bit wonky, but fine until I attack it. When I attack it my game crashes and I get this

[string "scripts/components/lootdropper.lua"]:147: bad argument #1 to 'ipairs' (table expected, got string)
LUA ERROR stack traceback:
=[C]:-1 in (global) ipairs (C) <-1--1>
scripts/components/lootdropper.lua:147 in (method) GenerateLoot (Lua) <94-177>
   self =
      trappable = true
      inst = 114196 - edwin (valid:true)
      loot = LOOT
      droppingchanceloot = false
   loots = table: 57AA0E00
scripts/components/lootdropper.lua:251 in (method) DropLoot (Lua) <250-268>
   self =
      trappable = true
      inst = 114196 - edwin (valid:true)
      loot = LOOT
      droppingchanceloot = false
   pt = (-363.13, 0.00, 103.09)
scripts/stategraphs/SGhound.lua:129 in (field) onenter (Lua) <124-130>
   inst = 114196 - edwin (valid:true)
scripts/stategraph.lua:501 in (method) GoToState (Lua) <450-511>
   self =
      timelineindex = 1
      tags = table: 571D47B0
      mem = table: 51F2B800
      statemem = table: 571D4760
      currentstate = table: 51F38AF0
      timeinstate = 0
      sg = Stategraph : hound
      inst = 114196 - edwin (valid:true)
      bufferedevents = table: 15BE8830
      lastupdatetime = 130.06667345017
      statestarttime = 130.0333401151
      laststate = table: 51F367A0
      prevstate = table: 51F367A0
   statename = death
   params = nil
   state = table: 51F38AF0
scripts/stategraphs/SGhound.lua:11 in (field) fn (Lua) <11-11>
   inst = 114196 - edwin (valid:true)
scripts/stategraph.lua:400 in (method) HandleEvents (Lua) <391-411>
   self =
      timelineindex = 1
      tags = table: 571D47B0
      mem = table: 51F2B800
      statemem = table: 571D4760
      currentstate = table: 51F38AF0
      timeinstate = 0
      sg = Stategraph : hound
      inst = 114196 - edwin (valid:true)
      bufferedevents = table: 15BE8830
      lastupdatetime = 130.06667345017
      statestarttime = 130.0333401151
      laststate = table: 51F367A0
      prevstate = table: 51F367A0
   buff_events = table: 15BE8830
   k = 2
   event = table: 571D43C8
   handler = table: 51F35E90
scripts/stategraph.lua:145 in (method) Update (Lua) <109-148>
   self =
      updaters = table: 571D3108
      OnEnterNewState = function - scripts/stategraph.lua:27
      tickwaiters = table: 32FA0768
      haveEvents = table: 571D4738
      hibernaters = table: 32FA0808
      instances = table: 32FA06F0
   current_tick = 3910
   waiters = table: 54B59570
   updaters = table: 571CF850
   evs = table: 571CF878
   k = sg="hound", state="death", time=0.30, tags = "busy,"
   v = true
scripts/update.lua:209 in () ? (Lua) <150-223>
   dt = 0.033333335071802
   tick = 3910
   i = 3910

Can I get some help?

edwin.lua

edwin_summon.lua

Link to comment
https://forums.kleientertainment.com/forums/topic/67721-companion/
Share on other sites

8 minutes ago, devon7600 said:

My companion for my mod is acting a bit wonky, but fine until I attack it. When I attack it my game crashes and I get this

You put a string instead of a table for loot.

local function linktoplayer(inst, player)
	inst.components.lootdropper:SetLoot("LOOT")
    inst.persists = false
    inst._playerlink = player
    player.edwin = inst
    player.components.leader:AddFollower(inst, true)
    for k, v in pairs(player.edwin_summons) do
        k:Refresh()
    end
    player:ListenForEvent("onremove", unlink, inst)
end
	
local LOOT = {"edwin_summon"}

should be

local LOOT = {"edwin_summon"}

local function linktoplayer(inst, player)
	inst.components.lootdropper:SetLoot(LOOT)
    inst.persists = false
    inst._playerlink = player
    player.edwin = inst
    player.components.leader:AddFollower(inst, true)
    for k, v in pairs(player.edwin_summons) do
        k:Refresh()
    end
    player:ListenForEvent("onremove", unlink, inst)
end

So you give the table on the variable LOOT, and not the string "LOOT".

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
  • Create New...