Factorio Standard Library

by Nexela

The Factorio Standard Library is a project to bring Factorio modders high-quality, commonly-required utilities and tools.

Internal
2 years ago
0.17 - 1.1
407K

i Update to Factorio 2.0

6 months ago
(updated 5 months ago)

Not sure if the mod author is still working on this, but for any of my mods that require this dependency, it should be safe to simply update it by unzipping the mod, editing info.json and updating the "factorio_version" to 2.0

I can't speak for any other mods that require this dependency, all of the functions my mods use did not need to be updated (or I modified them locally within my mod to not break anything)

5 months ago

not all features of stdlib end up working, sadly pickerdollie doesnt work with
"
stdlib/stdlib/event/event.lua:72: attempt to index field 'script' (a userdata value)
stack traceback:
stdlib/stdlib/event/event.lua:72: in main chunk
[C]: in function 'require'
PickerDollies/control.lua:4: in main chunk
"

if you just grab the old mod and change their json to load.

5 months ago

@Jey you must be using an older version of stdlib, line 72 in that file referenced is "end" which wouldn't throw that error.
Line 70 tries to index, so again, older version perhaps? It could totally still be broken, I hate LUA and all it stands for...

5 months ago
(updated 5 months ago)

I actually really like lua, but I also haven't programmed in any real languages, unless you count python (but even then, I haven't done that much in it). It's relatively simple to work with, aside from the lack of switch statements

5 months ago

i wouldnt be surprised, i used the version i had before dlc and i think it was updated like 20 months ago or so. i didnt mess around more than i had to, just opened the zip, changed the version in json and tried / got the error then gave up, i dont need picker dollies just yet :P. Im sure some similar mod will show up sooner than later.

Factorio modding community is just batshit insane lol.

5 months ago

@Jey you must be using an older version of stdlib, line 72 in that file referenced is "end" which wouldn't throw that error.
Line 70 tries to index, so again, older version perhaps? It could totally still be broken, I hate LUA and all it stands for...

he is on the correct line, I just debugged the thing (or at least I'm trying to, since I've never touched lua before)

for name in pairs(Event.script) do
        _G.script[name] = function()
            error('Detected attempt to register an event using script.' .. name .. ' while using the STDLIB event system ')
        end <- error in this line
    end

you can check out the code on gh -> https://github.com/Afforess/Factorio-Stdlib/blob/master/stdlib/event/event.lua

unfortunately I dont know how I could fix that, but I hope someone else does :D

5 months ago

I've actually begun making an attempt on updating this and the rest of the Picker mods to 2.0, and so far have actually been making some good progress. I fixed the error above by simply commenting out that entire for block (it doesn't appear to be critical for mod functionality, simply used for error checking and "script protection")

All of the other changes I've made so far are simply updating prototype references during control.lua to match the new format (from game.x_prototypes[object] to simply prototypes.x[object]), removing the "hidden" flags from all of the picker added tools, updating the picker tools to the new "select" format, and one check to ensure global variable exists before attempting to write to it.

So far, I've got Picker Extended working perfectly, except for the testing map (which I don't really know how to fix, but it doesn't crash unless you try to open it, so I'll probably just ignore it for now). Not sure if I should release them via OneDrive or Google Drive, or actually upload them to the mod portal as entirely new unofficial updates though. Don't know if I want the responsibility of all the other mods that depend on this one...

5 months ago
(updated 5 months ago)

Unofficial updates now available here (google drive link)

Folder includes stdlib, PickerAtheneum (required for PickerExtended), PickerExtended, and PickerDollies, and an updated version of Reverse Factory that works with the new stdlib (something I did broke my v9.0.0).

I have not extensively tested all functionality with these mods, but I know for sure the following features are working:

  • PickerExtended Screenshot tool, ore eraser, and tape measure
  • PickerExtended Ghost entity revival thing
  • PickerExtended Picker crafter
  • PickerExtended Quick swap between planners via hotkey
  • PickerDollies Moving of electric poles and circuit connected entities (and regular entities, from what I've tested)

I think that's a good enough start for now. If Nexela doesn't return by the end of the week, I'll just release a version of these directly to the mod portal and move all my dependencies to that instead.

5 months ago

thanks for your work. ill give it a whirl.

5 months ago
(updated 5 months ago)

not 100% sure if its the exact function that should be used, but was having problem pickerdollies not working once loading my save.

game.entity_prototypes[entity_name] no longer exists, replaced it with game.get_entity_by_tag(entity_name)

edit: seem to work as intended, trying to move a car does give the blacklist error.

also needed to add
"
if global then if global.blacklist_names then else create_global_blacklist() end else create_global_blacklist() end
"
to interface.lua line 68 (after interface["add_blacklist_name"] = function(entity_name)) to fix a crash on load.

5 months ago

Thanks for the work, many of us need this

5 months ago
(updated 5 months ago)

@Jey123456 Thanks for calling it out, it seems I missed a few references; I updated the game.entity_prototypes[entity_name] to prototypes.entity[entity_name] and it properly displays flying text "car does not support moving", which I assume is the intended result. I updated both PickerDollies and PickerAtheneum to swap out the instances of "_prototypes" that I didn't catch before.

Couple of things I have noticed while testing is that entities with multiple cables (for me it was a power switch with two copper connections and one red circuit connection) can be moved slightly farther than they should be allowed to (it might only be checking one of the connections for max distance, not checking all, but I'm not sure).

And oblong rotate function is also not currently working (that allows rotating pumps and combinators in more than 2 directions)

5 months ago

Nice work, quite a few mods still depend on stdlib, ran into the same issue with PickerDollies.

I currently didnt dig any deeper, but is _G a global table? and it seems that the structure has somewhat changed in 2.0?

5 months ago

Has anyone pushed a new version of this up to the mod library?

5 months ago
(updated 5 months ago)

There are currently two up-to-date versions of stdlib on the mod portal, mine and stdlib2 (as well as a third minimum effort version that has basically changed nothing but the name of the mod in all files to make it load)

stdlib2 is the more "official" project that actually has a github and multiple collaborators working on it (including a couple of my own edits), but hasn't actually released any of the more recent contributions, and the owner of that fork isn't particularly interested in maintaining the mod, so the version on the mod portal is still partially broken (most of the recipe functions and data:copy on recipes is not working)

My version of the stdlib was a bit more quick and dirty, and not the most professional (as I didn't use github for any of the changes), but it has basically all of the runtime changes that are currently in stdlib2, as well as fixed versions of all of the data/recipe functions (as well as some extra functions that I haven't committed to the stdlib2 project, since they aren't exactly critical for functionality)

If you need recipe functionality, your only option is my version atm, until stdlib2 releases another version (which may or may not happen, depending on the whims of the author). If you only need runtime fixes, stdlib2 should suffice (but I believe my version has the same fixes in place, and possibly more).

New response