From 28c6610a204f156b87ba44ac8cfa2b63ae5edba0 Mon Sep 17 00:00:00 2001 From: Cooldude2606 Date: Sun, 20 May 2018 19:04:24 +0100 Subject: [PATCH] Fixed a few inconsitancy --- ExpCore/gui.lua | 2 +- StdLib/color.lua | 6 ++---- StdLib/event.lua | 11 +++++------ control.lua | 2 +- 4 files changed, 9 insertions(+), 12 deletions(-) diff --git a/ExpCore/gui.lua b/ExpCore/gui.lua index a16ca0f6..d5649e79 100644 --- a/ExpCore/gui.lua +++ b/ExpCore/gui.lua @@ -29,7 +29,7 @@ function Gui._get_data(key) return Gui_data[key] end function Gui:_load_parts(parts) for _,part in pairs(parts) do verbose('Gui Extraction: '..part) - self[part] = require('/GuiParts/'..part) + self[part] = require('GuiParts/'..part) end end diff --git a/StdLib/color.lua b/StdLib/color.lua index fea89259..54aa9376 100644 --- a/StdLib/color.lua +++ b/StdLib/color.lua @@ -214,9 +214,6 @@ setmetatable(defines.lightcolor, _mt.lightcolor) -- @module Color -- @usage local Color = require('stdlib/color/color') ---require 'stdlib/defines/color' -local fail_if_missing = require 'game'['fail_if_missing'] - local Color = {} --luacheck: allow defined top --- Set a value for the alpha channel in the given color table. @@ -266,7 +263,8 @@ end -- @tparam[opt=1] float alpha the alpha value to set; such that ***[ 0 ⋜ value ⋜ 1 ]*** -- @treturn Concepts.Color a color table with RGB converted from Hex and with alpha function Color.from_hex(hex, alpha) - fail_if_missing(hex, "missing color hex value") + if not _G.Game then error('StdLib/Game not loaded') end + _G.Game.fail_if_missing(hex, "missing color hex value") if hex:find("#") then hex = hex:sub(2) end if not(#hex == 6) then error("invalid color hex value: "..hex) end local number = tonumber(hex, 16) diff --git a/StdLib/event.lua b/StdLib/event.lua index 8f142cbf..9a4a380b 100644 --- a/StdLib/event.lua +++ b/StdLib/event.lua @@ -5,9 +5,6 @@ -- @module Event -- @usage require('stdlib/event/event') -local fail_if_missing = require 'game'['fail_if_missing'] -local Game = require 'game' - local Event = { --luacheck: allow defined top _registry = {}, core_events = { @@ -58,7 +55,8 @@ end]] -- @tparam function handler Function to call when event is triggered -- @treturn Event function Event.register(event, handler) - fail_if_missing(event, "missing event argument") + if not _G.Game then error('StdLib/Game not loaded') end + _G.Game.fail_if_missing(event, "missing event argument") event = (type(event) == "table" and event) or {event} @@ -146,8 +144,9 @@ end -- @tparam function handler to remove -- @return Event function Event.remove(event, handler) - fail_if_missing(event, "missing event argument") - fail_if_missing(handler, "missing handler argument") + if not _G.Game then error('StdLib/Game not loaded') end + _G.Game.fail_if_missing(event, "missing event argument") + _G.Game.fail_if_missing(handler, "missing handler argument") event = (type(event) == "table" and event) or {event} diff --git a/control.lua b/control.lua index 21cbe7d0..69d1b1f7 100644 --- a/control.lua +++ b/control.lua @@ -34,7 +34,7 @@ require_return_err = false -- Set to false when removing files; set to true for _require = require require = function(path) local _path = path - if not string.sub(path,1) == '/' then path = '/'..path end + if string.sub(path,1) ~= '/' then path = '/'..path end local _return = {pcall(_require,path)} if not table.remove(_return, 1) then local __return = {pcall(_require,'/..'..path)}