adding a property using table insert between se and mega furnace

Place to get help with not working mods / modding interface.
Post Reply
SANCHERIZZO
Burner Inserter
Burner Inserter
Posts: 7
Joined: Tue Mar 19, 2024 10:41 pm
Contact:

adding a property using table insert between se and mega furnace

Post by SANCHERIZZO »

Hello guys! I need help. I want to write an addon that allows you to use a furnace in space for se. But the problem is that when trying to add the property se_allow_in_space = true, it does not work. I tried it using table insert. does not work. Thank you for your help.

Code: Select all

if data.raw["assembling-machine"]["mega-furnace"] then
  data.raw["assembling-machine"]["mega-furnace"].se_allow_in_space = true
end
Not working.

Code: Select all

table.insert (data.raw["assembling-machine"]["mega-furnace"],{{se_allow_in_space = true}})
not working too.

Code: Select all

data.raw["assembling-machine"]["mega-furnace"].se_allow_in_space = true
not working.

Bilka
Factorio Staff
Factorio Staff
Posts: 3139
Joined: Sat Aug 13, 2016 9:20 am
Contact:

Re: adding a property using table insert between se and mega furnace

Post by Bilka »

table.insert is intended for array-like tables, meaning a table with continuous numeric keys starting from 1. A prototype is not an array-like table. So data.raw["assembling-machine"]["mega-furnace"].se_allow_in_space = true is the correct syntax.

Have you checked whether the type and name you're using are correct? Usually furnaces have the furnace type, so data.raw["furnace"]["mega-furnace"].se_allow_in_space = true.

Or maybe "mega-furnace" is not the correct name for the prototype. You can check the prototype name and type by selecting the entity in-game and pressing SHIFT + CTRL + F to open the prototype explorer. It has rows for those two values.
I'm an admin over at https://wiki.factorio.com. Feel free to contact me if there's anything wrong (or right) with it.

SANCHERIZZO
Burner Inserter
Burner Inserter
Posts: 7
Joined: Tue Mar 19, 2024 10:41 pm
Contact:

Re: adding a property using table insert between se and mega furnace

Post by SANCHERIZZO »

Bilka wrote:
Wed Mar 20, 2024 9:12 am
Or maybe "mega-furnace" is not the correct name for the prototype. You can check the prototype name and type by selecting the entity in-game and pressing SHIFT + CTRL + F to open the prototype explorer. It has rows for those two values.
in original mod yes is a furnace but krastorio2 or se changes type furnace on a assembling machine
Last edited by SANCHERIZZO on Wed Mar 20, 2024 9:37 am, edited 1 time in total.

SANCHERIZZO
Burner Inserter
Burner Inserter
Posts: 7
Joined: Tue Mar 19, 2024 10:41 pm
Contact:

Re: adding a property using table insert between se and mega furnace

Post by SANCHERIZZO »

screenshot assembling machine
Attachments
screenshot
screenshot
изображение_2024-03-20_102953694.png (2.28 MiB) Viewed 375 times

User avatar
Stringweasel
Filter Inserter
Filter Inserter
Posts: 319
Joined: Thu Apr 27, 2017 8:22 pm
Contact:

Re: adding a property using table insert between se and mega furnace

Post by Stringweasel »

Are you sure your code is running? Is it placed in `data.lua`? Does it have an dependency on the mega-furnace mod?

To be sure you can change your code to:

Code: Select all

error("The code is running as expected")
if data.raw["assembling-machine"]["mega-furnace"] then
  data.raw["assembling-machine"]["mega-furnace"].se_allow_in_space = true
end
Alt-F4 Author | Factorio Modder
Mods: Hall of Fame | Better Victory Screen | Fluidic Power | Biter Power | Space Spidertron | Spidertron Dock | Weasel's Demolition Derby

SANCHERIZZO
Burner Inserter
Burner Inserter
Posts: 7
Joined: Tue Mar 19, 2024 10:41 pm
Contact:

Re: adding a property using table insert between se and mega furnace

Post by SANCHERIZZO »

Code: Select all

error("The code is running as expected")
please tell me where i see it, in game or log files?

User avatar
Stringweasel
Filter Inserter
Filter Inserter
Posts: 319
Joined: Thu Apr 27, 2017 8:22 pm
Contact:

