Page 1 of 1

How to make a new science pack?

Posted: Mon Mar 19, 2018 4:09 pm
by firestar246
So I wanted to make a new science pack. I copied science pack 1, changed the name, graphics, and recipe , but it isn't showing up on the laboratories screen. Is there something else I have to do?


Thanks!

Re: How to make a new science pack?

Posted: Mon Mar 19, 2018 4:31 pm
by darkfrei
firestar246 wrote:So I wanted to make a new science pack. I copied science pack 1, changed the name, graphics, and recipe , but it isn't showing up on the laboratories screen. Is there something else I have to do?


Thanks!

Code: Select all

data.raw.lab.lab.inputs[1] = "science-pack-1"
data.raw.lab.lab.inputs[2] = "science-pack-2"
data.raw.lab.lab.inputs[3] = "science-pack-3"
data.raw.lab.lab.inputs[4] = "military-science-pack"
data.raw.lab.lab.inputs[5] = "production-science-pack"
data.raw.lab.lab.inputs[6] = "high-tech-science-pack"
data.raw.lab.lab.inputs[7] = "space-science-pack"
Add here your item.

Re: How to make a new science pack?

Posted: Mon Mar 19, 2018 4:53 pm
by firestar246
darkfrei wrote:
firestar246 wrote:So I wanted to make a new science pack. I copied science pack 1, changed the name, graphics, and recipe , but it isn't showing up on the laboratories screen. Is there something else I have to do?


Thanks!

Code: Select all

data.raw.lab.lab.inputs[1] = "science-pack-1"
data.raw.lab.lab.inputs[2] = "science-pack-2"
data.raw.lab.lab.inputs[3] = "science-pack-3"
data.raw.lab.lab.inputs[4] = "military-science-pack"
data.raw.lab.lab.inputs[5] = "production-science-pack"
data.raw.lab.lab.inputs[6] = "high-tech-science-pack"
data.raw.lab.lab.inputs[7] = "space-science-pack"
Add here your item.
Thanks for helping me again! Out of curiosity, what would happen if I had this mod and another mod on at the same time that added an 8th input to the lab? Would they conflict or would the game fix it somehow? Just curios...

Re: How to make a new science pack?

Posted: Mon Mar 19, 2018 5:14 pm
by Arch666Angel

Code: Select all

table.insert(data.raw["lab"]["lab"].inputs, "your-science-pack")

Re: How to make a new science pack?

Posted: Tue Mar 20, 2018 9:03 am
by bobingabout
firestar246 wrote:
darkfrei wrote:
firestar246 wrote:So I wanted to make a new science pack. I copied science pack 1, changed the name, graphics, and recipe , but it isn't showing up on the laboratories screen. Is there something else I have to do?


Thanks!

Code: Select all

data.raw.lab.lab.inputs[1] = "science-pack-1"
data.raw.lab.lab.inputs[2] = "science-pack-2"
data.raw.lab.lab.inputs[3] = "science-pack-3"
data.raw.lab.lab.inputs[4] = "military-science-pack"
data.raw.lab.lab.inputs[5] = "production-science-pack"
data.raw.lab.lab.inputs[6] = "high-tech-science-pack"
data.raw.lab.lab.inputs[7] = "space-science-pack"
Add here your item.
Thanks for helping me again! Out of curiosity, what would happen if I had this mod and another mod on at the same time that added an 8th input to the lab? Would they conflict or would the game fix it somehow? Just curios...
Yeah, he gave you bad advice. this isn't an array, it's a table, you don't need to specifically reference each item by it's index number to add a new one, simply table.insert. Like what angel posted.
Arch666Angel wrote:

Code: Select all

table.insert(data.raw["lab"]["lab"].inputs, "your-science-pack")

Re: How to make a new science pack?

Posted: Tue Mar 20, 2018 9:16 am
by darkfrei
bobingabout wrote:
firestar246 wrote:
darkfrei wrote:
firestar246 wrote:So I wanted to make a new science pack. I copied science pack 1, changed the name, graphics, and recipe , but it isn't showing up on the laboratories screen. Is there something else I have to do?


Thanks!

Code: Select all

data.raw.lab.lab.inputs[1] = "science-pack-1"
data.raw.lab.lab.inputs[2] = "science-pack-2"
data.raw.lab.lab.inputs[3] = "science-pack-3"
data.raw.lab.lab.inputs[4] = "military-science-pack"
data.raw.lab.lab.inputs[5] = "production-science-pack"
data.raw.lab.lab.inputs[6] = "high-tech-science-pack"
data.raw.lab.lab.inputs[7] = "space-science-pack"
Add here your item.
Thanks for helping me again! Out of curiosity, what would happen if I had this mod and another mod on at the same time that added an 8th input to the lab? Would they conflict or would the game fix it somehow? Just curios...
Yeah, he gave you bad advice. this isn't an array, it's a table, you don't need to specifically reference each item by it's index number to add a new one, simply table.insert. Like what angel posted.
Arch666Angel wrote:

Code: Select all

table.insert(data.raw["lab"]["lab"].inputs, "your-science-pack")
All is table in lua. Of coarse new value must be added to inputs with function table.insert. https://www.lua.org/pil/19.2.html
And vanilla inputs can be written as list:

Code: Select all

data.raw.lab.lab.inputs = {"science-pack-1", "science-pack-2", "science-pack-3", "military-science-pack", "production-science-pack",  "high-tech-science-pack", "space-science-pack"}
There is no different between this code and code above.

Re: How to make a new science pack?

Posted: Tue Mar 20, 2018 9:22 am
by Arch666Angel
There is a significant one: Table.insert appends your argument to the end of the existing table, what you do is override the whole table with your new definition.