forked from jakimfett/autofill
-
Notifications
You must be signed in to change notification settings - Fork 7
/
commands.lua
39 lines (33 loc) · 1.38 KB
/
commands.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
local commands = {}
commands.help = "Autofill Help"
local function priority(global, player, set, params)
local stack = player.cursor_stack
local name = stack.name
local category = stack.type == "ammo" and stack.prototype.get_ammo_type().category
if category and MOD.sets.set_ammo_priority(set, category, name, tonumber(params[3]) or 1) then
local msg = {"", "Priority for ", {"item-name." .. name}, " is set to ", set["ammo"][category][name]}
return global and game.print(msg) or player.print(msg)
end
end
function commands.command(event)
local player = game.players[event.player_index]
local pdata = global.players[event.player_index]
local params = event.parameter and event.parameter:split(" ") or {}
if params[1]:lower() == "priority" then
if player.cursor_stack.valid_for_read then
if params[2]:lower() == "global" and player.admin then
priority(true, player, global.sets.item_sets, params)
elseif params[2]:lower() == "player" then
priority(true, player, pdata.sets.item_sets, params)
end
else
player.print({"", "Must be holding an item in your hand to change priority"})
end
end
end
function commands.dump()
MOD.interface.write_global()
MOD.interface.write_default_sets()
MOD.interface.write_MOD_global()
end
return commands