Untitled
unknown
lua
a year ago
2.3 kB
23
Indexable
local function platform_recipe_condition_satisfied(entities, surface_prop, prop_name)
for i = 1, #entities do
local entity = entities[i];
local recipe = entity.get_recipe();
if (entities_disabled[entity.unit_number] == nil) then
entities_disabled[entity.unit_number] = {["disabled"] = false};
end
if (recipe ~= nil) then
recipe = recipe.prototype;
if (cached_recipes[recipe.name] == nil and recipe.surface_conditions ~= nil) then
cached_recipes[recipe.name] = {surface_conditions = {}};
for j = 1, #recipe.surface_conditions do
local condition = recipe.surface_conditions[j];
cached_recipes[recipe.name].surface_conditions[condition.property] = {min = condition.min, max = condition.max};
end
end
local cached_recipe = cached_recipes[recipe.name];
if (cached_recipe == nil or cached_recipe.surface_conditions == nil or next(cached_recipe.surface_conditions) == nil) then
if (entities_disabled[entity.unit_number].disabled == true) then
entities_disabled[entity.unit_number].disabled = false;
remote.call("collisionless-disable-by-script", "entity_remove_disable", entity, "platform-script");
end
goto continue;
end
local condition = cached_recipe.surface_conditions[prop_name];
if (condition == nil) then
goto continue;
end
if (condition.min > surface_prop or condition.max < surface_prop) then
entities_disabled[entity.unit_number].disabled = true;
remote.call("collisionless-disable-by-script", "entity_add_disable", entity, surface_condition_status, "platform-script");
elseif (entities_disabled[entity.unit_number].disabled == true) then
entities_disabled[entity.unit_number].disabled = false;
remote.call("collisionless-disable-by-script", "entity_remove_disable", entity, "platform-script");
end
end
::continue::
end
endEditor is loading...
Leave a Comment