How can I unlink these two forks from ModMash Splinter so that I no longer depend on the given library?

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

How can I unlink these two forks from ModMash Splinter so that I no longer depend on the given library?

Post by Keysivi »

Please help!

I have one urgent problem with two forks.

ModMash Splinter, Explosive Water https://mods.factorio.com/mod/modmashsp ... osivewater
ModMash Splinter, Boom https://mods.factorio.com/mod/modmashsplinterboom I updated it, but have not posted it on the portal yet.

The problem is that both forks have a dependency on the ModMash Splinter library https://mods.factorio.com/mod/modmashsplinter

Specifically, the dependency is written in the defines.lua file. Here is the code from this file:

Code: Select all

if not modmashsplinterexplosivemining then modmashsplinterexplosivemining = {} end

if modmashsplinterexplosivemining.util == nil then
	if remote ~= nil then
		require '__modmashsplinter__/prototypes/scripts/util'
		modmashsplinterexplosivemining.util = get_modmashsplinterlib()	
	else 
		modmashsplinterexplosivemining.util = get_modmashsplinterlib()
	end
end
The problem is that the developer of this library abandoned his mods and does not update them.

Creating a fork of ModMash Splinter is problematic for me, because I do not understand anything there. Locally with the above mentioned mods ModMash Splinter works if you update the version of Factorio in info.json

Please tell me - how can I untie these two forks from ModMash Splinter, so as not to depend on the given library anymore?

Thanks!
Attachments
modmashsplinter_1.1.13.zip
(57.5 KiB) Downloaded 11 times
modmashsplinterexplosivewater_1.0.2.zip
(159.65 KiB) Downloaded 13 times
modmashsplinterboom_1.1.05.zip
(499.42 KiB) Downloaded 8 times
User avatar
IsaacOscar
Filter Inserter
Filter Inserter
Posts: 841
Joined: Sat Nov 09, 2024 2:36 pm
Contact:

Re: How can I unlink these two forks from ModMash Splinter so that I no longer depend on the given library?

Post by IsaacOscar »

So you don't actually want to use that library right?
So what you'd want to do is look at your mods code and see what part of that library you are using, and then fork only that part.
Keysivi
Fast Inserter
Fast Inserter
Posts: 108
Joined: Mon Feb 07, 2022 5:29 pm
Contact:

Re: How can I unlink these two forks from ModMash Splinter so that I no longer depend on the given library?

Post by Keysivi »

IsaacOscar wrote: Fri Dec 27, 2024 7:22 am So you don't actually want to use that library right?
So what you'd want to do is look at your mods code and see what part of that library you are using, and then fork only that part.
I would prefer to make all forks independent, standalone mods.

That is, pull the necessary code from the library and place it directly in the forks.

I tried to do this myself and my brain exploded.
User avatar
IsaacOscar
Filter Inserter
Filter Inserter
Posts: 841
Joined: Sat Nov 09, 2024 2:36 pm
Contact:

Re: How can I unlink these two forks from ModMash Splinter so that I no longer depend on the given library?

Post by IsaacOscar »

Keysivi wrote: Fri Dec 27, 2024 7:42 am
IsaacOscar wrote: Fri Dec 27, 2024 7:22 am So you don't actually want to use that library right?
So what you'd want to do is look at your mods code and see what part of that library you are using, and then fork only that part.
I would prefer to make all forks independent, standalone mods.

That is, pull the necessary code from the library and place it directly in the forks.

I tried to do this myself and my brain exploded.
Ok, I've checked and I found only two functions you're using from that mod, so it should be pretty simple, give me a moment.
User avatar
IsaacOscar
Filter Inserter
Filter Inserter
Posts: 841
Joined: Sat Nov 09, 2024 2:36 pm
Contact:

Re: How can I unlink these two forks from ModMash Splinter so that I no longer depend on the given library?

Post by IsaacOscar »

So I checked, and the following four lines are all I found that references that mod:
  • local table_contains = modmashsplinterboom.util.table.contains (in modmashsplinterboom_1.1.05/prototypes/scripts/data-final-fixes.lua)
  • local is_valid = modmashsplinterboom.util.is_valid (in modmashsplinterboom_1.1.05/prototypes/scripts/boom.lua, modmashsplinterboom_1.1.05/prototypes/scripts/boom.old)
  • local is_valid = modmashsplinterexplosivemining.util.is_valid (in modmashsplinterexplosivewater/prototypes/scripts/scripts.lua)
  • local starts_with = modmashsplinterexplosivemining.util.starts_with (in modmashsplinterexplosivewater/prototypes/scripts/scripts.lua)
  • local print = modmashsplinterboom.util.print (in modmashsplinterboom/prototypes/scripts/boom.lua and modmashsplinterboom/prototypes/scripts/boom.old)
  • local print = modmashsplinterexplosivemining.util.print (in modmashsplinterexplosivewater/prototypes/scripts/scripts.lua)
