Page 3 of 3

Re: [0.13-0.14] [Library]Factorio Standard Library Project 0.8.0

Posted: Thu Jan 12, 2017 4:04 am
by Afforess
The Factorio Standard Library 0.8.0 is released, with a number of additions and improvements:

Version 0.8.0 (No Breaking Changes)
  • Fixed loading error when train module was loaded before the game object existed
  • Fixed Trains.on_train_id_changed event not firing correctly
  • Deprecated Area.adjust, due to misleading name. (use Area.normalize instead)
  • Changed Surface.find_all_entities to support area search criteria
  • Changed Inventory.copy_inventory to support itemstacks with durability, health or ammo
  • Changed Trains.find_filtered to support the entity type in the search criteria. Defaults to 'locomotive'
  • Changed Entity.set_data/Entity.get_data to use a unit's unit_number as a key for data, enhancing performance for entities who have unit_numbers
  • Added Entity.set_industructible, toggles an entity so that it can not be damaged or mined by either the player or other forces
  • Added Entity.set_frozen, toggles an entity as inactive, making it inoperable and non-rotatable
  • Added Surface.get_surface_bounds, creates an area that represents the generated boundaries of a surface
  • Note: Thanks to Andy Hunt, Alex Aulbach, and Nexela for their contributions to 0.8.0!
Also note: The Factorio Standard Library 0.8.0 now requires Factorio 0.13.11+, 0.14.x or higher. Support for Factorio 0.12 has dropped. If for some reason, you need to support Factorio 0.12, stick with 0.7 or older releases. ;)

Re: [0.13-0.14] [Library]Factorio Standard Library Project 0.8.0

Posted: Wed Feb 08, 2017 12:29 pm
by RalleYTN
Is this still up to date and maintained? If yes, do you mind if I use this as built in extra libraries, for the tool I'm making right now?
Link in my signature.

Re: [0.13-0.14] [Library]Factorio Standard Library Project 0.8.0

Posted: Sat Feb 11, 2017 5:25 am
by Afforess
RalleYTN wrote:Is this still up to date and maintained? If yes, do you mind if I use this as built in extra libraries, for the tool I'm making right now?
Link in my signature.
Yes it is. We encourage all mod developers to use stdlib in their projects wherever it is useful. Feel free to use it for tools and other libraries as well.

The project isn't terribly active because most of the features are complete and frequent releases aren't necessary. Factorio Stdlib is compatible with 0.13-0.14, and I plan on supporting 0.15 and later future versions as needed as well.

Re: [0.13-0.14] [Library]Factorio Standard Library Project 0.8.0

Posted: Sat Feb 11, 2017 9:29 am
by RalleYTN
Afforess wrote:
RalleYTN wrote:Is this still up to date and maintained? If yes, do you mind if I use this as built in extra libraries, for the tool I'm making right now?
Link in my signature.
Yes it is. We encourage all mod developers to use stdlib in their projects wherever it is useful. Feel free to use it for tools and other libraries as well.

The project isn't terribly active because most of the features are complete and frequent releases aren't necessary. Factorio Stdlib is compatible with 0.13-0.14, and I plan on supporting 0.15 and later future versions as needed as well.
Is it too much if I would ask you to create a JSON file and include it in your project?
viewtopic.php?f=135&t=40830#p242179
with this format. it just so your library would have auto-completion(and error highlighting) in my tool.
:)

Re: [0.13-0.14] [Library]Factorio Standard Library Project 0.8.0

Posted: Wed Feb 15, 2017 2:15 pm
by Afforess
RalleYTN wrote:
Afforess wrote:
RalleYTN wrote:Is this still up to date and maintained? If yes, do you mind if I use this as built in extra libraries, for the tool I'm making right now?
Link in my signature.
Yes it is. We encourage all mod developers to use stdlib in their projects wherever it is useful. Feel free to use it for tools and other libraries as well.

