• Content Count

  • Joined

  • Last visited

Community Reputation

21 Excellent

About Wolf_EX

  • Rank
    Junior Member

Recent Profile Visitors

698 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. I was considering making an in depth weapon and maybe character mod tutorial on youtube. I never done anything like that before though so not sure. you get decompile an anim file to get the scml file/images using krane The ground image is a seperate spriter file from the equipped image. It's the anim file that goes into setBank and SetBuild. It's really weird how hats and amulets works to get them in 4 directions. iirc the images have to have a specific name and in spriter you have to drag each image into the window, then delete it. If you open the scml file in a text editor, you will see the images in there and can edit the x/y values to get them positioned right. There might be an easier way of doing it but It took me days messing with that to figure it out and I never want to make an item like that again lol. I can upload my amulet mod with the exported folder if you want to mess with it.
  5. A lot of your code for the weapon is from don't starve instead of don't starve together. Your onEquip/Unequip should be outside the main function, your missing network code, and some code is different like "local trans = inst.entity:AddTransform()" should be "inst.entity:AddTransform()". Here is what it should look like. local assets = { Asset("ANIM", "anim/chocolate_weapon.zip"), Asset("ANIM", "anim/swap_chocolate_weapon.zip"), Asset("ATLAS", "images/inventoryimages/chocolate_weapon.xml"), Asset("IMAGE", "images/inventoryimages/chocolate_weapon.tex"), } local prefabs = { } local function OnEquip(inst, owner) owner.AnimState:OverrideSymbol("swap_object", "swap_chocolate_weapon", "chocolate_weapon") owner.AnimState:Show("ARM_carry") owner.AnimState:Hide("ARM_normal") end local function OnUnequip(inst, owner) owner.AnimState:Hide("ARM_carry") owner.AnimState:Show("ARM_normal") end local function fn() local inst = CreateEntity() inst.entity:AddTransform() inst.entity:AddAnimState() inst.entity:AddNetwork() inst.AnimState:SetBank("chocolate_weapon") inst.AnimState:SetBuild("chocolate_weapon") inst.AnimState:PlayAnimation("idle") MakeInventoryPhysics(inst) if not TheWorld.ismastersim then return inst end inst.entity:SetPristine() --inst:AddComponent("weapon") --inst.components.weapon:SetDamage() --inst.components.weapon:SetOnAttack(OnAttack) inst:AddComponent("inventoryitem") inst.components.inventoryitem.imagename = "chocolate_weapon" inst.components.inventoryitem.atlasname = "images/inventoryimages/chocolate_weapon.xml" inst:AddComponent("equippable") inst.components.equippable:SetOnEquip(OnEquip) inst.components.equippable:SetOnUnequip(OnUnequip) return inst end return Prefab("common/inventory/chocolate_weapon", fn, assets, prefabs) The weapon spawns but the image doesn't show up in your hand, might be an issue with your anim file. Might have to rebuild it.
  6. 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).
  7. I came up with a solution of having the swap_meter as the full bar and just using ClearOverrideSymbol to remove the OverrideSymbol. This seems like a hack to my issue but don't think there will be any issues with it. local function OnFuelSectionChange(new, old, inst) if inst._fuellevel ~= new then inst._fuellevel = new if inst._fuellevel == 10 then inst.AnimState:ClearOverrideSymbol("swap_meter") else inst.AnimState:OverrideSymbol("swap_meter", "chest_meter", tostring(new)) end end end
  8. I am having the same issue as the last post on this thread I added a fuel bar to my item and the fuel bar disappears when the fuel is maxed. I use this code to change the meter but when new = 10 it just disappears. I have the image/folder for 10 in the chest_meter anim so I'm am not sure why it isn't showing up. local function OnFuelSectionChange(new, old, inst) if inst._fuellevel ~= new then inst._fuellevel = new inst.AnimState:OverrideSymbol("swap_meter", "chest_meter", tostring(new)) end end I can upload the mod if you need it.
  9. if inst.components.inventoryitem:GetContainer().inst.prefab == "icebox"