However, other than the table_contains and is_valid locals, none of the others are used, so those lines can just be deleted, and you only need to copy table_contains and is_valid over
User avatar
IsaacOscar
Filter Inserter
Filter Inserter
Posts: 841
Joined: Sat Nov 09, 2024 2:36 pm
Contact:

Re: How can I unlink these two forks from ModMash Splinter so that I no longer depend on the given library?

Post by IsaacOscar »

TL;DR I try to explain exactly how I worked out what to do, but if you can't be bothered, just replace the line in modmashsplinterboom_1.1.05/prototypes/scripts/data-final-fixes.lua that says "local table_contains = modmashsplinterboom.util.table.contains", with the code at the end of this post.
How I worked it out

Code: Select all

function table_contains(table, value)
	for k, v in pairs(table) do 
		if v == value then
			return true
        	end
	end return false
end
User avatar
IsaacOscar
Filter Inserter
Filter Inserter
Posts: 841
Joined: Sat Nov 09, 2024 2:36 pm
Contact:

Re: How can I unlink these two forks from ModMash Splinter so that I no longer depend on the given library?

Post by IsaacOscar »

Oh, and for the local is_valid = modmashsplinterboom.util.is_valid line (in modmashsplinterboom_1.1.05/prototypes/scripts/boom.lua and modmashsplinterboom_1.1.05/prototypes/scripts/boom.old), and the local is_valid = modmashsplinterexplosivemining.util.is_valid line (in modmashsplinterexplosivewater/prototypes/scripts/scripts.lua).
You can use the same logic I used in my previous comment.
You will find the definition of is_valid in modmashsplinter_1.1.13/prototypes/scripts/utilcontrol.lua
So all you need to do is change local = modmashsplinterexplosivemining.util.is_valid to function is_valid(entity) return type(entity)=="table" and entity.valid end
Now that you've done that, you can simply delete your 'defines.lua' file, and make sure to delete any references to it (e.g. a require ("prototypes.scripts.defines") line).
Keysivi
Fast Inserter
Fast Inserter
Posts: 108
Joined: Mon Feb 07, 2022 5:29 pm
Contact:

Re: How can I unlink these two forks from ModMash Splinter so that I no longer depend on the given library?

Post by Keysivi »

IsaacOscar wrote: Fri Dec 27, 2024 7:48 am So I checked, and the following four lines are all I found that references that mod:
  • local table_contains = modmashsplinterboom.util.table.contains (in modmashsplinterboom_1.1.05/prototypes/scripts/data-final-fixes.lua)
  • local is_valid = modmashsplinterboom.util.is_valid (in modmashsplinterboom_1.1.05/prototypes/scripts/boom.lua, modmashsplinterboom_1.1.05/prototypes/scripts/boom.old)
  • local is_valid = modmashsplinterexplosivemining.util.is_valid (in modmashsplinterexplosivewater/prototypes/scripts/scripts.lua)
  • local starts_with = modmashsplinterexplosivemining.util.starts_with (in modmashsplinterexplosivewater/prototypes/scripts/scripts.lua)
  • local print = modmashsplinterboom.util.print (in modmashsplinterboom/prototypes/scripts/boom.lua and modmashsplinterboom/prototypes/scripts/boom.old)
  • local print = modmashsplinterexplosivemining.util.print (in modmashsplinterexplosivewater/prototypes/scripts/scripts.lua)
However, other than the table_contains and is_valid locals, none of the others are used, so those lines can just be deleted, and you only need to copy table_contains and is_valid over
I understand that I need to change:

Code: Select all

    local table_contains = modmashsplinterboom.util.table.contains (in modmashsplinterboom_1.1.05/prototypes/scripts/data-final-fixes.lua)
    local is_valid = modmashsplinterboom.util.is_valid (in modmashsplinterboom_1.1.05/prototypes/scripts/boom.lua, modmashsplinterboom_1.1.05/prototypes/scripts/boom.old)
    local is_valid = modmashsplinterexplosivemining.util.is_valid (in modmashsplinterexplosivewater/prototypes/scripts/scripts.lua)

on