The project isn't terribly active because most of the features are complete and frequent releases aren't necessary. Factorio Stdlib is compatible with 0.13-0.14, and I plan on supporting 0.15 and later future versions as needed as well.
Is it too much if I would ask you to create a JSON file and include it in your project?
viewtopic.php?f=135&t=40830#p242179
with this format. it just so your library would have auto-completion(and error highlighting) in my tool.
:)
Do you have a tool to auto-generate the json for autocompletion? I'd like to automate the process, rather than manually creating a file that describes the entire API.

Re: [0.13-0.14] [Library]Factorio Standard Library Project 0.8.0

Posted: Wed Feb 15, 2017 3:22 pm
by RalleYTN
Afforess wrote:
RalleYTN wrote:
Afforess wrote:
RalleYTN wrote:Is this still up to date and maintained? If yes, do you mind if I use this as built in extra libraries, for the tool I'm making right now?
Link in my signature.
Yes it is. We encourage all mod developers to use stdlib in their projects wherever it is useful. Feel free to use it for tools and other libraries as well.

The project isn't terribly active because most of the features are complete and frequent releases aren't necessary. Factorio Stdlib is compatible with 0.13-0.14, and I plan on supporting 0.15 and later future versions as needed as well.
Is it too much if I would ask you to create a JSON file and include it in your project?
viewtopic.php?f=135&t=40830#p242179
with this format. it just so your library would have auto-completion(and error highlighting) in my tool.
:)
Do you have a tool to auto-generate the json for autocompletion? I'd like to automate the process, rather than manually creating a file that describes the entire API.
sadly no. but I can write one today and upload it here.

EDIT: but you would still have to type all the stuff manually.

Re: [0.13-0.15] [Library]Factorio Standard Library Project 0.8.0

Posted: Thu Apr 27, 2017 11:29 pm
by Afforess
As an FYI for concerned modders, early testing has not revealed any compatability issues with the current release of the standard library and Factorio 0.15. You should be able to continue to use the current release of 0.8.0 safely with Factorio 0.15.

Work on the next release with a number of bug fixes and improvements is proceeding.

Re: [0.13-0.15] [Library]Factorio Standard Library Project 0.8.0

Posted: Thu Apr 27, 2017 11:58 pm
by Nexela
Havn't reported it yet, but I believe stdlib/time is still using game.raise_event (should be using script.raise_event) other than that I have not come across any issues

Re: [0.13-0.15] [Library]Factorio Standard Library Project 0.8.0

Posted: Fri Apr 28, 2017 12:05 am
by Afforess
Nexela wrote:Havn't reported it yet, but I believe stdlib/time is still using game.raise_event (should be using script.raise_event) other than that I have not come across any issues
Yeah I have already fixed that in the repository.

Re: [0.13-0.15] [Library]Factorio Standard Library Project 0.8.0

Posted: Tue Feb 13, 2018 2:11 am
by golfmiketango
Looks like they disabled _G.require in callbacks, breaking the console module. (And my heart, since I really wanted to do lazy loading :cry:)

Re: [0.13-0.15] [Library]Factorio Standard Library Project 0.8.0

Posted: Wed Feb 14, 2018 12:57 am
by golfmiketango
I have an stdlib question. If I wanted to hack on stdlib -- or just consume it in a fairly invasive way -- which branch of your git repo would you recommend I use as my upstream as of now (20180213)? For now I'm on top of data-library since I know whenever I call something "wip" in my own development it effectively means "broken." :)

Re: [0.13-0.15] [Library]Factorio Standard Library Project 0.8.0

