Page 2 of 3

Re: [0.12-0.13] [Library]Factorio Standard Library Project 0.5.0

Posted: Tue Jun 28, 2016 11:16 pm
by Afforess
For interested modders, The Factorio Standard Library is fully compatible with both Factorio 0.12 and 0.13 with no changes. All existing versions are fully compatible.

Future releases after 0.5 will likely no longer be fully compatible with Factorio 0.12.

Re: [0.12-0.13] [Library]Factorio Standard Library Project 0.5.1

Posted: Mon Jul 04, 2016 9:27 pm
by Afforess
New Release, contains a single bug fix:
  • Version 0.5.1 (No Breaking Changes)
    • Fixed Event registry not notifying of an error in an event handler when the game was loaded, but no players were connected to the game
    • Note: Thanks to mojo2012 for the bug report

Re: [0.12-0.13] [Library]Factorio Standard Library Project 0.5.1

Posted: Thu Jul 21, 2016 9:50 am
by kiba
Your standard library's logging tool saved my butt. Thank you. :D

I still haven't learned the rest of your library yet, but it will do for now.

Re: [0.12-0.13] [Library]Factorio Standard Library Project 0.5.1

Posted: Fri Jul 22, 2016 2:49 am
by Afforess
kiba wrote:Your standard library's logging tool saved my butt. Thank you. :D

I still haven't learned the rest of your library yet, but it will do for now.
Glad you found it useful! Check out the index of the docs sometimes, it's very easy to use all of the modules: http://afforess.github.io/Factorio-Stdlib/index.html

Re: [0.12-0.13] [Library]Factorio Standard Library Project 0.5.1

Posted: Fri Jul 22, 2016 4:13 am
by Nexela
Btw, a typo in the log.lua file is driving me nuts every time I see it. It really needs a period or some other form of punctuation after "Creates a new logger object". The way it reads now is you create the logger in debug mode.

Code: Select all

Creates a new logger object In debug mode, the logger writes immediately. Otherwise it buffers lines. Logger flushes after 60 seconds has elapsed since the last message.
to

Code: Select all

Creates a new logger object. In debug mode, the logger writes immediately. Otherwise it buffers lines. Logger flushes after 60 seconds has elapsed since the last message.

Re: [0.12-0.13] [Library]Factorio Standard Library Project 0.5.1

Posted: Sat Jul 23, 2016 12:19 am
by Afforess
Nexela wrote:Btw, a typo in the log.lua file is driving me nuts every time I see it. It really needs a period or some other form of punctuation after "Creates a new logger object". The way it reads now is you create the logger in debug mode.

Code: Select all

Creates a new logger object In debug mode, the logger writes immediately. Otherwise it buffers lines. Logger flushes after 60 seconds has elapsed since the last message.
to

Code: Select all

Creates a new logger object. In debug mode, the logger writes immediately. Otherwise it buffers lines. Logger flushes after 60 seconds has elapsed since the last message.
Fascinating, an interesting result of the way the doc generator works. In the code, it looked correct:

Code: Select all

--- Creates a new logger object
-- In debug mode, the logger writes immediately. Otherwise it buffers lines.
At any rate, fixed. :)

Re: [0.12-0.13] [Library]Factorio Standard Library Project 0.6.0

Posted: Sun Jul 31, 2016 5:54 pm
by Afforess
Factorio Standard Library 0.6.0 has been released, with a ton of changes and several new contributors! Special thanks to credomane on his work for the GUI event system!

For the release, and the full changelog: https://github.com/Afforess/Factorio-St ... /tag/0.6.0

Re: [0.12-0.13] [Library]Factorio Standard Library Project 0.6.0

Posted: Sun Jul 31, 2016 8:48 pm
by Nexela
Added Tile.adjacent, given a tile, returns a list of adjacent tile positions (N, E, S, W) or (N, NE, E, SE, S, SW, W, NW), depending if diagonal tiles are specified.
Awesome!

Re: [0.12-0.13] [Library]Factorio Standard Library Project 0.6.0

Posted: Fri Aug 05, 2016 1:50 pm
by safan
Hello, interesting initiative.
I have a suggestion, since i'm struggling with the gui to make my mod.
Can you make something for creating a button that can open and close a new window. I'm trying to do this without knowing any program skills and it just won't work. It could also be used to update the advanced logistic network mod and others.

