BakaSchwarz

Registered Users
  • Content count

    12
  • Joined

  • Last visited

Community Reputation

2 Neutral

About BakaSchwarz

  • Rank
    Junior Member

Recent Profile Visitors

531 profile views
  1. Refresh container after item drop

    inst is the item to which this code belongs. A void gem. It checks if it is placed inside a container and then tells the container in which it was placed to drop it. owner is the container in which the gem was placed. It is also strange that the code seems to work just fine for guests, but not the host of a server.
  2. Refresh container after item drop

    Of course. The following contains the code in which the function is called. I cut out some really unnecessary stuff: require "prefabutil" local assets = { Asset("ANIM", "anim/voidgem_build.zip"), Asset("ATLAS", "images/inventoryimages/voidgem_normal.xml"), Asset("IMAGE", "images/inventoryimages/voidgem_normal.tex"), Asset("ATLAS", "images/inventoryimages/voidgem_refined.xml"), Asset("IMAGE", "images/inventoryimages/voidgem_refined.tex"), Asset("ATLAS", "images/inventoryimages/voidgem_purified.xml"), Asset("IMAGE", "images/inventoryimages/voidgem_purified.tex"), } local function buildvoidgem(version) local current_owner = nil local range_indicator = nil local PLACER_SCALE = 1 local function CheckVoidAmount(inst) local amount = 0 return amount end local function TryInsert(inst, item) end local function IsEntityACandidate(owner, candidate) return false end local function RangeIndicator(inst, active) end local function fn() local inst = CreateEntity() inst.entity:AddTransform() inst.entity:AddAnimState() inst.entity:AddNetwork() MakeInventoryPhysics(inst) inst.AnimState:SetBank("voidgem") inst.AnimState:SetBuild("voidgem_build") if version == "normal" then inst.AnimState:PlayAnimation("idle_normal", true) elseif version == "refined" then inst.AnimState:PlayAnimation("idle_refined", true) elseif version == "purified" then inst.AnimState:PlayAnimation("idle_purified", true) end inst:AddTag("molebait") inst:AddTag("voidresist") inst.entity:SetPristine() RangeIndicator(inst, true) if not TheWorld.ismastersim then return inst end inst:AddComponent("inventoryitem") if version == "normal" then inst.components.inventoryitem.atlasname = "images/inventoryimages/voidgem_normal.xml" elseif version == "refined" then inst.components.inventoryitem.atlasname = "images/inventoryimages/voidgem_refined.xml" inst:AddComponent("container") inst.components.container:WidgetSetup("voidgem_refined") inst.components.container.onopenfn = function () inst.components.inventoryitem.cangoincontainer = false end inst.components.container.onclosefn = function() inst.components.inventoryitem.cangoincontainer = true end elseif version == "purified" then inst.components.inventoryitem.atlasname = "images/inventoryimages/voidgem_purified.xml" inst:AddComponent("container") inst.components.container:WidgetSetup("voidgem_purified") inst.components.container.onopenfn = function () inst.components.inventoryitem.cangoincontainer = false end inst.components.container.onclosefn = function() inst.components.inventoryitem.cangoincontainer = true end end inst.components.inventoryitem:SetOnPutInInventoryFn(function(_, owner) if not owner:HasTag("voidresist") then RangeIndicator(current_owner, false) RangeIndicator(owner, true) current_owner = owner else owner.components.container:DropItem(inst) -- HERE!!! end end) inst.components.inventoryitem:SetOnDroppedFn(function(_, owner) RangeIndicator(current_owner, false) current_owner = nil end) inst:AddComponent("tradable") inst:AddComponent("inspectable") MakeHauntableLaunchAndSmash(inst) return inst end return Prefab("voidgem_"..version, fn, assets) end return buildvoidgem("normal"), buildvoidgem("refined"), buildvoidgem("purified") The widget setup gets overriden in the modmain.lua, where i define my own container: local RECIPETABS = GLOBAL.RECIPETABS local Vector3 = GLOBAL.Vector3 local TECH = GLOBAL.TECH local require = GLOBAL.require containers = require "containers" Assets = { Asset("ATLAS", "images/inventoryimages/voidgem_normal.xml"), Asset("IMAGE", "images/inventoryimages/voidgem_normal.tex"), Asset("ATLAS", "images/inventoryimages/voidgem_refined.xml"), Asset("IMAGE", "images/inventoryimages/voidgem_refined.tex"), Asset("ATLAS", "images/inventoryimages/voidgem_purified.xml"), Asset("IMAGE", "images/inventoryimages/voidgem_purified.tex"), Asset("ANIM", "anim/ui_chest_3x3.zip"), } PrefabFiles = { "voidgem", } -- Container -- local params = {} local old_widgetsetup = containers.widgetsetup function containers.widgetsetup(container, prefab, ...) 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 old_widgetsetup(container, prefab, ...) end end local function makeVoidGem() container = { widget = { slotpos = {}, animbank = "ui_chest_3x3", animbuild = "ui_chest_3x3", pos = Vector3(0, 200, 0), side_align_tip = 160, }, acceptsstacks = false, type = "chest", } for y = 2, 0, -1 do for x = 0, 2 do table.insert(container.widget.slotpos, Vector3(80 * x - 80 * 2 + 80, 80 * y - 80 * 2 + 80, 0)) end end return container end params.voidgem_refined = makeVoidGem() params.voidgem_purified = makeVoidGem() for k, v in pairs(params) do containers.MAXITEMSLOTS = math.max(containers.MAXITEMSLOTS, v.widget.slotpos ~= nil and #v.widget.slotpos or 0) end AddRecipe("voidgem_normal", {Ingredient("purplegem", 1), Ingredient("nightmarefuel", 2)}, RECIPETABS.MAGIC, TECH.SCIENCE_ONE, nil, nil, nil, nil, nil, "images/inventoryimages/voidgem_normal.xml") AddRecipe("voidgem_refined", {Ingredient("voidgem_normal", 1, "images/inventoryimages/voidgem_normal.xml", "voidgem_normal.tex"), Ingredient("goldnugget", 20)}, RECIPETABS.MAGIC, TECH.SCIENCE_ONE, nil, nil, nil, nil, nil, "images/inventoryimages/voidgem_refined.xml") AddRecipe("voidgem_purified", {Ingredient("voidgem_normal", 1, "images/inventoryimages/voidgem_normal.xml", "voidgem_normal.tex"), Ingredient("opalpreciousgem", 1)}, RECIPETABS.MAGIC, TECH.SCIENCE_ONE, nil, nil, nil, nil, nil, "images/inventoryimages/voidgem_purified.xml")
  3. Hey, i have the following code: owner.components.container:DropItem(inst) owner is lets say a chest. When i use DropItem, it drops the item as expected, but the chest interface is not updated and the item image remains. How can i refresh it without closing the inferface?
  4. That helped! Thanks a lot!
  5. I am implementing 3 items. One of them is part of the crafting recipe of the other two. My problem is that the image of this one item does not show inside the recipe (see attached image). I set the graphics inside the modmain.lua of my mod: local RECIPETABS = GLOBAL.RECIPETABS local TECH = GLOBAL.TECH local require = GLOBAL.require Assets = { Asset("ATLAS", "images/inventoryimages/voidgem_normal.xml"), Asset("IMAGE", "images/inventoryimages/voidgem_normal.tex"), Asset("ATLAS", "images/inventoryimages/voidgem_refined.xml"), Asset("IMAGE", "images/inventoryimages/voidgem_refined.tex"), Asset("ATLAS", "images/inventoryimages/voidgem_purified.xml"), Asset("IMAGE", "images/inventoryimages/voidgem_purified.tex"), } PrefabFiles = { "voidgem", } AddRecipe("voidgem_normal", {Ingredient("purplegem", 1), Ingredient("nightmarefuel", 2)}, RECIPETABS.MAGIC, TECH.SCIENCE_ONE, nil, nil, nil, nil, nil, "images/inventoryimages/voidgem_normal.xml") AddRecipe("voidgem_refined", {Ingredient("voidgem_normal", 1), Ingredient("goldnugget", 20)}, RECIPETABS.MAGIC, TECH.SCIENCE_ONE, nil, nil, nil, nil, nil, "images/inventoryimages/voidgem_refined.xml") AddRecipe("voidgem_purified", {Ingredient("voidgem_normal", 1), Ingredient("opalpreciousgem", 1)}, RECIPETABS.MAGIC, TECH.SCIENCE_ONE, nil, nil, nil, nil, nil, "images/inventoryimages/voidgem_purified.xml") When looking at the DST Log, i get the following output after hovering over the recipe: [00:10:26]: WARNING! Could not find region 'FROMNUM' from atlas 'images/inventoryimages.xml'. Is the region specified in the atlas? [00:10:26]: Looking for default texture '' from atlas 'images/inventoryimages.xml'. [00:10:26]: Error Looking for default texture in from atlas 'images/inventoryimages.xml'. [00:10:26]: WARNING! Could not find region 'FROMNUM' from atlas 'images/inventoryimages.xml'. Is the region specified in the atlas? [00:10:26]: Looking for default texture '' from atlas 'images/inventoryimages.xml'. [00:10:26]: Error Looking for default texture in from atlas 'images/inventoryimages.xml'. [00:10:27]: WARNING! Could not find region 'FROMNUM' from atlas 'images/inventoryimages.xml'. Is the region specified in the atlas? [00:10:27]: Looking for default texture '' from atlas 'images/inventoryimages.xml'. [00:10:27]: Error Looking for default texture in from atlas 'images/inventoryimages.xml'. What am i doing wrong? I created the xml and tex files from a normal png using TexCreator with default settings. Help is greatly appreciated since this mod is otherwise done... thanks in advance!
  6. Version 2.0.4

    5,995 downloads

    [steam Workshop] http://steamcommunity.com/sharedfiles/filedetails/?id=531158479 [Descripton] Glace was born with a cold heart. His whole body is emitting an aura that slowly freezes everything around him. But his cold heart does not mean he has a cold heart (pun intended). In fact, he really likes to be among friends, but often, he gets rejected with his aura being the cause. [stats] Health: 100 Hunger: 65 Sanity: 220 [Perks] --Has a cold heart-- His body is like a fridge. Items in his inventory get cooled like in an icebox. He furthermore emits an aura which cools everything around him down. Butterflies really don't like this because they freeze when they get too close to him. He himself does not overheat, which is fine in summer, but... --Hates winter-- He really really hates it. It's his least favorite time of the year. His body temperature will not rise beyond a certain point, so the thermic stone and campfires can only do so much and long travel will be certain death, because the cold hurts him really bad. He takes 2.5 times the damage and temperature changes double in speed for him. So prepare yourself. --Has a strong mind-- Living alone most of the time helped him develope an immunity against the sickness called solitude. But he really hates dark places. When it gets dark, his strong mind means nothing! His sanity will drain 2.5 times as fast in those situations. If you don't do something you easily loose ~50 sanity per night. To counter this fear, he has only one solution... --Likes to be among friends-- Despite his cold heart, he really is most comfortable among his friends. Even the night will mean nothing if he can feel the warmth of another persons heart. This feeling will quickly heal his mental scars. --Does not eat much-- His metabolism is different from most species. This brings forth the problem that he often collects too much food which will later perish all at once or he forgets it entirely. This can be deadly during winter. --Is a fast runner-- Glace is not much more than a twig when it comes to his weight. And if that was not enough, the ground freezes around him before he comes into contact with it. You could say that he slides through his life. He is 42 % faster than Wilson. [From the author] I tried to make it not too unbalanced, but not to the point where this character wouldn't be fun to play with. I used the Extended Character Template from Dleowolf for which i am quite grateful. If you find any misspelling or weird wording please let me know. English is not my first language but i try to improve whenever i can. And finally: Have fun playing!