Wolf_EX

  • Content count

    50
  • Joined

  • Last visited

Community Reputation

21 Excellent

About Wolf_EX

  • Rank
    Junior Member

Recent Profile Visitors

448 profile views
  1. This is the relevant code from my modmain.lua of my container mod local require = GLOBAL.require local Vector3 = GLOBAL.Vector3 local containers = require "containers" local refinerecipe = require "refinerecipe" Assets = { Asset("ANIM", "anim/ui_chest_3x1.zip"), } local params = {} --refine chest params.refinechest = { widget = { slotpos = { Vector3(-72, 0, 0), Vector3(72, 0, 0), }, animbank = "ui_chest_3x1", animbuild = "ui_chest_3x1", pos = GLOBAL.Vector3(0, 200, 0), side_align_tip = 160, }, type = "chest", } function params.refinechest.itemtestfn(container, item, slot) return refinerecipe[item.prefab] and (slot == 1 or slot == 2 and container.inst.on) end containers.MAXITEMSLOTS = math.max(containers.MAXITEMSLOTS, params.refinechest.widget.slotpos ~= nil and #params.refinechest.widget.slotpos or 0) local containers_widgetsetup_base = containers.widgetsetup function containers.widgetsetup(container, prefab, data) local t = params[prefab or container.inst.prefab] if t ~= nil then for k, v in pairs(t) do container[k] = v end container:SetNumSlots(container.widget.slotpos ~= nil and #container.widget.slotpos or 0) else containers_widgetsetup_base(container, prefab, data) end end You add this widget to your container with inst.components.container:WidgetSetup("refinechest") I'm pretty sure you can do all this in your containers lua file but most people do it in the modmain. If you want to look at the code from the mod it's https://steamcommunity.com/sharedfiles/filedetails/?id=1567856396
  2. most scripts use this and I seen it used in a loop so I'd imagine it can't be that slow. local x, y, z = inst.Transform:GetWorldPosition() local ents = TheSim:FindEntities(x, y, z, radius, {"TAGS"})
  3. Can you post your code? You shouldn't need to use replicas for the itemtestfn. Are you doing this in your containers lua file? I personally only ever done it in the modmain.lua. An example of one of my containers itemtestfn looks like function params.refinechest.itemtestfn(container, item, slot) return refinerecipe[item.prefab] and (slot == 1 or slot == 2 and container.inst.on) end
  4. You would copy wormwood.lua into your mods scrips/prefabs folder and add it to the PrefabFiles in the modmain like any other prefab in a mod, but I would advise against modding it like that unless you have no other option. It's better to use AddPrefabPostInit("wormwood", myfunction).
  5. From my experience, errors with caves enabled is from server side code running on the client. Are you using components without "if not TheWorld.ismastersim then"?