Re: [0.12-0.13] [Library]Factorio Standard Library Project 0.6.0

Posted: Thu Aug 25, 2016 7:05 pm
by kiba
Anybody making use of the GUI elements? I feel it's hard to figure out things if I don't have example codes to examine.

Here's some test code that seems to be not working?

Code: Select all


function test()
  print("test")
end

Gui.Event.register (defines.events.on_player_armor_inventory_changed, "top", test)
Looking through the stdlib's source code, I am not clear on how the game check for events being pinged? Though Gui.Event.dispatch?

Re: [0.12-0.13] [Library]Factorio Standard Library Project 0.6.0

Posted: Tue Sep 13, 2016 9:05 pm
by ssilk
I have looked into this code (great code, really well programmed!) and have a question about the epsilon, that is used to determine for example, if two float-number are zero. (for example Area/Position).

I thought (and it's my current opinion), that Factorio uses fixed floating point numbers (8 bits). Which means in general, one tile has up to 256 positions in X and Y direction. That is a much lesser accuracy than lua floating point.

Well, I haven't calculated anything through, it's just a thought. :)

Re: [0.12-0.13] [Library]Factorio Standard Library Project 0.6.0

Posted: Thu Sep 22, 2016 9:22 pm
by Afforess
ssilk wrote:I have looked into this code (great code, really well programmed!) and have a question about the epsilon, that is used to determine for example, if two float-number are zero. (for example Area/Position).

I thought (and it's my current opinion), that Factorio uses fixed floating point numbers (8 bits). Which means in general, one tile has up to 256 positions in X and Y direction. That is a much lesser accuracy than lua floating point.

Well, I haven't calculated anything through, it's just a thought. :)
Fixed floating points may be used in the engine itself (I have no way of knowing myself), but I am fairly certain that when these "fixed" are shared with the lua environment, they become the standard IEEE floating point values. I distinctly remember encountering hairy positions, such as 0.4999999999999 in the wild.

I think its probably best to err in the side of caution in the epsilon, however it's a variable, so theoretically anyone can change it to whatever their favorite magic number is. :)
kiba wrote:Anybody making use of the GUI elements? I feel it's hard to figure out things if I don't have example codes to examine.

Here's some test code that seems to be not working?

Code: Select all


function test()
  print("test")
end

Gui.Event.register (defines.events.on_player_armor_inventory_changed, "top", test)
Looking through the stdlib's source code, I am not clear on how the game check for events being pinged? Though Gui.Event.dispatch?
Sorry about the slow response. Use of the specific handlers, like Gui.on_click, Gui.on_checked_state_changed, or Gui.on_text_changed. The first argument is a regular expression that will match the name(s) of elements, and the second argument is the handler. So...

Code: Select all

Gui.on_click("my_cool_gui_element_name", function(event)
   .. 
  do something cool here
end)

Re: [0.12-0.14] [Library]Factorio Standard Library Project 0.6.0

Posted: Thu Sep 22, 2016 9:37 pm
by Afforess
As a belated followup notice, I can attest to there being no significant API changes in 0.14 that affect the Factorio Standard Library Project, and it remains compatible with all mods between 0.12.X and 0.14.X. Notice will be provided if the range of versions compatible changes in the future.

Re: [0.12-0.14] [Library]Factorio Standard Library Project 0.6.0

Posted: Thu Sep 22, 2016 9:39 pm
by Supercheese
Afforess wrote:As a belated followup notice, I can attest to there being no significant API changes in 0.14 that affect the Factorio Standard Library Project, and it remains compatible with all mods between 0.12.X and 0.14.X. Notice will be provided if the range of versions compatible changes in the future.
Well, with the exception that print-force, print-surface, and print-all are now integrated into the base game, so there's no longer a need for the StdLib versions. ;)

Re: [0.12-0.14] [Library]Factorio Standard Library Project 0.6.0

Posted: Thu Sep 22, 2016 9:56 pm
by Afforess
Supercheese wrote:
Afforess wrote:As a belated followup notice, I can attest to there being no significant API changes in 0.14 that affect the Factorio Standard Library Project, and it remains compatible with all mods between 0.12.X and 0.14.X. Notice will be provided if the range of versions compatible changes in the future.
Well, with the exception that print-force, print-surface, and print-all are now integrated into the base game, so there's no longer a need for the StdLib versions. ;)
Well, that's a good point. I'll add a deprecation notice there. That's the second API change that has obsoleted stdlib code, and the more the merrier.

