Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2 0 fixes #165

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion changelog.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
---------------------------------------------------------------------------------------------------
Version: 1.4.9
Version: 2.0.0
Date: ????
Changes:
- Factorio 2.0 compatible
---------------------------------------------------------------------------------------------------
Version: 1.4.8
Date: 2022-11-27
Expand Down
2 changes: 1 addition & 1 deletion doc/examples/event.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
-- Require the event module
local Event = require('__stdlib__/stdlib/event/event')
local Event = require('__stdlib2__/stdlib/event/event')

-- Register our hotkeys

Expand Down
12 changes: 6 additions & 6 deletions info.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
{
"name": "stdlib",
"version": "1.4.9",
"factorio_version": "1.1",
"title": "Factorio Standard Library",
"name": "stdlib2",
"version": "2.0.1",
"factorio_version": "2.0",
"title": "Factorio Standard Library 2.0",
"author": "Afforess",
"contact": "",
"dependencies": [
"base >= 1.1.0"
"base >= 2.0.0"
],
"homepage": "https://github.com/Afforess/Factorio-Stdlib",
"description": "The Factorio Standard Library is a project to bring Factorio modders high-quality, commonly-required utilities and tools.",
"description": "The Factorio Standard Library is a project to bring Factorio modders high-quality, commonly-required utilities and tools. Reupload with 2.0 fixes.",
"package": {
"ignore": [
"wiki/**",
Expand Down
4 changes: 2 additions & 2 deletions spec/area/area_spec.lua
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
require('spec/setup/busted')()

local Area = require('__stdlib__/stdlib/area/area')
local Area = require('__stdlib2__/stdlib/area/area')
local A = Area
local P = require('__stdlib__/stdlib/area/position')
local P = require('__stdlib2__/stdlib/area/position')
local rs = rawtostring

describe('Area', function ()
Expand Down
4 changes: 2 additions & 2 deletions spec/area/chunk_spec.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require('spec/setup/busted')()

local Chunk = require('__stdlib__/stdlib/area/chunk')
local Chunk = require('__stdlib2__/stdlib/area/chunk')
local C = Chunk

describe('Chunk Spec', function()
Expand All @@ -20,7 +20,7 @@ describe('Chunk Spec', function()
end)

it('should verify getting and setting data', function()
_G.global = {}
_G.storage = {}
_G.game = { surfaces = { nauvis = { index = 1, __self = 'userdata', valid = true } } }

local chunk_pos = { x = 4, y = -6 }
Expand Down
2 changes: 1 addition & 1 deletion spec/area/direction_spec.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require('spec/setup/busted')()

local Direction = require('__stdlib__/stdlib/area/direction')
local Direction = require('__stdlib2__/stdlib/area/direction')

describe('Direction Functions', function()
local d = defines.direction
Expand Down
2 changes: 1 addition & 1 deletion spec/area/position_spec.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require('spec/setup/busted')()

local Position = require('__stdlib__/stdlib/area/position')
local Position = require('__stdlib2__/stdlib/area/position')
local P = Position

describe('Position', function ()
Expand Down
2 changes: 1 addition & 1 deletion spec/area/surface_spec.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require('spec/setup/busted')()

local Surface = require('__stdlib__/stdlib/area/surface')
local Surface = require('__stdlib2__/stdlib/area/surface')

describe('Surface Spec', function()
describe('Surface lookups', function()
Expand Down
4 changes: 2 additions & 2 deletions spec/area/tile_spec.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require('spec/setup/busted')()

local Tile = require('__stdlib__/stdlib/area/tile')
local Tile = require('__stdlib2__/stdlib/area/tile')

describe('Tile Spec', function()
it('should give the correct tile coordinates for a position', function()
Expand Down Expand Up @@ -34,7 +34,7 @@ describe('Tile Spec', function()
end)

it('should verify getting and setting data', function()
_G.global = {}
_G.storage = {}
_G.game = { surfaces = { nauvis = { index = 1, __self = 'userdata', valid = true } } }

local tile_pos = { x = 4, y = -6 }
Expand Down
2 changes: 1 addition & 1 deletion spec/core_spec.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require('spec/setup/busted')()

local Core = require('__stdlib__/stdlib/core') --luacheck: ignore
local Core = require('__stdlib2__/stdlib/core') --luacheck: ignore

describe('Core',
function()
Expand Down
2 changes: 1 addition & 1 deletion spec/data/data_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ describe('Data', function()

before_each(function()
require('faketorio/dataloader')
Data = require('__stdlib__/stdlib/data/data')
Data = require('__stdlib2__/stdlib/data/data')
Raw = _G["data"].raw["recipe"]
R = Data("stone-furnace", "recipe")
F = Data("fake", "fake")
Expand Down
4 changes: 2 additions & 2 deletions spec/data/recipe_spec.lua
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
require('spec/setup/busted')()

local Recipe, Raw, Rawtech
local table = require('__stdlib__/stdlib/utils/table')
local table = require('__stdlib2__/stdlib/utils/table')

describe('Recipe', function()

before_each(function()
require('faketorio/dataloader')
Recipe = require('__stdlib__/stdlib/data/recipe')
Recipe = require('__stdlib2__/stdlib/data/recipe')
Raw = _G["data"].raw["recipe"]
Rawtech = _G["data"].raw["technology"]["steel-processing"]
end)
Expand Down
2 changes: 1 addition & 1 deletion spec/data/technology_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ describe(
before_each(
function()
require('faketorio/dataloader')
Technology = require('__stdlib__/stdlib/data/technology')
Technology = require('__stdlib2__/stdlib/data/technology')
end
)

Expand Down
8 changes: 4 additions & 4 deletions spec/entity/entity_spec.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require('spec/setup/busted')()

local Entity = require('__stdlib__/stdlib/entity/entity')
local Entity = require('__stdlib2__/stdlib/entity/entity')

describe('Entity', function()
it('an entity should be frozen', function()
Expand Down Expand Up @@ -53,7 +53,7 @@ describe('Entity', function()
end)

it('should verify getting and setting data', function()
_G['global'] = {}
_G['storage'] = {}
local entity = { name = 'fast-inserter', valid = true }
assert.is_nil(Entity.get_data(entity))

Expand All @@ -76,7 +76,7 @@ describe('Entity', function()
end)

it('should verify getting and setting data with unit_numbers', function()
_G['global'] = {}
_G['storage'] = {}
local entity = { name = 'fast-inserter', valid = true, unit_number = 13}
assert.is_nil(Entity.get_data(entity))

Expand Down Expand Up @@ -104,7 +104,7 @@ describe('Entity', function()
end)

it('should verify data can be deleted', function()
_G['global'] = {}
_G['storage'] = {}
local entity = { name = 'fast-inserter', valid = true }
assert.is_nil(Entity.get_data(entity))

Expand Down
4 changes: 2 additions & 2 deletions spec/entity/inventory_spec.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require('spec/setup/busted')()

local Inventory = require('__stdlib__/stdlib/entity/inventory')
local table = require('__stdlib__/stdlib/utils/table')
local Inventory = require('__stdlib2__/stdlib/entity/inventory')
local table = require('__stdlib2__/stdlib/utils/table')

describe('Inventory Spec', function()
local function make_get_contents(inv)
Expand Down
6 changes: 3 additions & 3 deletions spec/entity/resource_spec.lua
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
require('spec/setup/busted')()

local Resource = require('__stdlib__/stdlib/entity/resource')
local Area = require('__stdlib__/stdlib/area/area')
local table = require('__stdlib__/stdlib/utils/table')
local Resource = require('__stdlib2__/stdlib/entity/resource')
local Area = require('__stdlib2__/stdlib/area/area')
local table = require('__stdlib2__/stdlib/utils/table')

describe('Resource filtering', function()
local resources = {}
Expand Down
42 changes: 21 additions & 21 deletions spec/event/event_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ describe('Event', function ()
insulate('.register', function()
it('should multiplex events to multiple registered handlers', function()
World.bootstrap()
local Event = require('__stdlib__/stdlib/event/event')
local Event = require('__stdlib2__/stdlib/event/event')
local f, g = genstub(2)
Event.register(0, f)
Event.register(0, g)
Expand All @@ -26,7 +26,7 @@ describe('Event', function ()
insulate('.register', function()
it('should error() if a nil/false event id is supplied', function()
World.bootstrap()
local Event = require('__stdlib__/stdlib/event/event')
local Event = require('__stdlib2__/stdlib/event/event')
assert.has.errors(function() Event.register(false, function() end) end)
assert.has.errors(function() Event.register({0, false}, function() end) end)
assert.has.errors(function() Event.register({0, {}}) end)
Expand All @@ -36,7 +36,7 @@ describe('Event', function ()
insulate('.register', function()
it('should error() if no handler is provided', function()
World.bootstrap()
local Event = require('__stdlib__/stdlib/event/event')
local Event = require('__stdlib2__/stdlib/event/event')
local f, g = genstub(2)
Event.register(0, f)
Event.register(0, g)
Expand All @@ -47,7 +47,7 @@ describe('Event', function ()
insulate('.register', function()
it('should add and invoke handlers for multiple events', function()
World.bootstrap()
local Event = require('__stdlib__/stdlib/event/event')
local Event = require('__stdlib2__/stdlib/event/event')
local f, g = genstub(2)
Event.register({0, 2}, f).register(2, g)

Expand All @@ -67,7 +67,7 @@ describe('Event', function ()
it('should attach to factorio events when initial, but not subsequent \z
registrations are requested on a per-event basis', function()
World.bootstrap()
local Event = require('__stdlib__/stdlib/event/event')
local Event = require('__stdlib2__/stdlib/event/event')
local s = spy.on(Event.script, 'on_event')

Event.register(0, genstub())
Expand Down Expand Up @@ -97,7 +97,7 @@ describe('Event', function ()
insulate('.register', function()
it('should return the event module to callers', function()
World.bootstrap()
local Event = require('__stdlib__/stdlib/event/event')
local Event = require('__stdlib2__/stdlib/event/event')
assert.equals(Event, Event.register(0, genstub(1)))
assert.equals(Event, Event.register(0, genstub(1)).register(0, genstub(1)))
end)
Expand All @@ -107,7 +107,7 @@ describe('Event', function ()
it('should not add duplicate handers to a single event, and \z
should fire in order of least recent registration', function()
World.bootstrap()
local Event = require('__stdlib__/stdlib/event/event')
local Event = require('__stdlib2__/stdlib/event/event')
local g = genstub()
local f = spy(function ()
assert.stub(g).was.called(1)
Expand All @@ -133,7 +133,7 @@ describe('Event', function ()
insulate('.register', function()
it('should register and appropriately invoke filtered handlers', function()
World.bootstrap()
local Event = require('__stdlib__/stdlib/event/event')
local Event = require('__stdlib2__/stdlib/event/event')

local pete_repeat_repeated_pattern = 'pete_repeat' -- RepeatyPete copies pattern here when invoked
local that_one_thing = {} -- arbitrary singleton
Expand Down Expand Up @@ -209,7 +209,7 @@ describe('Event', function ()
is for the event being dispatched, does not cause the handler \z
to fire.', function()
World.bootstrap()
local Event = require('__stdlib__/stdlib/event/event')
local Event = require('__stdlib2__/stdlib/event/event')
local g, h = genstub(2)
local f = spy(function()
Event.register(0, h)
Expand Down Expand Up @@ -249,7 +249,7 @@ describe('Event', function ()
events, and should deregister itself when the corresponding final \z
listener is removed.', function()
World.bootstrap()
local Event = require('__stdlib__/stdlib/event/event')
local Event = require('__stdlib2__/stdlib/event/event')
local spy_on_init = spy.on(Event.script, 'on_init')
local spy_on_load = spy.on(Event.script, 'on_load')
local spy_on_configuration_changed = spy.on(Event.script, 'on_configuration_changed')
Expand Down Expand Up @@ -356,7 +356,7 @@ describe('Event', function ()
it('unregisters the requested handler regardless of the order \z
in which it was registered', function()
World.bootstrap()
local Event = require('__stdlib__/stdlib/event/event')
local Event = require('__stdlib2__/stdlib/event/event')
local f, g, h = genstub(3)
Event.register(0, f).register(0, g).register(0, h)

Expand Down Expand Up @@ -391,7 +391,7 @@ describe('Event', function ()
insulate('.remove', function()
it('returns the Event module when called', function()
World.bootstrap()
local Event = require('__stdlib__/stdlib/event/event')
local Event = require('__stdlib2__/stdlib/event/event')
local f, g, h = genstub(3)
Event.register(0, f).register(0, g).register(0, h)

Expand Down Expand Up @@ -421,7 +421,7 @@ describe('Event', function ()
insulate('.remove', function()
pending('should remove the running handler if requested', function()
World.bootstrap()
local Event = require('__stdlib__/stdlib/event/event')
local Event = require('__stdlib2__/stdlib/event/event')
local f, h = genstub(2)
local g = spy(function()
Event.remove(0, g) --luacheck: ignore g
Expand All @@ -444,7 +444,7 @@ describe('Event', function ()
pending('should prevent invocation of subsequent handlers \z
during processing of preceeding handlers', function()
World.bootstrap()
local Event = require('__stdlib__/stdlib/event/event')
local Event = require('__stdlib2__/stdlib/event/event')
local f = spy(function()
Event.remove(0, g).remove(0, h) --luacheck: ignore g h
end)
Expand All @@ -464,7 +464,7 @@ describe('Event', function ()
it('should log, but not error(), upon de-registration \z
of non-registered listeners', function()
World.bootstrap()
local Event = require('__stdlib__/stdlib/event/event')
local Event = require('__stdlib2__/stdlib/event/event')
_G.log = genstub()
assert.has_no.errors(function () Event.remove(0, genstub()) end)
--assert.stub(_G.log).was.called()
Expand All @@ -474,7 +474,7 @@ describe('Event', function ()
insulate('.remove', function()
it('should deregister a given handler from an event', function()
World.bootstrap()
local Event = require('__stdlib__/stdlib/event/event')
local Event = require('__stdlib2__/stdlib/event/event')
local f, g, h, i = genstub(4)
Event.register(0, f).register({0, 1}, g)
Event.register({0, 1, 2}, h).register({2, 0}, i)
Expand Down Expand Up @@ -563,7 +563,7 @@ describe('Event', function ()
it('should print an error to connected players if a protected handler \z
throws an error', function()
World.bootstrap()
local Event = require('__stdlib__/stdlib/event/event')
local Event = require('__stdlib2__/stdlib/event/event')
World.init(true)
World.create_players(2)
_G.game.tick = 2
Expand Down Expand Up @@ -594,7 +594,7 @@ describe('Event', function ()
it('should cease processing an event with a userdata property \z
which has become non-valid', function()
World.bootstrap()
local Event = require('__stdlib__/stdlib/event/event')
local Event = require('__stdlib2__/stdlib/event/event')
local fud = World.fake_userdata()
local e = {foo = 'bar', fud = fud}
local f, h = genstub(2)
Expand All @@ -614,7 +614,7 @@ describe('Event', function ()
it('should abort event processing when a handler returns \z
stop_processing', function()
World.bootstrap()
local Event = require('__stdlib__/stdlib/event/event')
local Event = require('__stdlib2__/stdlib/event/event')
local return_value = Event.stop_processing
local g = spy(function ()
return return_value
Expand Down Expand Up @@ -653,7 +653,7 @@ describe('Event', function ()
it('should abort event processing when a matched handler \z
returns stop_processing', function()
World.bootstrap()
local Event = require('__stdlib__/stdlib/event/event')
local Event = require('__stdlib2__/stdlib/event/event')
local i,k = genstub(2)
local j = spy(function()
return Event.stop_processing
Expand Down Expand Up @@ -693,7 +693,7 @@ describe('Event', function ()
Event.stop_processing, which should just count as a \z
successful match in that context', function()
World.bootstrap()
local Event = require('__stdlib__/stdlib/event/event')
local Event = require('__stdlib2__/stdlib/event/event')
local l,m,n,o = genstub(4)
local pattern_identity_matcher = function(_, pattern)
return pattern
Expand Down
Loading