Code: Select all

    local table_contains = function(table, value) return local_table_index_of(table, value) ~= nil end (in modmashsplinterboom_1.1.05/prototypes/scripts/data-final-fixes.lua)
    local is_valid  = function(entity) return type(entity)=="table" end (in modmashsplinterboom_1.1.05/prototypes/scripts/boom.lua, modmashsplinterboom_1.1.05/prototypes/scripts/boom.old)
    local is_valid = function(entity) return type(entity)=="table" end (in modmashsplinterexplosivewater/prototypes/scripts/scripts.lua)
Right?
User avatar
IsaacOscar
Filter Inserter
Filter Inserter
Posts: 841
Joined: Sat Nov 09, 2024 2:36 pm
Contact:

Re: How can I unlink these two forks from ModMash Splinter so that I no longer depend on the given library?

Post by IsaacOscar »

Keysivi wrote: Fri Dec 27, 2024 8:24 am Right?
You need the local_table_index_of function (or use the version I suggested which inlined it)
Keysivi
Fast Inserter
Fast Inserter
Posts: 108
Joined: Mon Feb 07, 2022 5:29 pm
Contact:

Re: How can I unlink these two forks from ModMash Splinter so that I no longer depend on the given library?

Post by Keysivi »

IsaacOscar wrote: Fri Dec 27, 2024 8:10 am TL;DR I try to explain exactly how I worked out what to do, but if you can't be bothered, just replace the line in modmashsplinterboom_1.1.05/prototypes/scripts/data-final-fixes.lua that says "local table_contains = modmashsplinterboom.util.table.contains", with the code at the end of this post.
I apologize. I care. My main problem is that my brain is too weak for such a volume of new information. I always try to understand everything you write to me. And I still manage to grasp some bits. Thank you!

To avoid confusion, I will now repeat all the actions that I need to do:

1. I delete all the lines:

Code: Select all

    local starts_with = modmashsplinterexplosivemining.util.starts_with (in modmashsplinterexplosivewater/prototypes/scripts/scripts.lua)
    local print = modmashsplinterboom.util.print (in modmashsplinterboom/prototypes/scripts/boom.lua and modmashsplinterboom/prototypes/scripts/boom.old)
    local print = modmashsplinterexplosivemining.util.print (in modmashsplinterexplosivewater/prototypes/scripts/scripts.lua)
2. I replace

Code: Select all

    local table_contains = modmashsplinterboom.util.table.contains (in modmashsplinterboom_1.1.05/prototypes/scripts/data-final-fixes.lua)
With the function:

Code: Select all

function table_contains(table, value)
	for k, v in pairs(table) do 
		if v == value then
			return true
        	end
	end return false
end
3. I replace the lines

Code: Select all

    local is_valid = modmashsplinterboom.util.is_valid (in modmashsplinterboom_1.1.05/prototypes/scripts/boom.lua, modmashsplinterboom_1.1.05/prototypes/scripts/boom.old)
    local is_valid = modmashsplinterexplosivemining.util.is_valid (in modmashsplinterexplosivewater/prototypes/scripts/scripts.lua)
with

Code: Select all

    local is_valid  = function(entity) return type(entity)=="table" end (in modmashsplinterboom_1.1.05/prototypes/scripts/boom.lua, modmashsplinterboom_1.1.05/prototypes/scripts/boom.old)
    local is_valid = function(entity) return type(entity)=="table" end (in modmashsplinterexplosivewater/prototypes/scripts/scripts.lua)
4. I delete the file "defines.lua" and all references to it.
User avatar
IsaacOscar
Filter Inserter
Filter Inserter
Posts: 841
Joined: Sat Nov 09, 2024 2:36 pm
Contact:

Re: How can I unlink these two forks from ModMash Splinter so that I no longer depend on the given library?

Post by IsaacOscar »

Yup!
Sorry for the information overload, I was hoping if I explain things maybe you'll be able to do more on your own next time...
Keysivi
Fast Inserter
Fast Inserter
Posts: 108
Joined: Mon Feb 07, 2022 5:29 pm
Contact:

Re: How can I unlink these two forks from ModMash Splinter so that I no longer depend on the given library?

Post by Keysivi »

IsaacOscar wrote: Fri Dec 27, 2024 8:53 am Yup!
Sorry for the information overload, I was hoping if I explain things maybe you'll be able to do more on your own next time...
Everything is fine. It is not your fault that you have to work with such stupid recipients as me...

In reality, I want to finally sort out the old mods and try to work on the new "Hardcorio" mod.

You are already familiar with it. It was for it that the function for simultaneous extraction of two resources instead of one was created.