[0.12-0.14] [Library]Factorio Standard Library Project 0.7.0

Posted: Fri Sep 30, 2016 11:27 pm
by Afforess
The Factorio Standard Library 0.7.0 is released, with a number of additions:

Version 0.7.0 (No Breaking Changes)
  • Fixed documentation for Entity.to_collision_area
  • Fixed documentation for Area.to_table
  • Changed Game.print_all to print to offline players (fixes https://github.com/Afforess/Factorio-Stdlib/issues/49)
  • Deprecated Game.print_force (use force.print instead)
  • Deprecated Game.print_surface (use surface.print instead)
  • Deprecated Area.area, due to misleading name. (use Area.size instead)
  • Added Area.adjust, modifies area to ensure x,y coordinate values are normalized
  • Added Area.construct, creates an area from two pairs of x,y coordinates
  • Added Area.size, replaces the deprecated function, Area.area.
  • Added Position.copy, creates a copy of a position
  • Added Position.construct, creates a position from an x,y pair
  • Added table.find, searches a table for the first element that matches the function
  • Added table.any, searches a table and returns true if any elements matches the function
  • Added Trains module, providing train utility methods and events:
    • Added Trains.set_data, sets persistent mod data on a train
    • Added Trains.get_data, gets mod data on a train
    • Added Trains.on_train_id_changed event, contains the old and new id of the train, and fires when a train id changes (e.g. locomotives are added to an existing train)
    • Added Trains.find_filtered, searches and returns a table of trains on surface(s) for trains that match the area, name, or state criteria
    • Added Trains.get_train_id, returns the train id of a train
    • Added Trains.get_main_locomotive, finds and returns the main locomotive entity of any train
  • Added Time-based events, require 'stdlib/event/time' to enable them, then register the events to script them.
    • Event.Time.sunset, fires an event when sunset occurs for a surface
    • Event.Time.sunrise, fires an event when sunrise occurs for a surface
    • Event.Time.midday, fires an event noon occurs for a surface
    • Event.Time.midnight, fires an event when midnight occurs for a surface
    • Event.Time.minutely, fires an event when an in-game minute passes
    • Event.Time.hourly, fires an event when an in-game hour passes
    • Event.Time.daily, fires an event when an in-game day passes
  • Added Config system, for easier management of persistent mod configuration
    • Added Config.new, ex: Config.new(global.config) creates a new configuration, stored at global.config
    • Added config.set, allows setting a value at nested paths, ex: (Config.new(global.config).set("your.path.here", foo)
    • Added config.get, allows getting nested values, ex: (Config.new(global.config).get("your.path.here")
    • Added config.delete, deletes a value at a config path, ex: (Config.new(global.config).delete("your.path.here")
    • Added config.is_set, tests whether a config value is set or not, ex: (Config.new(global.config).is_set("your.path.here")
  • Added a GUI event handler system. Multiple handlers for each event can be registered, using regex patterns to match element names.
Note: Thanks to Andy Hunt, Alex Aulbach, and credomane for their contributions to 0.7.0!

Re: [0.12-0.14] [Library]Factorio Standard Library Project 0.7.0

Posted: Sat Oct 01, 2016 8:47 am
by ssilk
BTW: Alex Aulbach is me. :)

Re: [0.12-0.14] [Library]Factorio Standard Library Project 0.7.0

Posted: Sat Oct 01, 2016 5:00 pm
by Afforess
ssilk wrote:BTW: Alex Aulbach is me. :)
Cool! :D

Re: [0.12-0.14] [Library]Factorio Standard Library Project 0.7.0

Posted: Thu Nov 03, 2016 5:18 pm
by lettherebelight
Found a documentation bug on http://afforess.github.io/Factorio-Stdl ... rface.html. The example for find_all_entities says final_all_entities instead.

Re: [0.12-0.14] [Library]Factorio Standard Library Project 0.7.0

Posted: Thu Nov 03, 2016 6:10 pm
by Afforess
lettherebelight wrote:Found a documentation bug on http://afforess.github.io/Factorio-Stdl ... rface.html. The example for find_all_entities says final_all_entities instead.
Nice find! I've updated the documentation and fixed the typo.