From a15875d8a07f9a2f51514236da91df5e109eb72c Mon Sep 17 00:00:00 2001 From: Cooldude2606 Date: Fri, 1 Feb 2019 23:23:09 +0000 Subject: [PATCH 1/2] Small Bugs Fixed --- modules/ExpGamingAdmin/Jail/control.lua | 1 + modules/ExpGamingAdmin/control.lua | 2 +- modules/ExpGamingCommands/home/locale/en.cfg | 4 +- modules/FactorioStdLib/Table/control.lua | 49 +++++++++----------- modules/WarpPoints/control.lua | 12 ++--- 5 files changed, 33 insertions(+), 35 deletions(-) diff --git a/modules/ExpGamingAdmin/Jail/control.lua b/modules/ExpGamingAdmin/Jail/control.lua index e868d943..7720c182 100644 --- a/modules/ExpGamingAdmin/Jail/control.lua +++ b/modules/ExpGamingAdmin/Jail/control.lua @@ -40,6 +40,7 @@ function Admin.jail(player,by_player,reason) ['Reason:']=reason } end Role.meta.last_jail = player.name + player.vehicle = nil Server.interface(Role.assign,true,player,'Jail',by_player.name) Server.interface(Role.unassign,true,player,Role.get(player),by_player.name) end diff --git a/modules/ExpGamingAdmin/control.lua b/modules/ExpGamingAdmin/control.lua index 4d4f20e1..af9d31c2 100644 --- a/modules/ExpGamingAdmin/control.lua +++ b/modules/ExpGamingAdmin/control.lua @@ -43,7 +43,7 @@ function Admin.create_reason(reason,name) reason = reason or 'No Reason' if not string.find(string.lower(reason),string.lower(name)) then reason = reason..' - '..name end if Sync and Sync.info.date ~= '0000/00/00' and not string.find(string.lower(reason),Sync.info.date) then reason = reason..' - '..Sync.info.date end - if not string.find(string.lower(reason),'appeal') then reason = reason..' - Vist www.explosivegaming.nl to appeal.' end + if not string.find(string.lower(reason),'appeal') then reason = reason..' - Visit www.explosivegaming.nl to appeal.' end return reason end diff --git a/modules/ExpGamingCommands/home/locale/en.cfg b/modules/ExpGamingCommands/home/locale/en.cfg index e70a2161..e2993070 100644 --- a/modules/ExpGamingCommands/home/locale/en.cfg +++ b/modules/ExpGamingCommands/home/locale/en.cfg @@ -2,8 +2,8 @@ too-many-homes=You have too many homes, to add more you must remove one. Your max is __1__. homes=Your Homes: (__1__/__2__) home=__1__) __2__: __3__ , __4__ -set=Your home "__1__" as been set to __2__ , __3__ -remove=Your home "__1__" as been removed +set=Your home "__1__" has been set to __2__ , __3__ +remove=Your home "__1__" has been removed goto=You are now at "__1__" return=You are now at your previous location: __1__ , __2__ invalid=Invalid name, __1__ \ No newline at end of file diff --git a/modules/FactorioStdLib/Table/control.lua b/modules/FactorioStdLib/Table/control.lua index 96e063ca..04f048fc 100644 --- a/modules/FactorioStdLib/Table/control.lua +++ b/modules/FactorioStdLib/Table/control.lua @@ -272,6 +272,27 @@ function table.deepcopy(object) return _copy(object) end +--- Default table comparator sort function. +-- @local +-- @param x one comparator operand +-- @param y the other comparator operand +-- @return true if x logically comes before y in a list, false otherwise +local function sortFunc(x, y) --sorts tables with mixed index types. + local tx = type(x) + local ty = type(y) + if tx == ty then + if type(x) == 'string' then + return string.lower(x) < string.lower(y) + else + return x < y + end + elseif tx == 'number' then + return true --only x is a number and goes first + else + return false --only y is a number and goes first + end +end + --- Returns a copy of all of the values in the table. -- @tparam table tbl the table to copy the keys from, or an empty table if tbl is nil -- @tparam[opt] boolean sorted whether to sort the keys (slower) or keep the random order from pairs() @@ -293,19 +314,7 @@ function table.values(tbl, sorted, as_string) end end if sorted then - table.sort(valueset, - function(x, y) --sorts tables with mixed index types. - local tx = type(x) == 'number' - local ty = type(y) == 'number' - if tx == ty then - return x < y and true or false --similar type can be compared - elseif tx == true then - return true --only x is a number and goes first - else - return false --only y is a number and goes first - end - end - ) + table.sort(valueset,sortFunc) end return valueset end @@ -331,19 +340,7 @@ function table.keys(tbl, sorted, as_string) end end if sorted then - table.sort(keyset, - function(x, y) --sorts tables with mixed index types. - local tx = type(x) == 'number' - local ty = type(y) == 'number' - if tx == ty then - return x < y and true or false --similar type can be compared - elseif tx == true then - return true --only x is a number and goes first - else - return false --only y is a number and goes first - end - end - ) + table.sort(keyset,sortFunc) end return keyset end diff --git a/modules/WarpPoints/control.lua b/modules/WarpPoints/control.lua index e648b55e..16c150f9 100644 --- a/modules/WarpPoints/control.lua +++ b/modules/WarpPoints/control.lua @@ -103,8 +103,8 @@ function ThisModule.make_warp_point(position,surface,force,warpName) icon={type='item',name=warp_item} }) global.warps[warpName] = {tag=tag,surface=surface.index,position=tag.position,old_tile=old_tile} - local _temp = {Spawn=global.warps.Spawn} - global.warps.Spawn = nil + local _temp = {spawn=global.warps.spawn} + global.warps.spawn = nil for name,data in pairs(table.keysort(global.warps)) do _temp[name] = data end global.warps = _temp ThisModule.Gui() @@ -163,7 +163,7 @@ ThisModule.Gui = Gui.left{ } for name,warp in pairs(global.warps) do if not warp.tag or not warp.tag.valid then - player.force.add_chart_tag(game.surfaces[warp.surface],{ + warp.tag = player.force.add_chart_tag(game.surfaces[warp.surface],{ position=warp.position, text='Warp: '..name, icon={type='item',name=warp_item} @@ -181,7 +181,7 @@ ThisModule.Gui = Gui.left{ local btn = go_to_warp(_flow) btn.style.height = 20 btn.style.width = 20 - if not Role and player.admin and name ~= 'Spawn' or Role and Role.allowed(player,'make-warp') and name ~= 'Spawn' then + if not Role and player.admin and name ~= 'spawn' or Role and Role.allowed(player,'make-warp') and name ~= 'spawn' then local btn = remove_warp(_flow) btn.style.height = 20 btn.style.width = 20 @@ -239,10 +239,10 @@ script.on_event(defines.events.on_player_created, function(event) player.force.chart(player.surface, {{player.position.x - 20, player.position.y - 20}, {player.position.x + 20, player.position.y + 20}}) local tag = player.force.add_chart_tag(player.surface,{ position={0,0}, - text='Warp: Spawn', + text='Warp: spawn', icon={type='item',name=warp_item} }) - global.warps['Spawn'] = {tag=tag,surface=player.surface.index,position={x=0,y=0}} + global.warps['spawn'] = {tag=tag,surface=player.surface.index,position={x=0,y=0}} end end) From 86b98af2bb208f4ddaa6dcc42b0094fe1a947208 Mon Sep 17 00:00:00 2001 From: Cooldude2606 Date: Wed, 6 Feb 2019 17:43:19 +0000 Subject: [PATCH 2/2] Removed loging of global table to file --- FactorioSoftmodManager.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/FactorioSoftmodManager.lua b/FactorioSoftmodManager.lua index 3b7cc1a7..5b41c124 100644 --- a/FactorioSoftmodManager.lua +++ b/FactorioSoftmodManager.lua @@ -735,7 +735,7 @@ script.on_load(function(...) local names = {} for name,default in pairs(Manager.global.__defaults) do table.insert(names,name) end Manager.verbose('Global Tables: '..table.concat(names,', ')) - for name,default in pairs(Manager.global.__defaults) do Manager.verbose('Global '..name..' = '..serpent.line(Manager.global(name))) end + --for name,default in pairs(Manager.global.__defaults) do Manager.verbose('Global '..name..' = '..serpent.line(Manager.global(name))) end Manager.event(-2,...) Manager.verbose('____________________| SubStop: script.on_load |____________________') end)