Posted: Wed Feb 14, 2018 4:47 am
by Nexela
Data-library is the currently in development branch and is very much wip and data-library-wip is/was the OMG I am breaking things every time I type branch. (Actually I only did this branch because symlinks and I didn't want to update a bunch of mods until I was mostly done with it)

Most data-library branch changes will be backwards compatible with master (except for today where I said screw it and local'ed all the things. So with the exception of Event/Gui local whatever = require("stdlib.modname") is pretty much mandatory).

As for console stuff, that should be working just fine (the example usage was incorrect). Also nothing is loaded into globals by default but I did add a script you can run to add everything to all caps globals for use in console

local console = require("stdlib/utils/scripts/console")
require("stdlib/utils/scripts/load_globals")() --yes don't forget the ()
remote.add_interface("my-interface", {console = console})

in console,
local a = AREA(-1,-1,1,1):size();game.print(a)

Re: [0.13-0.15] [Library]Factorio Standard Library Project 0.8.0

Posted: Wed Feb 14, 2018 5:10 am
by golfmiketango
Nexela wrote:Data-library is the currently in development branch and is very much wip and data-library-wip is/was the OMG I am breaking things every time I type branch. (Actually I only did this branch because symlinks and I didn't want to update a bunch of mods until I was mostly done with it)
ACK, comports with my assumptions, thanks :)
Nexela wrote: Most data-library branch changes will be backwards compatible with master (except for today where I said screw it and local'ed all the things. So with the exception of Event/Gui local whatever = require("stdlib.modname") is pretty much mandatory).

As for console stuff, that should be working just fine (the example usage was incorrect).
Aaah, now I get it... didn't figure that out from our github discussion on this.
Nexela wrote: require("stdlib/utils/scripts/load_globals")() --yes don't forget the ()
I see what you did there :). This is a great non-feature of the luas. I know you didn't ask but I approve.

Re: [0.13-0.15] [Library]Factorio Standard Library Project 0.8.0

Posted: Thu Feb 15, 2018 5:21 am
by golfmiketango
Nexela wrote: Most data-library branch changes will be backwards compatible with master (except for today where I said screw it and local'ed all the things. So with the exception of Event/Gui local whatever = require("stdlib.modname") is pretty much mandatory).

As for console stuff, that should be working just fine (the example usage was incorrect).
Hm... well I have been playing with this again but I'm still completely striking out (in the data-library branch).

A few things seem to be going on.

First, the console, event and gui modules appear to be in some kind of load-ordering gordian knot that I can't seem to unravel. I'm pretty sure the remaining Event.Gui reference in Gui.register is just a missed substitution from commit 536e9a77. So, OK, I change that. Even still things seem to be load-order sensitive. It's kind of like those modules are mad at me for using, i.e., local Gui = require('stdlib/event/gui') because it hides globals they wind up expecting to be floating around. This may have to do with the recent "local all the things" tip commit in the branch.

The end result is the same as before. I can bring up the console gui but the event code associated with the buttons does not fire when I press them.

To me it seems like Gui is doing it all wrong. It takes over the global handler for the events its interested in (but only if Event doesn't already consume them), and jams its own non-Event-registry-format entries into that the Event registry, relying on I'm-not-exactly-sure-what-but-probably-some-kind-of-subtle-side-effect to avoid breaking the primary Event dispatcher, meaning there is a 2x2 matrix of possible outcomes: events dispatched solely by Event or Gui in one dimension, and event-handler-registry entries in standard Event format or extended Gui format. All apparently must all be supported which seems pretty cray cray.

Why doesn't Gui just consume the conveniently multiplexable Event API like any other consumer, and handle them with it's own secondary dispatcher, using a private event_id={ pattern_spec = { <array of handlers> } } } registry to dispatch to tertiary listeners? Are we worried about the performance impact of hierarchical dispatch? That's the wrong place to get all optimiz-ey imo, it's just creating a muddle.

Maybe I'm missing some important reason for it to be this way?

Re: [0.13-0.15] [Library]Factorio Standard Library Project 0.8.0

Posted: Thu Feb 15, 2018 11:10 am
by golfmiketango
Squished that little fucker.

It was, to say the least, not a monster bug with tendrils deep in the bowels of stdlilb :roll:

https://github.com/Afforess/Factorio-Stdlib/pull/112

Re: [0.13-0.15] [Library]Factorio Standard Library Project 0.8.0

Posted: Wed May 02, 2018 3:29 pm
by TRauMa
Hey, I see there's quite some active development on this, but no release for some time now. Right now the parts I'm interested in (table and string helpers) are of course usable, but still, I'd feel much better using a somewhat recent release instead of a git checkout. :)

Re: [0.13-0.15] [Library]Factorio Standard Library Project 0.8.0

Posted: Thu Jun 07, 2018 10:44 pm
by golfmiketango
TRauMa wrote:Hey, I see there's quite some active development on this, but no release for some time now. Right now the parts I'm interested in (table and string helpers) are of course usable, but still, I'd feel much better using a somewhat recent release instead of a git checkout. :)
Hey, sorry for the extended radio silence, I keep returning to a mental note to answer this question but not actually doing so :). Nexela has been plugging away with lots of backward-compatibility breaking ideas and, since I didn't like the event demultiplexing implementation, I've been hard at work in collaboration with him on a much more robust / elegant reimplementation of the event system. Between the two of us we've made a bit of a mess of the test suite and some other things. Everything is moving forward but it's taking a while, mostly due to paying bills and life and stuff.

We may be suffering a bit from poorly defined versioning objectives. At some point some decision to fork off a pre-stable-next type of branch where we get everything in order without any more adventures in aggressive refactoring or new features may be required to break a possible eternal bikeshed/break-stuff/fix-it cycle... not sure of timeline, I've been meaning to talk to Nexela about that and finish up the event demux work (it's "almost" done :)) but ..... clearly more work needs to be done, either fixing/documenting or making and implementing a decision about stable/unstable changes, before we unleash the bleeding edge code-base on unsuspecting users.

