Wolf_EX

  • Content count

    38
  • Joined

  • Last visited

Community Reputation

11 Good

About Wolf_EX

  • Rank
    Junior Member
  1. I have a container with a button and when you press that button, it executes a function. The issue is that I'm doing this from the modmain and the function is from a serverside component, so it causes an error when I click it. function params.refinechest.widget.buttoninfo.fn(inst, doer) if REFINECHESTFUEL then if not inst.components.fueled:IsEmpty() then inst.components.machine:TurnOn() end else inst.components.machine:TurnOn() end end I tried moving "if not TheWorld.ismastersim then return inst end" after the components on the container prefab so it will be on both client and server but that gives me an error when I load the game about not being enough memory. I also tried using remote procedure calls to have the client send to server to execute the function but wasn't having much luck with that. I never messed with that before so might of been doing it wrong. the whole modmain is local require = GLOBAL.require local Vector3 = GLOBAL.Vector3 local STRINGS = GLOBAL.STRINGS local Ingredient = GLOBAL.Ingredient local RECIPETABS = GLOBAL.RECIPETABS local TECH = GLOBAL.TECH local containers = require "containers" local refinerecipe = require "refinerecipe" PrefabFiles = { "repairchest", "refinechest", } Assets = { Asset("ANIM", "anim/ui_chest_3x2.zip"), Asset("ANIM", "anim/ui_chest_3x1.zip"), Asset("ATLAS", "images/inventoryimages/refinery.xml"), Asset("IMAGE", "images/inventoryimages/refinery.tex"), } --strings STRINGS.NAMES.REPAIRCHEST = "Repair Chest" STRINGS.CHARACTERS.GENERIC.DESCRIBE.REPAIRCHEST = "It can repair all my weapons!" STRINGS.NAMES.REFINECHEST = "Refinery" --STRINGS.CHARACTERS.GENERIC.DESCRIBE.REFINECHEST = "" --recipes AddRecipe("repairchest", {Ingredient("gears", 2), Ingredient("boards", 6), Ingredient("transistor", 2), Ingredient("hammer", 1)}, RECIPETABS.TOWN, TECH.SCIENCE_TWO, "repairchest_placer", nil, nil, nil, nil, "images/inventoryimages/refinery.xml", "refinery.tex") AddRecipe("refinechest", {Ingredient("gears", 1), Ingredient("boards", 2), Ingredient("transistor", 1)}, RECIPETABS.TOWN, TECH.SCIENCE_TWO, "refinechest_placer", nil, nil, nil, nil,"images/inventoryimages/refinery.xml", "refinery.tex") --configurations TUNING.REPAIRCHESTFUEL = GetModConfigData("repairchestfuel") TUNING.REFINECHESTFUEL = GetModConfigData("refinechestfuel") --containers --repair chest local params = {} params.repairchest = { widget = { slotpos ={}, animbank = "ui_chest_3x2", animbuild = "ui_chest_3x2", pos = GLOBAL.Vector3(0, 200, 0), side_align_tip = 160, }, type = "chest", } for y = 1, 0, -1 do for x = 0, 2 do table.insert(params.repairchest.widget.slotpos, GLOBAL.Vector3(80 * x - 80 * 2 + 80, 80 * y - 80 * 2 + 120, 0)) end end function params.repairchest.itemtestfn(container, item, slot) return item.components.armor or item.components.weapon or item.prefab == "telestaff" or item.prefab == "orangestaff" or item.prefab == "opalstaff" end containers.MAXITEMSLOTS = math.max(containers.MAXITEMSLOTS, params.repairchest.widget.slotpos ~= nil and #params.repairchest.widget.slotpos or 0) --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, buttoninfo = { text = "Refine", position = Vector3(0, -100, 0), }, }, type = "chest", } function params.refinechest.itemtestfn(container, item, slot) return refinerecipe[item.prefab] and (slot == 1 or slot == 2 and container.inst.components.machine:IsOn()) end function params.refinechest.widget.buttoninfo.fn(inst, doer) if REFINECHESTFUEL then if not inst.components.fueled:IsEmpty() then inst.components.machine:TurnOn() end else inst.components.machine:TurnOn() end 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 and the mod is https://steamcommunity.com/sharedfiles/filedetails/?id=1567856396
  2. 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
  3. 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.