Error when saving ruins of damaged objects in "Ruin maker Updated (Time fork)"
Posted: Fri Dec 20, 2024 4:02 am
This is a continuation of the topic Strange problem with the "Ruin maker" mod viewtopic.php?f=25&t=124603
After all the work done to update the Ruin maker mod and upload it to the site as a fork
"Ruin maker Updated (Time fork)" https://mods.factorio.com/mod/ruin-maker_updated_fork a new error has appeared. If there are no problems when saving ruins with intact objects, then when trying to create ruins from damaged objects, an error occurs:
It complains about this script - that the 'max_health' key is not specified there:
But it is there!!!! I don't understand what the problem is....
After all the work done to update the Ruin maker mod and upload it to the site as a fork
"Ruin maker Updated (Time fork)" https://mods.factorio.com/mod/ruin-maker_updated_fork a new error has appeared. If there are no problems when saving ruins with intact objects, then when trying to create ruins from damaged objects, an error occurs:
Code: Select all
The Ruin maker Updated (Fork) mod (0.1.4) has caused a fatal error.
Please report this error to the mod author.
Error while running event ruin-maker_updated_fork::on_gui_click (ID 1)
LuaEntityPrototype doesn't contain key max_health.
stack traceback:
[C]: in function '__index'
__ruin-maker_updated_fork__/output.lua:54: in function 'create_entity'
__ruin-maker_updated_fork__/output.lua:87: in function 'output_selection'
__ruin-maker_updated_fork__/control.lua:13: in function 'confirm_selection'
__ruin-maker_updated_fork__/control.lua:19: in function <__ruin-maker_updated_fork__/control.lua:17>
Code: Select all
30 local function create_entity(entities, center, damage, items, fluids, out)
31 if next(entities) == nil then return end
32
33 out[#out+1] = " entities =\n"
34 out[#out+1] = " {\n"
35
36 for _, entity in pairs(entities) do
37 local vec = util.vector_from_center(entity.position, center)
38
39 out[#out+1] = " {\"" .. entity.name .. "\", "
40 out[#out+1] = "{x = " .. vec.x .. ", y = " .. vec.y .. "}, "
41
42 out[#out+1] = "{" -- extra options start
43
44 local dir = entity.direction
45 if dir ~= defines.direction.north then
46 out[#out+1] = "dir = \"" .. util.direction_to_str(dir) .. "\", "
47 end
48 if entity.is_entity_with_owner then
49 if entity.force.name ~= "player" and entity.force.name ~= "neutral" then
50 out[#out+1] = "force = \"enemy\", "
51 end
52 end
53 if damage and entity.is_entity_with_health and (entity.get_health_ratio() ~= 1) then
54 local dmg = math.floor(entity.prototype.max_health - entity.health)
55 out[#out+1] = "dmg = {dmg = " .. dmg .. "}, "
56 end
57 if items and entity.has_items_inside() then
58 local inv = nil
59 if entity.type == "container" or entity.type == "logistic-container" then
60 inv = entity.get_inventory(defines.inventory.chest)
61 elseif entity.type == "ammo-turret" then
62 inv = entity.get_inventory(defines.inventory.turret_ammo)
63 end
64 if inv then
65 out[#out+1] = "items = " .. serpent.line(inv.get_contents()) .. ", "
66 end
67 end
68 if fluids and entity.get_fluid_count() > 0 then
69 out[#out+1] = "fluids = " .. serpent.line(entity.get_fluid_contents()) .. ", "
70 end
71 if entity.type == "assembling-machine" then
72 local recipe = entity.get_recipe()
73 if recipe then
74 out[#out+1] = "recipe = \"" .. recipe.name .. "\", "
75 end
76 end
77 out[#out+1] = "}},\n" -- extra options and entity end
78 end
79
80 out[#out+1] = " },\n"
81end
Code: Select all
53 if damage and entity.is_entity_with_health and (entity.get_health_ratio() ~= 1) then
54 local dmg = math.floor(entity.prototype.max_health - entity.health)
55 out[#out+1] = "dmg = {dmg = " .. dmg .. "}, "
56 end