There's part of code in my mod : https://pastebin.com/8j7sGeA4 (whole file : https://pastebin.com/Sw9V7nzk)
In this part of code I define technology and add it to game. But it is nowhere to be found, I just ... don't have it in game.
Here's log from game : https://pastebin.com/cWfQiLjR my mod loads (0.741), have no errors, it is enabled... I don't understand what is failing here.
What am I doing wrong? I'm pretty sure this exact mod worked, but I worked on it like half year ago, so few new versions of game came out.
I changed value of property : order = ~~~ to some other, so it is not exactly same as in vanilla techs, but it did nothing, I have no ideas on what can I try to do.
[Fixed] Adding data: to game
[Fixed] Adding data: to game
Last edited by Rafiz on Thu Dec 30, 2021 1:11 pm, edited 3 times in total.
Re: Adding technology to game
Typo!
data:extend(
{
recile_lube,
should be recipe_lube.
That's strange that nothing crashed. I guess data:extend just accepts nil and ends adding elements from table once it gots to nil. I would rather expect it to ... if not crash everything, then at least continue checking next elements.
Data:extend shouldn't be looping past array, until value under current index returns nil (IMO). It should rather just check # of elements in array and iterate over # elements. Maybe it does that, I don't know. It just looks as if it was "end-of-array being nil" based.
data:extend(
{
recile_lube,
should be recipe_lube.
That's strange that nothing crashed. I guess data:extend just accepts nil and ends adding elements from table once it gots to nil. I would rather expect it to ... if not crash everything, then at least continue checking next elements.
Data:extend shouldn't be looping past array, until value under current index returns nil (IMO). It should rather just check # of elements in array and iterate over # elements. Maybe it does that, I don't know. It just looks as if it was "end-of-array being nil" based.
Re: [Fixed] Adding data: to game
In Lua, nil entries in a table/array are simply not stored at all.
a=nil
tab={a}
Is the same as
tab={nil}
Is the same as
tab={}
In all cases #tab=0
The only time it matters is array spacing:
tab={nil,nil,nil,42}
Is the same as
tab={[4]=42}
And #tab=4 but table_size(tab)=1 (iirc)
a=nil
tab={a}
Is the same as
tab={nil}
Is the same as
tab={}
In all cases #tab=0
The only time it matters is array spacing:
tab={nil,nil,nil,42}
Is the same as
tab={[4]=42}
And #tab=4 but table_size(tab)=1 (iirc)
My mods: Multiple Unit Train Control, RGB Pipes, Shipping Containers, Rocket Log, Smart Artillery Wagons.
Maintainer of Auto Deconstruct, Cargo Ships, Vehicle Wagon, Honk, Shortwave.
Maintainer of Auto Deconstruct, Cargo Ships, Vehicle Wagon, Honk, Shortwave.
-
- Smart Inserter
- Posts: 2767
- Joined: Tue Apr 25, 2017 2:01 pm
- Contact:
Re: [Fixed] Adding data: to game
Well, that’s the thing the OP was confused about in their 2nd post.
If I’m following that post correctly, they were essentially entering this:
data:extend({nil, dat2, dat3, …})
And the game wasn’t inputting any of it.
My Mods: Classic Factorio Basic Oil Processing | Sulfur Production from Oils | Wood to Oil Processing | Infinite Resources - Normal Yield | Tree Saplings (Redux) | Alien Biomes Tweaked | Restrictions on Artificial Tiles | New Gear Girl & HR Graphics
Re: [Fixed] Adding data: to game
Probably because of how array's are handled in LUA and where certain functions consider their end to be.
So in this case, data:extend expects an array, finds the first entry to be nil, and thus treats the array as if it were empty. data:extend uses ipairs to iterate the data given to it, per the code at https://github.com/wube/factorio-data/b ... loader.lua . There's also a check that the table isn't empty, but since that uses the # operator I believe it's missing this case - the table isn't empty, it's just not being fully iterated over.LUA documentation wrote:The basic Lua library provides ipairs, a handy function that allows you to iterate over the elements of an array, following the convention that the array ends at its first nil element.