mirror of
https://github.com/Refactorio/RedMew.git
synced 2025-01-18 03:21:47 +02:00
fixed remove cheated items logic
This commit is contained in:
parent
a74e2e018b
commit
75c33cb83f
28
control.lua
28
control.lua
@ -202,6 +202,25 @@ end
|
||||
|
||||
global.cheated_items = {}
|
||||
global.cheated_items_by_timestamp = {}
|
||||
|
||||
local Token = require 'utils.global_token'
|
||||
local Task = require 'utils.Task'
|
||||
|
||||
local remove_token =
|
||||
Token.register(
|
||||
function(data)
|
||||
local p = data.player
|
||||
local stack = data.stack
|
||||
|
||||
local removed = p.remove_item(stack)
|
||||
|
||||
if removed > 0 then
|
||||
stack.count = removed
|
||||
p.surface.spill_item_stack(p.position, stack)
|
||||
end
|
||||
end
|
||||
)
|
||||
|
||||
Event.add(
|
||||
defines.events.on_player_crafted_item,
|
||||
function(event)
|
||||
@ -226,9 +245,12 @@ Event.add(
|
||||
local count = user_item_record.count
|
||||
local time = user_item_record['time'] or format_time(game.tick)
|
||||
data[name] = {count = stack.count + count, time = time}
|
||||
|
||||
p.remove_item(stack)
|
||||
p.surface.spill_item_stack(p.position, stack)
|
||||
|
||||
if _DEBUG then
|
||||
return
|
||||
end
|
||||
|
||||
Task.set_timeout_in_ticks(1, remove_token, {player = p, stack = stack})
|
||||
end
|
||||
)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user