Page 1 of 1

Setting construction robotics to nil

Posted: Mon Jan 08, 2018 3:51 am
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

Re: Setting construction robotics to nil

Posted: Mon Jan 08, 2018 6:52 am
by darkfrei
Where's error?

Re: Setting construction robotics to nil

Posted: Mon Jan 08, 2018 11:41 am
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, ...)

Re: Setting construction robotics to nil

Posted: Mon Jan 08, 2018 4:25 pm
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.

Re: Setting construction robotics to nil

Posted: Mon Jan 08, 2018 6:19 pm
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

Re: Setting construction robotics to nil

Posted: Tue Jan 09, 2018 1:30 am
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.

Re: Setting construction robotics to nil

Posted: Tue Jan 09, 2018 8:07 am
by darkfrei
It helps if you start this code twice. Instead you have the same error: prototype doesn't exist.

Re: Setting construction robotics to nil

Posted: Tue Jan 09, 2018 9:11 am
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.

Re: Setting construction robotics to nil

Posted: Tue Jan 09, 2018 3:47 pm
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.

Re: Setting construction robotics to nil

Posted: Tue Jan 09, 2018 5:03 pm
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.