That stated, please feel free to grab nexela's or my (github:gmt) branches and "see what happens." They are believed to mostly work. If you have problems, send patches or file issues and we'll see what we can do. If you don't feel like getting mixed up in bug fixing, then the stable branch is probably the place to stay for now.

Re: [0.13-0.15] [Library]Factorio Standard Library Project 0.8.0

Posted: Fri Jun 08, 2018 2:44 am
by Nexela
True Story!!!!!!

Release is ... stable
Master is mostly stable
The In Dev stuff (data-library branch) is Bleeding edge! However it is not fully backwards compatible.
And the hard part is actually getting time to do anything to finish

We will probably put heads together and work on getting out a new release since most of the non data stage stuff is in a good spot.

Re: [0.13-0.15] [Library]Factorio Standard Library Project 0.8.0

Posted: Thu May 30, 2019 4:17 pm
by TheSAguy
Nexela wrote:
Fri Jun 08, 2018 2:44 am
True Story!!!!!!

Release is ... stable
Master is mostly stable
The In Dev stuff (data-library branch) is Bleeding edge! However it is not fully backwards compatible.
And the hard part is actually getting time to do anything to finish

We will probably put heads together and work on getting out a new release since most of the non data stage stuff is in a good spot.
Hey Nexela,
I could not find a recent Factorio Standard Library furm posting.
I see you're still maintaining the code - Thanks!

I'm currently using some of this code for event handling. "on_tick", but would like to switch to "on_nth_tick"
My current code is:

Code: Select all

Event.register(defines.events.on_tick, function(event)
	
	if (game.tick % (60 * 6) == 0) then 
		local surface = game.surfaces[1]
		local tick = event.tick
		processWorld(surface, tick) 
	end
	
end)
I'd like to convert this to "on_nth_tick", but still use the Standard Library code:
So how do I convert the below?

Code: Select all

script.on_nth_tick(38, function(event)	
	
	local surface = game.surfaces[1]
	local tick = event.tick
	processWorld(surface, tick) 
	
end)
Can you please help me out, or point me in the right direction.

Thanks.

Re: [0.13-0.15] [Library]Factorio Standard Library Project 0.8.0

Posted: Sat Jun 01, 2019 4:25 am
by Nexela
Use negative numbers!

Code: Select all

Event.register(-32, function(e)
  game.print('every 32nd tick')
  end