Not sure if I can explain it correctly, but I'll try.
I'm essentially modding a mod at the moment. I'm creating a mod (currently for personal use, but that may change) that uses evildogbot100's mod
Diesel Locomotive as a base. I'm creating (currently) 3 locomotives that use his system, each with (hopefully) different qualities, pros & cons, etc. This also includes different fuel tank sizes for each one. In order for his system to work of allowing the locomotive to use fluids, he needs to create proxy tanks (pre-establishing their capacity) and then in control.lua has hardcoded "entity.name = " checks to see if the locomotive is one of his, and if so, hardcoded assignment of the proxy tanks to it in the appropriate circumstances.
Because I'm adding additional locomotives, obviously his "entity.name = " checks will fail to identify mine. I've gotten around this by modifying his code with string.find for now.
Then there's the matter of my locomotives having different tank sizes. I created the appropriate proxy tanks in my mod, but need to modify his code to support adding different sized tanks depending on which locomotive is queued up in the code. For now I do this by adding the tank size to the name of my locomotive and the proxy tanks I created, then in his code use string.match to find and pull this number so it can in turn be used to match up the correct proxy tank.
So, for example, I'll do something like this in data-update.lua during the creation process of the locomotives
Code: Select all
newloco1.name = "Diesel-Locomotive-fluid-locomotive-"..NEWLOCO1_TANK_CAPACITY.."-newloco1" -- The additional "newloco1" in the name is meant as a further identifier in case two locomotives have the same tank capacity value
and fluid tanks
Code: Select all
tank.name = "Diesel-Locomotive-proxy-tank-"..NEWLOCO1_TANK_CAPACITY.."-"..i
Then in his control.lua, I have to modify his code so where it checks to see if it's a valid locomotive, instead of
Code: Select all
entity.name == "Diesel-Locomotive-fluid-locomotive"
it's now
Code: Select all
string.find(entity.name, "Diesel%-Locomotive%-fluid%-locomotive") ~= nil
Then, where it checks for and creates/destroys the proxy tanks, I have to modify this
Code: Select all
if not (proxy.tank[i].name == "Diesel-Locomotive-proxy-tank-"..tank_type)
to this
Code: Select all
if not (proxy.tank[i].name == "Diesel-Locomotive-proxy-tank-"..(string.match(loco.name, "Diesel%-Locomotive%-fluid%-locomotive%-(%d+%-)%w+") or "")..tank_type) then
Obviously I feel all of this would just be easier if during creation of the locomotive (at least) I could just do this:
Code: Select all
newloco1.fluid_tank_size = NEWLOCO1_TANK_CAPACITY
And then in control.lua, I could use the presence of that value to tell if it's a locomotive requiring a fluid tank and even directly query it for use in assigning the correct proxy tank.
Ultimately, once I'm done with these edits, I plan on suggesting them to evildogbot100 to make his mod more compatible with anyone else wanting to expand off from it, but also to make it so if he makes an edit to his mod, I won't need find and port this edit into my current alternate version of his mod.

I want to try and make it as "fool proof" as possible first, though, before calling it good and sending the edits to him. But as is it just seems messy. :/