mirror of
https://github.com/Refactorio/RedMew.git
synced 2025-01-26 03:52:00 +02:00
changes to tpmode
This commit is contained in:
parent
73830b124b
commit
9f49802aeb
@ -329,13 +329,13 @@ local function well(cmd)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
tp_players = {}
|
global.tp_players = {}
|
||||||
tp_players_count = 0
|
--global.tp_players_count = 0
|
||||||
|
|
||||||
local function built_entity(event)
|
local function built_entity(event)
|
||||||
local index = event.player_index
|
local index = event.player_index
|
||||||
|
|
||||||
if tp_players[index] then
|
if global.tp_players[index] then
|
||||||
local entity = event.created_entity
|
local entity = event.created_entity
|
||||||
|
|
||||||
if entity.type ~= "entity-ghost" then return end
|
if entity.type ~= "entity-ghost" then return end
|
||||||
@ -345,6 +345,8 @@ local function built_entity(event)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Event.register(defines.events.on_built_entity, built_entity )
|
||||||
|
|
||||||
local function toggle_tp_mode()
|
local function toggle_tp_mode()
|
||||||
if not (game.player.admin or is_mod(game.player.name)) then
|
if not (game.player.admin or is_mod(game.player.name)) then
|
||||||
cant_run(cmd.name)
|
cant_run(cmd.name)
|
||||||
@ -352,27 +354,32 @@ local function toggle_tp_mode()
|
|||||||
end
|
end
|
||||||
|
|
||||||
local index = game.player.index
|
local index = game.player.index
|
||||||
local toggled = tp_players[index]
|
local toggled = global.tp_players[index]
|
||||||
|
|
||||||
if toggled then
|
if toggled then
|
||||||
tp_players[index] = nil
|
global.tp_players[index] = nil
|
||||||
tp_players_count = tp_players_count - 1
|
|
||||||
|
--[[
|
||||||
|
global.tp_players_count = global.tp_players_count - 1
|
||||||
|
|
||||||
-- remove event handler if no players are using it.
|
-- remove event handler if no players are using it.
|
||||||
if tp_players_count == 0 then
|
if global.tp_players_count == 0 then
|
||||||
Event.remove(defines.events.on_built_entity, built_entity )
|
Event.remove(defines.events.on_built_entity, built_entity )
|
||||||
end
|
end
|
||||||
|
--]]
|
||||||
|
|
||||||
game.player.print("tp mode is now off")
|
game.player.print("tp mode is now off")
|
||||||
|
|
||||||
else
|
else
|
||||||
tp_players[index] = true
|
global.tp_players[index] = true
|
||||||
tp_players_count = tp_players_count + 1
|
--[[
|
||||||
|
global.tp_players_count = global.tp_players_count + 1
|
||||||
|
|
||||||
-- add event handler now that a player is using it.
|
-- add event handler now that a player is using it.
|
||||||
if tp_players_count == 1 then
|
if global.tp_players_count == 1 then
|
||||||
Event.register(defines.events.on_built_entity, built_entity )
|
Event.register(defines.events.on_built_entity, built_entity )
|
||||||
end
|
end
|
||||||
|
--]]
|
||||||
|
|
||||||
game.player.print("tp mode is now on - place a ghost entity to teleport there.")
|
game.player.print("tp mode is now on - place a ghost entity to teleport there.")
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user