Conversation
|
Related to #8 |
| @@ -1,4 +1,4 @@ | |||
| local util = require("util") | |||
| local util = table.deepcopy ( require("util") ) | |||
There was a problem hiding this comment.
I admit I am not very good with lua nor factorio modding, but does this not make a deepcopy only for the local variable? Or does this actually carry over to the, let's say, script/construction_drone.lua file?
There was a problem hiding this comment.
The way tables work in Lua is that every variable with a table in it doesn't actually contain the table, it's merely a portal to the table. So every change made to it will apply to the original table, and every OTHER local variable that points at the same table as it will be able to see it. This is why you can do local belt = data.raw["transport-belt"]["express-transport-belt"]; belt.speed = 60, and it would apply to the original object held in the data table.
In the example you provide with scripts/construction_drone.lua, it never actually did see the modified tf_util table, even before I touched anything, since tf_util is executed during the DATA stage, which the script file is used during the CONTROL stage. No data beyond what factorio takes from the data table is transferred over.
The util in that file is defined in control.lua line 3.
|
I built these changes locally, but received errors when I ran other Klanon "based" mods. Running Hive_Mind_MitchPlay This is the error I receive on startup with Hive_Mind. I came back through this code base to change all "util" calls to local with deep_copy. Still receive the error on with Hive_mind, seems like there might be a deeper problem with Klanon "based" mods. |

No description provided.