Re: adding a property using table insert between se and mega furnace

Post by Stringweasel »

It should crash your game while it's loading with that error message. If it's not then your code isn't running :)
Alt-F4 Author | Factorio Modder
Mods: Hall of Fame | Better Victory Screen | Fluidic Power | Biter Power | Space Spidertron | Spidertron Dock | Weasel's Demolition Derby

SANCHERIZZO
Burner Inserter
Burner Inserter
Posts: 7
Joined: Tue Mar 19, 2024 10:41 pm
Contact:

Re: adding a property using table insert between se and mega furnace

Post by SANCHERIZZO »

i add recipe category for check running my addon and it`s working, but se_allow_in_space = true not working.

Code: Select all

if data.raw["assembling-machine"]["mega-furnace"] then
  data.raw["assembling-machine"]["mega-furnace"].se_allow_in_space = true,
  table.insert(data.raw['assembling-machine']['mega-furnace'].crafting_categories,'kiln')
else
  error("The code is running not as expected")
end
may be need dependency for se?

User avatar
Stringweasel
Filter Inserter
Filter Inserter
Posts: 319
Joined: Thu Apr 27, 2017 8:22 pm
Contact:

Re: adding a property using table insert between se and mega furnace

Post by Stringweasel »

SANCHERIZZO wrote:
Wed Mar 20, 2024 10:35 am
and it`s working
What do you mean? So did the code I provided crash? And you want it to crash, because that means the code was running. And once you verified that you can remove the `error(...)`.

Maybe a better clearer approach would be:

Code: Select all

log("[TEST] The code is running as expected")
if data.raw["assembling-machine"]["mega-furnace"] then
  log("[TEST] Found the entity prototype")
  data.raw["assembling-machine"]["mega-furnace"].se_allow_in_space = true
else
    log("[TEST] NOOO! COULD NOT FIND THE PROTOTYPE!")
end
You will find this log here https://wiki.factorio.com/Log_file
Alt-F4 Author | Factorio Modder
Mods: Hall of Fame | Better Victory Screen | Fluidic Power | Biter Power | Space Spidertron | Spidertron Dock | Weasel's Demolition Derby

SANCHERIZZO
Burner Inserter
Burner Inserter
Posts: 7
Joined: Tue Mar 19, 2024 10:41 pm
Contact:

Re: adding a property using table insert between se and mega furnace

Post by SANCHERIZZO »

i run you code, log

Code: Select all

8.247 Script @__5x slots__/data-final-fixes.lua:2: [TEST] The code is running as expected
8.247 Script @__5x slots__/data-final-fixes.lua:4: [TEST] Found the entity prototype
   

User avatar
Stringweasel
Filter Inserter
Filter Inserter
Posts: 319
Joined: Thu Apr 27, 2017 8:22 pm
Contact:

Re: adding a property using table insert between se and mega furnace

Post by Stringweasel »

In what file did you place your code? It could be that it's running after SE does it's space checks. Safest is to add a dependency to SE as you mentioned. But it could be you placed your code in `data-final-fixes.lua` whereas better place might be `data-updates.lua`.
Alt-F4 Author | Factorio Modder
Mods: Hall of Fame | Better Victory Screen | Fluidic Power | Biter Power | Space Spidertron | Spidertron Dock | Weasel's Demolition Derby

SANCHERIZZO
Burner Inserter
Burner Inserter
Posts: 7
Joined: Tue Mar 19, 2024 10:41 pm
Contact:

Re: adding a property using table insert between se and mega furnace

Post by SANCHERIZZO »

Yes. You are right. data updates needed. I have question for the future. Can i change loadorder mod? Or tell me please where i can read about this. Thank you very much Stringweasel :)

User avatar
Stringweasel
Filter Inserter
Filter Inserter
Posts: 319
Joined: Thu Apr 27, 2017 8:22 pm
Contact:

Re: adding a property using table insert between se and mega furnace

Post by Stringweasel »

Happy to help :)

The documentation here explains the load order. And you'll see there the only way you should change it is by adding dependencies on other mods.
Alt-F4 Author | Factorio Modder
Mods: Hall of Fame | Better Victory Screen | Fluidic Power | Biter Power | Space Spidertron | Spidertron Dock | Weasel's Demolition Derby

Post Reply

Return to “Modding help”