diff --git a/data/anim/pocketwatchbox.zip b/data/anim/pocketwatchbox.zip new file mode 100644 index 0000000..c03e1e4 Binary files /dev/null and b/data/anim/pocketwatchbox.zip differ diff --git a/data/anim/pocketwatchpack.zip b/data/anim/pocketwatchpack.zip new file mode 100644 index 0000000..b33b1fb Binary files /dev/null and b/data/anim/pocketwatchpack.zip differ diff --git a/data/images/inventoryimages/pocketwatchbox.tex b/data/images/inventoryimages/pocketwatchbox.tex new file mode 100644 index 0000000..65ef2f0 Binary files /dev/null and b/data/images/inventoryimages/pocketwatchbox.tex differ diff --git a/data/images/inventoryimages/pocketwatchbox.xml b/data/images/inventoryimages/pocketwatchbox.xml new file mode 100644 index 0000000..946ae26 --- /dev/null +++ b/data/images/inventoryimages/pocketwatchbox.xml @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/data/images/inventoryimages/pocketwatchpack.tex b/data/images/inventoryimages/pocketwatchpack.tex new file mode 100644 index 0000000..93b88e3 Binary files /dev/null and b/data/images/inventoryimages/pocketwatchpack.tex differ diff --git a/data/images/inventoryimages/pocketwatchpack.xml b/data/images/inventoryimages/pocketwatchpack.xml new file mode 100644 index 0000000..893e776 --- /dev/null +++ b/data/images/inventoryimages/pocketwatchpack.xml @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/data/images/modicon_pocketwatchpack.tex b/data/images/modicon_pocketwatchpack.tex new file mode 100644 index 0000000..15f226d Binary files /dev/null and b/data/images/modicon_pocketwatchpack.tex differ diff --git a/data/images/modicon_pocketwatchpack.xml b/data/images/modicon_pocketwatchpack.xml new file mode 100644 index 0000000..682f3ff --- /dev/null +++ b/data/images/modicon_pocketwatchpack.xml @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/data/modinfo.lua b/data/modinfo.lua new file mode 100644 index 0000000..8b5007c --- /dev/null +++ b/data/modinfo.lua @@ -0,0 +1,38 @@ +name = "Wanda's pocket watch bag (advanced)" +description = "An advanced version of Wanda's pocket watch bag" +author = "非自然对数㏑x & Mestima" +version = "1.0.0" + +forumthread = "" + +api_version = 6 +api_version_dst = 10 + +dst_compatible = true + +dont_starve_compatible = false +reign_of_giants_compatible = false +shipwrecked_compatible = false + +all_clients_require_mod = true + +icon_atlas = "images/modicon_pocketwatchpack.xml" +icon = "modicon_pocketwatchpack.tex" + +priority = 0 + +server_filter_tags = {"Wanda's bag"} + +configuration_options = { + { + name = "lang", + label = "Language", + hover = "Choose a language", + options = { + { description = "English", data = "eng" }, + { description = "Русский", data = "ru" }, + { description = "中文", data = "chi" }, + }, + default = "eng" + } +} diff --git a/data/modmain.lua b/data/modmain.lua new file mode 100644 index 0000000..2f5a8a2 --- /dev/null +++ b/data/modmain.lua @@ -0,0 +1,56 @@ +GLOBAL.setmetatable(env,{__index=function(t,k) return GLOBAL.rawget(GLOBAL,k) end}) + +local function GetConfig(name, default) + local opt = GetModConfigData(name) + if (not opt) then + opt = default + end + if (type(opt) == "table") then + opt = opt.option_data + end + return opt +end + +local lang = { + eng = { + name = "Watch bag", + desc = "A bag for your watch!", + insp = "It contains the power of shadows..." + }, + ru = { + name = "Сумка с часами", + desc = "Сумка для всех Ваших часов!", + insp = "В ней сила теней..." + }, + chi = { + name = "怀表工具袋", + desc = "收纳时间", + insp = "蕴含暗影的力量" + } +} + +local language = GetConfig("lang", "eng") + +PrefabFiles = { "pocketwatchpack" } +Assets = { + Asset("ATLAS", "images/inventoryimages/pocketwatchpack.xml") +} + +modimport("scripts/main/lnx_container.lua") +AddRecipe("pocketwatchpack", + { + Ingredient("pocketwatch_dismantler", 1), + Ingredient("livinglog", 2), + Ingredient("nightmarefuel", 2) + }, + CUSTOM_RECIPETABS.CLOCKMAKER, + TECH.NONE, + nil, nil, nil, nil, + "clockmaker", + "images/inventoryimages/pocketwatchpack.xml", + "pocketwatchpack.tex" +) + +STRINGS.NAMES.POCKETWATCHPACK = lang[language].name +STRINGS.RECIPE_DESC.POCKETWATCHPACK = lang[language].desc +STRINGS.CHARACTERS.GENERIC.DESCRIBE.POCKETWATCHPACK = lang[language].insp diff --git a/data/scripts/main/lnx_container.lua b/data/scripts/main/lnx_container.lua new file mode 100644 index 0000000..bdafd27 --- /dev/null +++ b/data/scripts/main/lnx_container.lua @@ -0,0 +1,45 @@ +local containers = require("containers") + +local params = { + pocketwatchpack = { + widget = { + slotpos = {}, + animbank = "ui_piggyback_2x6", + animbuild = "ui_piggyback_2x6", + pos = Vector3(-5, -50, 0) + }, + issidewidget = true, + openlimit = 1, + type = "pack" + } +} + +for y = 0, 5 do + table.insert(params.pocketwatchpack.widget.slotpos, Vector3(-162, -75 * y + 170, 0)) + table.insert(params.pocketwatchpack.widget.slotpos, Vector3(-162 + 75, -75 * y + 170, 0)) +end + + +function params.pocketwatchpack.itemtestfn(container, item, slot) + return (item:HasTag("pocketwatch") or (item.prefab == "pocketwatch_parts" or item.prefab == "pocketwatch_dismantler")) +end + + +for k, v in pairs(params) do + containers.MAXITEMSLOTS = math.max(containers.MAXITEMSLOTS, v.widget.slotpos and #v.widget.slotpos or 0) +end + + +local containers_widgetsetup = containers.widgetsetup + +function containers.widgetsetup(container, prefab, data) + local t = data or 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 + return containers_widgetsetup(container, prefab, data) + end +end diff --git a/data/scripts/prefabs/pocketwatchpack.lua b/data/scripts/prefabs/pocketwatchpack.lua new file mode 100644 index 0000000..762df60 --- /dev/null +++ b/data/scripts/prefabs/pocketwatchpack.lua @@ -0,0 +1,69 @@ +local assets = { + Asset("ANIM", "anim/pocketwatchpack.zip"), + Asset("ATLAS", "images/inventoryimages/pocketwatchpack.xml") +} + +local prefabs = {} + + +local function onopen(inst) +end + +local function onclose(inst) + local owner = inst.components.inventoryitem.owner + if owner then + local container = owner.components.inventory:GetOverflowContainer() + if container then + container:Open(owner) + end + end +end + + +local function ondropped(inst) + if inst.components.container then + inst.components.container:Close() + end +end +local function fn() + local inst = CreateEntity() + inst.entity:AddTransform() + inst.entity:AddAnimState() + inst.entity:AddSoundEmitter() + inst.entity:AddNetwork() + + MakeInventoryPhysics(inst) + + inst.AnimState:SetBank("pocketwatchpack") + inst.AnimState:SetBuild("pocketwatchpack") + inst.AnimState:PlayAnimation("idle") + + MakeInventoryFloatable(inst) + + inst.entity:SetPristine() + + if not TheWorld.ismastersim then + return inst + end + + inst:AddComponent("inspectable") + + inst:AddComponent("inventoryitem") + inst.components.inventoryitem.imagename = "pocketwatchpack" + inst.components.inventoryitem.atlasname = "images/inventoryimages/pocketwatchpack.xml" + inst.components.inventoryitem.canonlygoinpocket = true -- can't store a pocket watch bag into a backpack etc + inst.components.inventoryitem.keepondeath = true + inst.components.inventoryitem.keepondrown = true + inst.components.inventoryitem:SetOnDroppedFn(ondropped) + + inst:AddComponent("container") + inst.components.container:WidgetSetup("pocketwatchpack") + --inst.components.container.onopenfn = onopen + inst.components.container.onclosefn = onclose + + MakeHauntableLaunchAndDropFirstItem(inst) + + return inst +end + +return Prefab("pocketwatchpack", fn, assets, prefabs) \ No newline at end of file diff --git a/icon.png b/icon.png new file mode 100644 index 0000000..85170a7 Binary files /dev/null and b/icon.png differ