Petrichor-PSTVL/code/systems/inventory.lua
2025-04-21 04:11:21 +08:00

229 lines
7.8 KiB
Lua
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

local ____lualib = require("lualib_bundle")
local __TS__AsyncAwaiter = ____lualib.__TS__AsyncAwaiter
local __TS__Await = ____lualib.__TS__Await
local __TS__ArrayIncludes = ____lualib.__TS__ArrayIncludes
local __TS__ArrayIndexOf = ____lualib.__TS__ArrayIndexOf
local __TS__ArraySplice = ____lualib.__TS__ArraySplice
local ____exports = {}
local ____global = require("code.global")
local accessor = ____global.accessor
local function textGen()
return {
item_bucket = {
name = "Pail",
info = function()
return {
"<p:player>(A pail. Good for collecting things.)",
unpack(accessor.event_home_bucket and ({
"<p:player><f:sigh>(Apart from rainwater, apparently.)"
}) or ({}))
}
end
},
item_card = {
name = "Library Card",
info = {
"<p:player>(A library card with a blued, jeweled strip.)"
}
},
item_drill = {
name = "一把电钻",
info = function()
return ({ {
"<p:player>(一把电钻,满电。)"
}, {
"<p:player>(一把电钻,还剩一半电量。)"
}, {
"<p:player>(一把电钻,没电了。)"
} })
[math.max((accessor.item_crowbar and 1 or 0) + (accessor.state_redleaf_gate == 1 and 1 or 0), 0) + 1]
end
},
item_goatplush = {
name = "一个毛绒玩偶",
info1a = {
"<p:player>(带上一个作伴也没什么害处。)"
},
info1b = {
"戴上它",
"什么都不做"
},
info1c = {
"<p:player><f:sigh>(走你。)"
},
info2a = {
"<p:player><f:wink>(A worn plushie.)"
},
info2b = {
"拿下来",
"算了"
},
info2c = {
"<p:player><f:sigh>(我先把它拿下来好了。)"
}
},
item_rope = {
name = "一段绳子",
info = function()
return accessor.plot < 2 and ({
"<p:player>(一截老麻绳,快用完了。)"
}) or
(accessor.plot < 3 and ({ "<p:player><f:side>(再长点就好了...", accessor.item_cover and "<p:player><f:sweat4>...那样我就不用\n把床单剪了编绳子了。)" or "<p:player>...看看有没有什么\n能拿来编绳子的吧。)" }) or ({
"<p:player>(一截老麻绳,快用完了。)",
"<p:player><f:determined>(肯定比不上我编的那根啦。)"
}))
end
},
item_scissors = {
name = "一把剪刀",
info = {
"<p:player>一把普通的料理剪。"
}
}
}
end
local function inventory(game, ____bindingPattern0)
local player
player = ____bindingPattern0.player
local text
local inventory = {}
local items = {
{
name = function(self)
return text.item_goatplush.name
end,
priority = 0,
script = function(self, reader)
return __TS__AsyncAwaiter(function(____awaiter_resolve)
if accessor.floof then
__TS__Await(reader:text(text.item_goatplush.info2a))
__TS__Await(reader:choice(text.item_goatplush.info2b))
if game.r_choice == 0 then
__TS__Await(reader:text(text.item_goatplush.info2c))
accessor.floof = false
player.metadata.floof = false
end
else
__TS__Await(reader:text(text.item_goatplush.info1a))
__TS__Await(reader:choice(text.item_goatplush.info1b))
if game.r_choice == 0 then
__TS__Await(reader:text(text.item_goatplush.info1c))
accessor.floof = true
player.metadata.floof = true
end
end
end)
end,
show = function(self)
return accessor.item_goatplush
end
},
{
name = function(self)
return text.item_scissors.name
end,
priority = 1,
script = function(self, reader)
return __TS__AsyncAwaiter(function(____awaiter_resolve)
__TS__Await(reader:text(text.item_scissors.info))
end)
end,
show = function(self)
return accessor.item_scissors
end
},
{
name = function(self)
return text.item_drill.name
end,
priority = 2,
script = function(self, reader)
return __TS__AsyncAwaiter(function(____awaiter_resolve)
local ____opt_0 = game.script
if __TS__Await(____opt_0 and ____opt_0("drillie")) == true then
return ____awaiter_resolve(nil)
end
__TS__Await(reader:text(text.item_drill.info()))
end)
end,
show = function(self)
return accessor.item_drill
end
},
{
name = function(self)
return text.item_rope.name
end,
priority = 3,
script = function(self, reader)
return __TS__AsyncAwaiter(function(____awaiter_resolve)
local ____opt_2 = game.script
if __TS__Await(____opt_2 and ____opt_2("roper")) == true then
return ____awaiter_resolve(nil)
end
reader:text(text.item_rope.info())
end)
end,
show = function(self)
return accessor.item_rope
end
},
{
name = function(self)
return text.item_bucket.name
end,
priority = 4,
script = function(self, reader)
return __TS__AsyncAwaiter(function(____awaiter_resolve)
local ____opt_4 = game.script
if __TS__Await(____opt_4 and ____opt_4("buckey")) == true then
return ____awaiter_resolve(nil)
end
reader:text(text.item_bucket.info())
end)
end,
show = function(self)
return accessor.item_bucket
end
},
{
name = function(self)
return text.item_card.name
end,
priority = 1000,
script = function(self, reader)
return __TS__AsyncAwaiter(function(____awaiter_resolve)
__TS__Await(reader:text(text.item_card.info))
end)
end,
show = function(self)
return accessor.event_home_bookshelf == 2
end
}
}
text = textGen()
local function update()
local id = 0
while id ~= #items do
if items[id + 1]:show() then
if #inventory == 0 or not __TS__ArrayIncludes(inventory, id) then
inventory[#inventory + 1] = id
end
else
local index = __TS__ArrayIndexOf(inventory, id)
if #inventory ~= 0 and index ~= -1 then
__TS__ArraySplice(inventory, index, 1)
end
end
id = id + 1
end
table.sort(
inventory,
function(a, b) return items[a + 1].priority < items[b + 1].priority end
)
end
return { inventory = inventory, items = items, text = text, update = update }
end
____exports.default = inventory
return ____exports