Error updating mod for Factorio 2.0 (continued 2)

Place to get help with not working mods / modding interface.
Keysivi
Fast Inserter
Fast Inserter
Posts: 110
Joined: Mon Feb 07, 2022 5:29 pm
Contact:

Error updating mod for Factorio 2.0 (continued 2)

Post by Keysivi »

This is a continuation of the topic Error updating mod for Factorio 2.0 (continued) viewtopic.php?f=25&t=124422

I posted the updated mod "The Ruins Mod" as a fork The Ruins Mod Updated (Time fork) https://mods.factorio.com/mod/Abandoned ... dated_fork

And I had a small but difficult problem for me.

The gist of it is that for a number of reasons I separated all the ruins from this mod into another submod. And now when I launch this mod without content and submods, an error appears:

Code: Select all


The mod The Ruins Mod Updated (Fork) (1.1.7) caused a non-recoverable error.
Please report this error to the mod author.

Error while running event AbandonedRuins_updated_fork::on_tick (ID 0)
AbandonedRuins_updated_fork/spawning.lua:185: bad argument #1 of 1 to 'random' (interval is empty)
stack traceback:
[C]: in function 'random'
AbandonedRuins_updated_fork/spawning.lua:185: in function 'spawn_random_ruin'
AbandonedRuins_updated_fork/control.lua:58: in function <AbandonedRuins_updated_fork/control.lua:53> 
It complains about a specific script:

Code: Select all

spawning.spawn_random_ruin = function(ruins, half_size, center, surface)
  --spawn a random ruin from the list
  spawning.spawn_ruin(ruins[math.random(#ruins)], half_size, center, surface)
end
The reason is that the script is looking for ruins files and can't find them:

I know roughly that I need to write a condition in this script so that it launches if there are ruins files, but I have no idea how to write it....

I can make a hack in the form of empty ruins files. But this is not the best solution...

I will be glad to any help! Thank you!
Attachments
spawning.lua
(5.94 KiB) Downloaded 18 times
FireMonster2112
Manual Inserter
Manual Inserter
Posts: 2
Joined: Fri Apr 28, 2023 11:31 pm
Contact:

Re: Error updating mod for Factorio 2.0 (continued 2)

Post by FireMonster2112 »

I am also getting this error, happens by tick 93 of a new world.
Attachments
12-21-2024, 09-52-47.png
12-21-2024, 09-52-47.png (163.03 KiB) Viewed 397 times
User avatar
IsaacOscar
Filter Inserter
Filter Inserter
Posts: 843
Joined: Sat Nov 09, 2024 2:36 pm
Contact:

Re: Error updating mod for Factorio 2.0 (continued 2)

Post by IsaacOscar »

Well you can trivially prevent the error with an if:

Code: Select all

spawning.spawn_random_ruin = function(ruins, half_size, center, surface)
  if #ruins > 0 then 
      spawning.spawn_ruin(ruins[math.random(#ruins)], half_size, center, surface)
   end
end
Are the ruins supposed to be empty though? How are you loading the files, and where are they stored?
Keysivi
Fast Inserter
Fast Inserter
Posts: 110
Joined: Mon Feb 07, 2022 5:29 pm
Contact:

Re: Error updating mod for Factorio 2.0 (continued 2)

Post by Keysivi »

IsaacOscar wrote: Sat Dec 21, 2024 2:59 pm Well you can trivially prevent the error with an if:

Code: Select all

spawning.spawn_random_ruin = function(ruins, half_size, center, surface)
  if #ruins > 0 then 
      spawning.spawn_ruin(ruins[math.random(#ruins)], half_size, center, surface)
   end
end
Are the ruins supposed to be empty though? How are you loading the files, and where are they stored?
Thank you very much for the tip.

I am familiar with 'if'. But unfortunately I don't have the brains to build such a construction - 'if #ruins > 0 then'

You can laugh at me...

"The ruihs mod" is quite old. I played with it quite a bit myself and noticed that after a few hours of playing with the basic content of the vanilla game, the "Wow" effect disappears... And further spawning of vanilla entities begins to irritate...

But some modders made submods for it with new content. For example, "The Ruins Mod - Fortress Ruins" https://mods.factorio.com/mod/FortressRuins . And this was already more interesting, since they diversified the game quite well.

That's why I separated the content of the original mod into a separate submod "The Ruins Mod - Base (Temporary)" https://mods.factorio.com/mod/AbandonedRuins-base. So that you could play both with vanilla ruins and without them (if you have more creative submods).
User avatar
IsaacOscar
Filter Inserter
Filter Inserter
Posts: 843
Joined: Sat Nov 09, 2024 2:36 pm
Contact:

Re: Error updating mod for Factorio 2.0 (continued 2)

Post by IsaacOscar »

Keysivi wrote: Sat Dec 21, 2024 3:42 pm
I am familiar with 'if'. But unfortunately I don't have the brains to build such a construction - 'if #ruins > 0 then'
I highly recommend reading section 3 of https://www.lua.org/manual/5.2/, it explains what all those symbols mean.
Keysivi
Fast Inserter
Fast Inserter
Posts: 110
Joined: Mon Feb 07, 2022 5:29 pm
Contact:

Re: Error updating mod for Factorio 2.0 (continued 2)

Post by Keysivi »

IsaacOscar wrote: Sat Dec 21, 2024 3:46 pm I highly recommend reading section 3 of https://www.lua.org/manual/5.2/, it explains what all those symbols mean.
Thank you! I'll read it. Maybe it will help...
Post Reply

Return to “Modding help”