In the new mod, I want to try to make it so that assemblers do not just assemble complex structures from primitive ingredients, but first form intermediate modules from primitive ingredients, and then assemble complex structures from these modules...

It does not require particularly complex scripts. Basically, redefining recipes and creating new items.
User avatar
IsaacOscar
Filter Inserter
Filter Inserter
Posts: 841
Joined: Sat Nov 09, 2024 2:36 pm
Contact:

Re: How can I unlink these two forks from ModMash Splinter so that I no longer depend on the given library?

Post by IsaacOscar »

Are you suggesting a single Assembler making stuff in stages? (So it makes the intermediate thing first, and then automatically makes the final product)? Because I've done something like that with the circuit network, but it is slow due to trash slots...
Keysivi
Fast Inserter
Fast Inserter
Posts: 108
Joined: Mon Feb 07, 2022 5:29 pm
Contact:

Re: How can I unlink these two forks from ModMash Splinter so that I no longer depend on the given library?

Post by Keysivi »

IsaacOscar wrote: Fri Dec 27, 2024 9:14 am Are you suggesting a single Assembler making stuff in stages? (So it makes the intermediate thing first, and then automatically makes the final product)? Because I've done something like that with the circuit network, but it is slow due to trash slots...
No, it's simpler. New intermediate items with new recipes will simply be added to the game.

For example, in the vanilla game, a gun turret is assembled from 10 "iron gear wheel", 10 "copper plate" and 20 "iron plate". And I want to do it this way, so that first, 3 modules are assembled from simpler ingredients: a "barbette", a "combat module" and a "control module". And the gun turret itself is assembled from these three modules.
User avatar
IsaacOscar
Filter Inserter
Filter Inserter
Posts: 841
Joined: Sat Nov 09, 2024 2:36 pm
Contact:

Re: How can I unlink these two forks from ModMash Splinter so that I no longer depend on the given library?

Post by IsaacOscar »

Keysivi wrote: Fri Dec 27, 2024 11:08 am No, it's simpler. New intermediate items with new recipes will simply be added to the game.

For example, in the vanilla game, a gun turret is assembled from 10 "iron gear wheel", 10 "copper plate" and 20 "iron plate". And I want to do it this way, so that first, 3 modules are assembled from simpler ingredients: a "barbette", a "combat module" and a "control module". And the gun turret itself is assembled from these three modules.
Oh god, why... the recipes are already complex enough already
Keysivi
Fast Inserter
Fast Inserter
Posts: 108
Joined: Mon Feb 07, 2022 5:29 pm
Contact:

Re: How can I unlink these two forks from ModMash Splinter so that I no longer depend on the given library?

Post by Keysivi »

IsaacOscar wrote: Fri Dec 27, 2024 11:20 am Oh god, why... the recipes are already complex enough already
I just have this desire. To add a little more realism to the game...

That's why I gave the mod a corresponding name. In reality, it's not that scary - because I plan to make many modules universal. And they will simply replace simpler ingredients in many recipes.

Of course, this will lead to scaling of production and an increase in the consumption of basic resources.

But many players like it. Especially since there are a lot of mods that make the game more difficult... I just want to try to make my own version....
User avatar
IsaacOscar
Filter Inserter
Filter Inserter
Posts: 841
Joined: Sat Nov 09, 2024 2:36 pm
Contact:

Re: How can I unlink these two forks from ModMash Splinter so that I no longer depend on the given library?

Post by IsaacOscar »

Keysivi wrote: Fri Dec 27, 2024 11:35 am
IsaacOscar wrote: Fri Dec 27, 2024 11:20 am Oh god, why... the recipes are already complex enough already
I just have this desire. To add a little more realism to the game...

That's why I gave the mod a corresponding name. In reality, it's not that scary - because I plan to make many modules universal. And they will simply replace simpler ingredients in many recipes.

Of course, this will lead to scaling of production and an increase in the consumption of basic resources.

But many players like it. Especially since there are a lot of mods that make the game more difficult... I just want to try to make my own version....
Fair enough!
What I want though is a mod that makes rocket silos work with mixed cargo (so it can automatically request lots of different stuff from the logistics network to fill a rocket, thus minimising the total number of rocket launches), you think you could do that?
Keysivi
Fast Inserter
Fast Inserter
Posts: 108
Joined: Mon Feb 07, 2022 5:29 pm
Contact:

Re: How can I unlink these two forks from ModMash Splinter so that I no longer depend on the given library?

Post by Keysivi »

