-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathfu_player_init.lua
48 lines (41 loc) · 1.37 KB
/
fu_player_init.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
local origInit = init
local origUninit = uninit
function init()
origInit()
sb.logInfo("----- FU player init -----")
message.setHandler("fu_key", function(_, _, requiredItem)
if player.hasItem(requiredItem) then
return true
end
local essentialSlots = {"beamaxe", "wiretool", "painttool", "inspectiontool"}
for _,slot in pairs (essentialSlots) do
local essentialItem = player.essentialItem(slot)
if essentialItem and essentialItem.name == requiredItem then
return true
end
end
return false
end)
--[[
local goods = {"foodgoods", "medicalgoods", "electronicgoods", "militarygoods"}
for _, g in ipairs(goods) do
local amount = player.hasCountOfItem({name = g})
if amount > 0 then
player.consumeItem({name = g, count = amount})
player.addCurrency("fu"..g, amount)
sb.logInfo("converted %s '%s' into '%s' currency", amount, g, "fu"..g)
end
end
--]]
end
function uninit()
local untieredLootboxes = player.hasCountOfItem({name = "fu_lootbox", parameters = {}}, true)
if untieredLootboxes and untieredLootboxes > 0 then
local threatLevel = math.floor(world.threatLevel() + 0.5)
for i = 1, untieredLootboxes do
player.consumeItem({name = "fu_lootbox", parameters = {}}, true, true)
player.giveItem({name = "fu_lootbox", parameters = {level = threatLevel}})
end
end
origUninit()
end