mirror of
https://github.com/Refactorio/RedMew.git
synced 2024-12-12 10:04:40 +02:00
Implemented well
This commit is contained in:
parent
cba455de24
commit
dd79f655f0
@ -301,6 +301,28 @@ local function unfollow(cmd)
|
||||
end
|
||||
end
|
||||
|
||||
global.wells = {}
|
||||
local function well(cmd)
|
||||
if not game.player.admin then
|
||||
cant_run(cmd.name)
|
||||
return
|
||||
end
|
||||
|
||||
if cmd.parameter == nil then
|
||||
return
|
||||
end
|
||||
|
||||
local params = {}
|
||||
for param in string.gmatch(cmd.parameter, "%S+") do table.insert(params, param) end
|
||||
if game.item_prototypes[params[1]] and params[2] and tonumber(params[2]) then
|
||||
local ips = tonumber(params[2])
|
||||
local chest = game.surfaces[1].create_entity({name = "steel-chest", force = game.player.force, position = game.player.position})
|
||||
table.insert(global.wells, {chest = chest, item = params[1], items_per_second = ips})
|
||||
refill_well()
|
||||
else
|
||||
game.player.print("Usage: /well <item> <items per second>.")
|
||||
end
|
||||
end
|
||||
|
||||
commands.add_command("kill", "Will kill you.", kill)
|
||||
commands.add_command("detrain", "<player> - Kicks the player off a train. (Admins and moderators)", detrain)
|
||||
@ -319,3 +341,5 @@ commands.add_command("afktime", 'Shows how long players have been afk.', afk)
|
||||
commands.add_command("tag", '<player> <tag> Sets a players tag. (Admins only)', tag)
|
||||
commands.add_command("follow", '<player> makes you follow the player. Use /unfollow to stop following a player.', follow)
|
||||
commands.add_command("unfollow", 'stops following a player.', unfollow)
|
||||
commands.add_command("well", '<item> <items per second> (Admins only)', well)
|
||||
|
||||
|
10
on_tick.lua
10
on_tick.lua
@ -1,3 +1,9 @@
|
||||
function refill_well()
|
||||
for _,well in pairs(global.wells) do
|
||||
well.chest.insert({name = well.item, count = well.items_per_second * 15})
|
||||
end
|
||||
end
|
||||
|
||||
local function on_tick()
|
||||
walk_on_tick()
|
||||
if game.tick % 60 == 0 then
|
||||
@ -8,8 +14,12 @@ local function on_tick()
|
||||
end
|
||||
if game.tick % 180 == 0 then
|
||||
fish_market_on_180_ticks()
|
||||
if game.tick % 900 == 0 then
|
||||
refill_well()
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Event.register(defines.events.on_tick, on_tick)
|
||||
|
Loading…
Reference in New Issue
Block a user