Setting construction robotics to nil

Place to get help with not working mods / modding interface.
MrGuffels
Burner Inserter
Burner Inserter
Posts: 12
Joined: Sun Mar 05, 2017 7:47 am
Contact:

Setting construction robotics to nil

Post by MrGuffels »

(I will start with the fact that I am in 15.40 just incase that matters)
So I am trying to remove construction robotics for a mod I am making. I have already removed logistic-robotics without any problems but construction-robotics throws an error every time I try to set it to nil.
Check me to make sure this is right

Code: Select all

 data.raw.technology["construction-robotics"] = nil 
The error I get is that construction-robotics does not exist.
But reading through the technology.lua file, construction-robotics starts on line 2061.

Does anyone know what I am doing wrong or have any pointers to get me past this?

Here is the error specifically
https://imgur.com/HQERRxd

Source files are here if anyone wants to see them
https://github.com/MrGuffels/World-of-R ... ots_0.2.1b
Last edited by MrGuffels on Mon Jan 08, 2018 7:19 am, edited 3 times in total.
User avatar
darkfrei
Smart Inserter
Smart Inserter
Posts: 2905
Joined: Thu Nov 20, 2014 11:11 pm
Contact:

Re: Setting construction robotics to nil

Post by darkfrei »

Where's error?
User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5211
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: Setting construction robotics to nil

Post by eradicator »

You're reading the error message wrong. It says construction-robotics does not exist. This means that it was successfully deleted, the line you quoted can never throw an error because data.raw.technoloy always exists. And thus adding (nil) values to it can not fail. (i.e. data.raw.technology.thisdoesnotexist = nil will not produce an error).
The error message says that the actual source of the error is "black-out-the-skies", so it sounds more like somewhere else in your code you require construction-robotics, but because you deleted it it's not there anymore. (Using github search i can't find anything suspicious though, ...)
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.
MrGuffels
Burner Inserter
Burner Inserter
Posts: 12
Joined: Sun Mar 05, 2017 7:47 am
Contact:

Re: Setting construction robotics to nil

Post by MrGuffels »

Yeah I noticed that when I was taking the screenshot of the error message. The tech I added has no dependencies on other tech so.... I have no clue what is going on.
User avatar
darkfrei
Smart Inserter
Smart Inserter
Posts: 2905
Joined: Thu Nov 20, 2014 11:11 pm
Contact:

Re: Setting construction robotics to nil

Post by darkfrei »

try so:

Code: Select all

if data.raw.technology and data.raw.technology["construction-robotics"]  then 
  data.raw.technology["construction-robotics"] = nil
end
User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5211
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: Setting construction robotics to nil

Post by eradicator »

darkfrei wrote:try so:

Code: Select all

if data.raw.technology and data.raw.technology["construction-robotics"]  then 
  data.raw.technology["construction-robotics"] = nil
end
That changes nothing (it is tautological). If it doesn't exist it will simply continue to not exist.
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.
User avatar
darkfrei
Smart Inserter
Smart Inserter
Posts: 2905
Joined: Thu Nov 20, 2014 11:11 pm
Contact:

Re: Setting construction robotics to nil

Post by darkfrei »

It helps if you start this code twice. Instead you have the same error: prototype doesn't exist.
User avatar
bobingabout
Smart Inserter
Smart Inserter
Posts: 7352
Joined: Fri May 09, 2014 1:01 pm
Contact:

Re: Setting construction robotics to nil

Post by bobingabout »

MrGuffels wrote:Yeah I noticed that when I was taking the screenshot of the error message. The tech I added has no dependencies on other tech so.... I have no clue what is going on.
A technology named black out the skies in mod world of robots has a dependency on construction robotics which no longer exists, because you deleted it by setting it to nil.

The solution, is that after your data.raw.technology["construction-robotics"] = nil line, you need to have a for loop going through all technologies, containing a for loop going through all dependancies, and if it matches construction robotics, set that dependency to nil.

And I'd actually put this for loop in data updates to remove the construction robotics dependency from other mods too, because you KNOW other mods are going to have dependancies for base game technology without checking to see if they exist first.
Creator of Bob's mods. Expanding your gameplay since version 0.9.8.
I also have a Patreon.
MrGuffels
Burner Inserter
Burner Inserter
Posts: 12
Joined: Sun Mar 05, 2017 7:47 am
Contact:

Re: Setting construction robotics to nil

Post by MrGuffels »

bobingabout wrote:A technology named black out the skies in mod world of robots has a dependency on construction robotics which no longer exists, because you deleted it by setting it to nil.
So just looking at the source code, I can't figure out where the dependency is. This is the technology file with the black out the skies technology.
https://github.com/MrGuffels/World-of-R ... nology.lua

I would assume that it has something to do with either unlocking the recipe or unlocking the ghost time to live but I didn't think either of those were dependant on the construction robotics technology.
User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5211
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: Setting construction robotics to nil

Post by eradicator »

bobingabout wrote: A technology named black out the skies in mod world of robots has a dependency on construction robotics which no longer exists, because you deleted it by setting it to nil.
That's what i thought at first too, but neither his code nor base game seems to have any technology that prerequisites construction-robotics.

@MrGuffels:
Looking at the base game files i can see that there's a tutorial that depends on construction-robotics though. So you might have other problems after this one. Also looping through all techs (like bob suggests) and just removing the requirement is going to break progression, you'd have to replace the requirement with something else or do some other sanity checking.

Btw, do you absolutely require to remove construction-robotics? Can't you just replace all the effects/graphics/descriptions of construction-robotics with your black-out-the-skies thing? That way you keep the internal name (and nothing should break) while still getting your new mechanics.
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.
Post Reply

Return to “Modding help”