From 4efa83edd98b84170f778e50b02a86c2e2763669 Mon Sep 17 00:00:00 2001 From: Cooldude2606 Date: Thu, 30 Nov 2017 19:15:38 +0000 Subject: [PATCH] Fixed a few bugs --- control.lua | 3 +-- locale/StdLib/color.lua | 2 +- locale/StdLib/game.lua | 2 +- locale/StdLib/load.lua | 16 +++++++++++++--- locale/StdLib/table.lua | 2 +- 5 files changed, 17 insertions(+), 8 deletions(-) diff --git a/control.lua b/control.lua index 8f55a0f8..8e627d65 100644 --- a/control.lua +++ b/control.lua @@ -24,8 +24,7 @@ error = function(err) end -- loads the stdlib and allows Core Game and Event -local StdLib = require '/locale/StdLib/load' -local Core, Game, Event = StdLib.Core, StdLib.Game, StdLib.Event +local Color, Game, Event = require('/locale/StdLib/load'){'Color','Game','Event'} -- loads the ExpLib, functions are plased into the lua global local ExpLib = require 'ExpLib' diff --git a/locale/StdLib/color.lua b/locale/StdLib/color.lua index d62fef50..fea89259 100644 --- a/locale/StdLib/color.lua +++ b/locale/StdLib/color.lua @@ -217,7 +217,7 @@ setmetatable(defines.lightcolor, _mt.lightcolor) --require 'stdlib/defines/color' local fail_if_missing = require 'game'['fail_if_missing'] -Color = {} --luacheck: allow defined top +local Color = {} --luacheck: allow defined top --- Set a value for the alpha channel in the given color table. -- `color.a` represents the alpha channel in the given color table. diff --git a/locale/StdLib/game.lua b/locale/StdLib/game.lua index b31468ac..77552732 100644 --- a/locale/StdLib/game.lua +++ b/locale/StdLib/game.lua @@ -2,7 +2,7 @@ -- @module Game -- @usage local Game = require('stdlib/game') -Game = { --luacheck: allow defined top +local Game = { --luacheck: allow defined top VALID_FILTER = function(v) return v and v.valid end, diff --git a/locale/StdLib/load.lua b/locale/StdLib/load.lua index 3ff84f77..a7501775 100644 --- a/locale/StdLib/load.lua +++ b/locale/StdLib/load.lua @@ -11,7 +11,8 @@ Discord: https://discord.gg/r6dC2uK StdLib This file allow you to only require this one file to return the diffent libarys. -The array returned contains the stdlib modules so there can be decleared after the file require +This file will return a function which can be used to access only the part you want. +Pass a table with the names of the objects you want and it will be return in that order ]] local StdLib = {} @@ -19,8 +20,17 @@ local StdLib = {} require '/table' require '/string' require '/time' -StdLib.Colour = require '/color' +StdLib.Color = require '/color' StdLib.Game = require '/game' StdLib.Event = require '/event' -return StdLib \ No newline at end of file +return function(rtn) + local to_return = {} + for _,name in pairs(rtn) do + if StdLib[name] then + table.insert(to_return,StdLib[name]) + end + end + test = to_return + return unpack(to_return) +end \ No newline at end of file diff --git a/locale/StdLib/table.lua b/locale/StdLib/table.lua index 2a26e73b..b22246c1 100644 --- a/locale/StdLib/table.lua +++ b/locale/StdLib/table.lua @@ -413,7 +413,7 @@ function table.val_to_str(v) end return '"'..string.gsub(v,'"', '\\"' )..'"' else - return "table" == type( v) and table.tostring(v) or + return "table" == type( v) and table.to_string(v) or "function" == type(v) and '"cant-display-function"' or "userdata" == type(v) and '"cant-display-userdata"' or tostring(v)