Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

crash: mods: Deadlock-SE-bridge + deadlock-beltboxes-loaders + space-exploration #105

Closed
winex opened this issue Apr 12, 2024 · 2 comments · Fixed by #204
Closed

crash: mods: Deadlock-SE-bridge + deadlock-beltboxes-loaders + space-exploration #105

winex opened this issue Apr 12, 2024 · 2 comments · Fixed by #204
Assignees
Labels
bug Something isn't working lua This requires writing and/or debugging Lua

Comments

@winex
Copy link

winex commented Apr 12, 2024

  • YAFC-0.6.3-RC2 git, Factorio-1.1.107
  • mods are the latest versions to date
Log mods once: {
  ["Deadlock-SE-bridge"] = "0.6.6",
  ["aai-containers"] = "0.2.11",
  ["aai-industry"] = "0.5.22",
  ["aai-signal-transmission"] = "0.4.9",
  ["alien-biomes"] = "0.6.8",
  base = "1.1.107",
  ["deadlock-beltboxes-loaders"] = "2.4.2",
  informatron = "0.3.4",
  jetpack = "0.3.14",
  robot_attrition = "0.5.15",
  ["shield-projector"] = "0.1.6",
  simhelper = "1.1.6",
  ["space-exploration"] = "0.6.128",
  ["space-exploration-graphics"] = "0.6.17",
  ["space-exploration-graphics-2"] = "0.6.1",
  ["space-exploration-graphics-3"] = "0.6.2",
  ["space-exploration-graphics-4"] = "0.6.3",
  ["space-exploration-graphics-5"] = "0.6.1",
  ["space-exploration-menu-simulations"] = "0.6.9",
  ["space-exploration-postprocess"] = "0.6.28"
}
All mods found! Loading order: core, base, simhelper, aai-containers, aai-signal-transmission,
alien-biomes, deadlock-beltboxes-loaders, informatron, jetpack, robot_attrition, shield-projector,
space-exploration-graphics, space-exploration-graphics-2, space-exploration-graphics-3,
space-exploration-graphics-4, space-exploration-graphics-5, space-exploration-menu-simulations,
aai-industry, space-exploration, Deadlock-SE-bridge, space-exploration-postprocess
Mod settings parsed
yafc 0.6.3.0

last messages:

