mirror of
https://github.com/Refactorio/RedMew.git
synced 2025-01-30 04:30:58 +02:00
Changed rail_grid_restrictions to use Token
This commit is contained in:
parent
1ecf72a86a
commit
301c57a536
@ -2,6 +2,7 @@ local Event = require 'utils.event'
|
|||||||
local Global = require 'utils.global'
|
local Global = require 'utils.global'
|
||||||
local RestrictEntities = require 'map_gen.shared.entity_placement_restriction'
|
local RestrictEntities = require 'map_gen.shared.entity_placement_restriction'
|
||||||
local Popup = require 'features.gui.popup'
|
local Popup = require 'features.gui.popup'
|
||||||
|
local Token = require 'utils.token'
|
||||||
|
|
||||||
local floor = math.floor
|
local floor = math.floor
|
||||||
|
|
||||||
@ -37,20 +38,21 @@ local function all_on_landfill(entity)
|
|||||||
end
|
end
|
||||||
|
|
||||||
RestrictEntities.set_keep_alive_callback(
|
RestrictEntities.set_keep_alive_callback(
|
||||||
function(entity)
|
Token.register(
|
||||||
local name = entity.name
|
function(entity)
|
||||||
if name == 'entity-ghost' then
|
local name = entity.name
|
||||||
name = entity.ghost_name
|
if name == 'entity-ghost' then
|
||||||
end
|
name = entity.ghost_name
|
||||||
|
end
|
||||||
|
|
||||||
if not rail_entities[name] then
|
if not rail_entities[name] then
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
return all_on_landfill(entity)
|
return all_on_landfill(entity)
|
||||||
end
|
end
|
||||||
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
-- On first time player places rail entity on invalid tile, show popup explaining the rail mechanic.
|
-- On first time player places rail entity on invalid tile, show popup explaining the rail mechanic.
|
||||||
local function restricted_entity_destroyed(event)
|
local function restricted_entity_destroyed(event)
|
||||||
local p = event.player
|
local p = event.player
|
||||||
@ -74,10 +76,7 @@ local function player_joined_game(event)
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
player.print(
|
player.print("Welcome to RedMew's Rail Grids Map. Rails can only be built on green tiles.", {r = 0, g = 1, b = 0, a = 1})
|
||||||
"Welcome to RedMew's Rail Grids Map. Rails can only be built on green tiles.",
|
|
||||||
{r = 0, g = 1, b = 0, a = 1}
|
|
||||||
)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
Event.add(RestrictEntities.events.on_restricted_entity_destroyed, restricted_entity_destroyed)
|
Event.add(RestrictEntities.events.on_restricted_entity_destroyed, restricted_entity_destroyed)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user