mirror of
https://github.com/Refactorio/RedMew.git
synced 2025-03-03 14:53:01 +02:00
Change on_destroy message on danger_ores (#1322)
Before, the message was hardcoded. Now, the message is generated from the list of entities actually whitelisted, and prints the list of icons.
This commit is contained in:
parent
b5f3de51dc
commit
7764d7bc7a
@ -29,7 +29,28 @@ return function(allowed_entities, message)
|
||||
local function on_destroy(event)
|
||||
local p = event.player
|
||||
if p and p.valid then
|
||||
p.print(message or 'You cannot build that on top of ores, only belts, mining drills, and power poles are allowed.')
|
||||
if message then
|
||||
p.print(message)
|
||||
return
|
||||
end
|
||||
local items = {}
|
||||
local len = 0
|
||||
local entities = RestrictEntities.get_allowed()
|
||||
for k in pairs(entities) do
|
||||
local entity = game.entity_prototypes[k]
|
||||
for _, v in pairs(entity.items_to_place_this) do
|
||||
if not items[v.name] then --- Avoid duplication for straight-rail and curved-rail, which both use rail
|
||||
items[v.name] = v
|
||||
len = len + 1
|
||||
end
|
||||
end
|
||||
end
|
||||
local str = "You cannot build that on top of ores, only "
|
||||
local strs = {};
|
||||
for k in pairs(items) do
|
||||
table.insert(strs, "[img=item." .. k .."]")
|
||||
end
|
||||
p.print(str..table.concat(strs, " "))
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -311,6 +311,12 @@ function Public.remove_anti_grief_callback()
|
||||
primitives.anti_grief_callback = nil
|
||||
end
|
||||
|
||||
--- Get the list of allowed entities
|
||||
-- @return allowed_entities <table> array of string entity names
|
||||
function Public.get_allowed()
|
||||
return allowed_entities
|
||||
end
|
||||
|
||||
--- Adds to the list of allowed entities
|
||||
-- @param ents <table> array of string entity names
|
||||
function Public.add_allowed(ents)
|
||||
|
Loading…
x
Reference in New Issue
Block a user