...
Executing Deadlock-SE-bridge/data-final-fixes.lua
Require space-exploration/data_util.lua
Require space-exploration/scripts/log.lua
Require space-exploration/shared_util.lua
Require Deadlock-SE-bridge/prototypes/deadlock.lua
Require Deadlock-SE-bridge/prototypes/colors.lua
Require deadlock-beltboxes-loaders/prototypes/shared.lua
Require deadlock-beltboxes-loaders/prototypes/create_loader.lua
Require deadlock-beltboxes-loaders/prototypes/shared.lua
Unhandled exception. YAFC.Parser.LuaException: (Deadlock-SE-bridge, prototypes/deadlock.lua):199: attempt to call field 'create_loader' (a nil value)
stack traceback:
[C]: in function 'create_loader'
(Deadlock-SE-bridge, prototypes/deadlock.lua):199: in main chunk
[C]: in function 'require'
(Deadlock-SE-bridge, data-final-fixes.lua):2: in main chunk
   at YAFC.Parser.LuaContext.Exec(ReadOnlySpan`1 chunk, String mod, String name, Int32 argument) in /home/winex/projects/factorio/yafc-ce/YAFCparser/LuaContext.cs:line 409
   at YAFC.Parser.LuaContext.Require(IntPtr lua) in /home/winex/projects/factorio/yafc-ce/YAFCparser/LuaContext.cs:line 353
Aborted (core dumped)

global variable deadlock_stacking:

$  grep -Rn --include="*.lua" -B3 -A3 -i 'deadlock_stacking' .
--
./Deadlock-SE-bridge_0.6.6/prototypes/deadlock.lua-85---Add beltbox tier
./Deadlock-SE-bridge_0.6.6/prototypes/deadlock.lua:86:if deadlock_stacking then
./Deadlock-SE-bridge_0.6.6/prototypes/deadlock.lua-87-  local DBL = require("__deadlock-beltboxes-loaders__/prototypes/shared")
./Deadlock-SE-bridge_0.6.6/prototypes/deadlock.lua-88-  require("__deadlock-beltboxes-loaders__/prototypes/create_loader")
./Deadlock-SE-bridge_0.6.6/prototypes/deadlock.lua-89-
--
./Deadlock-SE-bridge_0.6.6/prototypes/stacking.lua:94:      if deadlock_stacking and settings.startup["deadlock-enable-beltboxes"].value == true then
--
./deadlock-beltboxes-loaders_2.4.2/prototypes/public.lua-299--- tables for legacy interfaces from early 0.16 versions
./deadlock-beltboxes-loaders_2.4.2/prototypes/public.lua-300-deadlock_loaders = {}
./deadlock-beltboxes-loaders_2.4.2/prototypes/public.lua:301:deadlock_stacking = {}
--

they're internally adding to previously required tables, will this work the same way in YAFC?:

  local DBL = require("__deadlock-beltboxes-loaders__/prototypes/shared")
  require("__deadlock-beltboxes-loaders__/prototypes/create_loader")

-- but in prototypes/create_loader.lua:
function DBL.create_loader(tier_table)
    --...
end

"static" function to global DBL, while required is local - this looks weird to me...

...maybe they're totally wrong, but a crash must not happen!

@winex winex added the bug Something isn't working label Apr 12, 2024
@shihan42
Copy link
Collaborator

That is indeed a strange thing. If I find the time, I might be looking into it.
But no promises, RL is hard right now.

@DaleStan
Copy link
Collaborator

DaleStan commented May 11, 2024

The critical lines are these two in Deadlock-SE-bridge/prototypes/deadlock.lua:

	local DBL = require("__deadlock-beltboxes-loaders__/prototypes/shared")
	require("__deadlock-beltboxes-loaders__/prototypes/create_loader")

In Factorio, the second require adds a create_loader value to DBL, while in YAFC the second require does nothing.
The first line of create_loader.lua is local DBL = require("prototypes.shared"), and shared.lua starts with local DBL = {} and ends with return DBL.

My theory is that YAFC sees the local declaration twice and creates two different tables, while Factorio creates only one table.

If I make these two changes, the mods load in both YAFC and Factorio:
diff --git a/Deadlock-SE-bridge_0.6.6/prototypes/deadlock.lua b/Deadlock-SE-bridge_0.6.6/prototypes/deadlock.lua
index 0fe598b..100ffa7 100644
--- a/Deadlock-SE-bridge_0.6.6/prototypes/deadlock.lua
+++ b/Deadlock-SE-bridge_0.6.6/prototypes/deadlock.lua
@@ -84,8 +84,7 @@
 --BELTBOX
 --Add beltbox tier
 if deadlock_stacking then
-       local DBL = require("__deadlock-beltboxes-loaders__/prototypes/shared")
-       require("__deadlock-beltboxes-loaders__/prototypes/create_loader")
+       local DBL = require("__deadlock-beltboxes-loaders__/prototypes/create_loader")

        remove_tech_pack ( data.raw.technology["deadlock-stacking-3"], { "production-science-pack" } )

diff --git a/deadlock-beltboxes-loaders_2.4.2/prototypes/create_loader.lua b/deadlock-beltboxes-loaders_2.4.2/prototypes/create_loader.lua
index 08bd05d..e771123 100644
--- a/deadlock-beltboxes-loaders_2.4.2/prototypes/create_loader.lua
+++ b/deadlock-beltboxes-loaders_2.4.2/prototypes/create_loader.lua
@@ -277,3 +277,5 @@
                )
        end
 end
+
+return DBL

I don't know where to go from here, but hopefully someone else will be able to take this further.

@DaleStan DaleStan added the lua This requires writing and/or debugging Lua label Jun 28, 2024
@DaleStan DaleStan self-assigned this Jul 23, 2024
shpaass added a commit that referenced this issue Jul 23, 2024
…decoding. (#202)

Lua uses UTF8 strings, not Ansi. This usually doesn't matter, except
that Schall Alien Loot has setting values containing the character `×`
(U+00D7), and this gets garbled when loaded from mod-settings.dat.

In addition to Schall, I checked loading with AngelBobMadClown,
ExoticIndustries, IR3, Nullius, Pyanodon, and SE. The only error I
encountered was #105.
shpaass added a commit that referenced this issue Jul 23, 2024
…ing nil. (#204)

This matches Factorio's behavior, and fixes both #105 and #145.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working lua This requires writing and/or debugging Lua
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants