Helwdrokin

  • Content Count

    5
  • Joined

  • Last visited

Community Reputation

3 Neutral

About Helwdrokin

  • Rank
    Junior Member
...

Recent Profile Visitors

49 profile views
  1. it worked Monti18, I just had to use an if statement to check which inventory slot the soul was in before dropping it, otherwise the character would end up dropping the last item in the inventory i am realy glad for the help ty Monti18 and ty Nelzanger you realy helped me understand how lua works
  2. is i tried to search for a function that could replace FindItems() but i couldn't find one i really don't know what to do, i think only if make a function that could replace finditems but idk what self (in inventory.lua) and inst (in general) exactly do
  3. so i am new at moding, and i was trying to understand how the inventory works in dont starve so in the gamesfiles have three inventories inventory.lua inventory_replica.lua inventory_clasified.lua can you help me to undestand the diference between them ?
  4. so i'm trying to make a mod that checks how many souls wortox has, and when it reaches a certain number, it will drop the excess soul to avoid getting more than 20 souls, and losing sanity due to soul overload. that my code local _G = GLOBAL local MAX = GetModConfigData("MAXSOULS") local function IsSoul(item) return item.prefab == "wortox_soul" end local function GetStackSize(item) return item.components.stackable ~= nil and item.components.stackable:StackSize() or 1 end local function TheDrop(parent) local souls = parent.components.inventory:FindItems(IsSoul) local count = 0 for i, v in pairs(_G.ThePlayer.replica.inventory:GetItems(IsSoul)) do if v ~= nil and v.prefab == "wortox_soul" then for i, v in ipairs(souls) do count = count + GetStackSize(v) end if count > MAX then _G.ThePlayer.replica.inventory:DropItemFromInvTile(v) end end end end AddPlayerPostInit(function(inst) inst:DoPeriodicTask(0.5, function() if 1==1 then TheDrop(inst) end end) end) it works fine in local worlds, but when i add caves or go to a server the games crashes thats the log [00:28:15]: [string "../mods/_Wortox Souls Droping/modmain.lua"]:16: attempt to index field 'inventory' (a nil value) LUA ERROR stack traceback: ../mods/_Wortox Souls Droping/modmain.lua:16 in (upvalue) TheDrop (Lua) <15-29> ../mods/_Wortox Souls Droping/modmain.lua:34 in (field) fn (Lua) <32-36> scripts/scheduler.lua:177 in (method) OnTick (Lua) <155-207> scripts/scheduler.lua:371 in (global) RunScheduler (Lua) <369-377> scripts/update.lua:191 in () ? (Lua) <170-249> this is my first forum post, so sorry if i did something wrong, and ty for you time