IsaacOscar wrote: Fri Dec 27, 2024 11:57 am Fair enough!
What I want though is a mod that makes rocket silos work with mixed cargo (so it can automatically request lots of different stuff from the logistics network to fill a rocket, thus minimising the total number of rocket launches), you think you could do that?
What did you want me to do with it? Because I'm too weak in terms of code. You know that yourself...

I can do a little bit of graphics. For example, draw icons. In terms of file structure, everything is pretty elementary. That is, if I have a ready-made code, then it won't be difficult for me to create an archive with the mod.

However, it will be problematic for me to test it, since I haven't reached space yet. And how all this interplanetary logistics works there - I don't know.
User avatar
IsaacOscar
Filter Inserter
Filter Inserter
Posts: 841
Joined: Sat Nov 09, 2024 2:36 pm
Contact:

Re: How can I unlink these two forks from ModMash Splinter so that I no longer depend on the given library?

Post by IsaacOscar »

Keysivi wrote: Fri Dec 27, 2024 12:19 pm What did you want me to do with it? Because I'm too weak in terms of code. You know that yourself...
Sorry, it was a joke. Just my biggest complaint with space age so far, but even I'm too scared to attempt to fix it...
Keysivi wrote: Fri Dec 27, 2024 12:19 pm I can do a little bit of graphics. For example, draw icons. In terms of file structure, everything is pretty elementary. That is, if I have a ready-made code, then it won't be difficult for me to create an archive with the mod.

However, it will be problematic for me to test it, since I haven't reached space yet. And how all this interplanetary logistics works there - I don't know.
Yes, it does take a while to do that. Perhaps you should make the technologies and materials required much easier, but push unnecessary stuff from nauvis to other planets?
Perhaps make a way to easily transport the player to other planets, but you need to do more advanced research on said planets before you actually unlock space platforms? This will be too hard though if you don't know how to make GUI's (and I don't) (the actual transporting to the other planet should be easy).
This is probably a bit too hard though, just another suggestion that might make the game better.

The only other main complaint I have with space age would be that platform speed depends significantly on the width, but very little on the weight, but there's already a mod (https://mods.factorio.com/mod/Rocs-Impr ... tform-Drag) that fixes that; I don't want to use it though as it feels like cheating (or maybe it actually makes the game harder, by encouraging me to build lighter platforms?)
Keysivi
Fast Inserter
Fast Inserter
Posts: 108
Joined: Mon Feb 07, 2022 5:29 pm
Contact:

Re: How can I unlink these two forks from ModMash Splinter so that I no longer depend on the given library?

Post by Keysivi »

IsaacOscar wrote: Fri Dec 27, 2024 12:29 pm The only other main complaint I have with space age would be that platform speed depends significantly on the width, but very little on the weight, but there's already a mod (https://mods.factorio.com/mod/Rocs-Impr ... tform-Drag) that fixes that; I don't want to use it though as it feels like cheating (or maybe it actually makes the game harder, by encouraging me to build lighter platforms?)
There are several mods that make interplanetary logistics and travel easier in different ways:

Here are some examples:
Telogistics https://mods.factorio.com/mod/Telogistics
Adjustable_Rocketry https://mods.factorio.com/mod/Adjustable_Rocketry
Rocket Cargo Insertion https://mods.factorio.com/mod/RocketCargoInsertion
Circuit Launchable Rockets https://mods.factorio.com/mod/CircuitLaunchableRockets
Reusable rocket https://mods.factorio.com/mod/reusable-rocket-simple
Rocket silos can buffer more rockets https://mods.factorio.com/mod/rocket-si ... re-rockets
Rocket Reusability https://mods.factorio.com/mod/rocket-reusability
Teleporters Space Age https://mods.factorio.com/mod/Teleporters_SpaceAge
五雷正法和传送(Magician) https://mods.factorio.com/mod/ZY-God
Teleporters https://mods.factorio.com/mod/Teleporters
Transport rings https://mods.factorio.com/mod/transport-ring-teleporter

Maybe there is something interesting for you there?
IsaacOscar wrote: Fri Dec 27, 2024 12:29 pm The only other main complaint I have with space age would be that platform speed depends significantly on the width, but very little on the weight, but there's already a mod (https://mods.factorio.com/mod/Rocs-Impr ... tform-Drag) that fixes that; I don't want to use it though as it feels like cheating (or maybe it actually makes the game harder, by encouraging me to build lighter platforms?)
What if you try to make a fork of this mod or make your own mod-tweak to make that mod less cheating?
Post Reply

Return to “Modding help”