diff --git a/modules/ExpGamingAdmin/AdminLib/control.lua b/modules/ExpGamingAdmin/AdminLib/control.lua index 57e75a03..98a95d5b 100644 --- a/modules/ExpGamingAdmin/AdminLib/control.lua +++ b/modules/ExpGamingAdmin/AdminLib/control.lua @@ -63,6 +63,7 @@ function Admin.is_banned(player,detail) end function Admin.add_action(action,callback) + verbose('Added admin action: '..action) table.insert(Admin.action_names,action) Admin.actions[string.lower(action)] = callback end diff --git a/modules/ExpGamingAdmin/Gui/control.lua b/modules/ExpGamingAdmin/Gui/control.lua index 6f6a158e..8d6a6bdd 100644 --- a/modules/ExpGamingAdmin/Gui/control.lua +++ b/modules/ExpGamingAdmin/Gui/control.lua @@ -104,7 +104,7 @@ local reason_input = Gui.inputs.add_text('reason-input-admin-commands',false,'En end end) -local action_drop_down = Gui.inputs.add_drop_down('action-drop-down-rank-change',{'Select Action',unpack(Admin.action_names)},1,function(player,selected,items,element) +local action_drop_down = Gui.inputs.add_drop_down('action-drop-down-rank-change',function() return {'Select Action',unpack(Admin.action_names)} end,1,function(player,selected,items,element) element.parent.parent.action.caption = selected if selected == 'Jail' or selected == 'Kick' or selected == 'Ban' or selected == 'Temp Ban' then element.parent['reason-input-admin-commands'].style.visible = true diff --git a/modules/ExpGamingCore/Gui/control.lua b/modules/ExpGamingCore/Gui/control.lua index d30c7dad..c62f200c 100644 --- a/modules/ExpGamingCore/Gui/control.lua +++ b/modules/ExpGamingCore/Gui/control.lua @@ -6,6 +6,7 @@ local Game = require('FactorioStdLib.Game') local Color = require('FactorioStdLib.Color') +local Server -- ExpGamingCore.Server@?^4.0.0 local Gui = {} local global = global() @@ -106,7 +107,7 @@ function Gui.cam_link(data) data.cam.style.width = data.width or 100 data.cam.style.height = data.height or 100 else return end - if not Server or not Server._thread or not Server.get_thread('camera-follow') then + if not Server or not Server.get_thread('camera-follow') then if not global.cams then global.cams = {} global.cam_index = 1 @@ -177,18 +178,18 @@ end) function Gui:on_init() self.left:on_init(); self.left.on_init = nil self.toolbar:on_init(); self.toolbar.on_init = nil - if loaded_modules['ExpGamingCore.Server'] then verbose('ExpGamingCore.Server is installed; Loading server src') require(module_path..'/src/server',{Gui=Gui}) end - if loaded_modules['ExpGamingCore.Role'] then + if loaded_modules['ExpGamingCore.Server@^4.0.0'] then Server = require('ExpGamingCore.Server@^4.0.0') verbose('ExpGamingCore.Server is installed; Loading server src') script.on_init(require(module_path..'/src/server',{Gui=self})) end + if loaded_modules['ExpGamingCore.Role@^4.0.0'] then verbose('ExpGamingCore.Role is installed; Loading ranking src') script.on_event('on_role_change',function(event) - Gui.toolbar.on_role_change(event) - Gui.center.on_role_change(event) + self.toolbar.on_role_change(event) + self.center.on_role_change(event) end) end script.on_event('on_player_joined_game',function(event) - Gui.toolbar.on_player_joined_game(event) - Gui.popup.on_player_joined_game(event) - Gui.left.on_player_joined_game(event) + self.toolbar.on_player_joined_game(event) + self.popup.on_player_joined_game(event) + self.left.on_player_joined_game(event) end) end diff --git a/modules/ExpGamingCore/Gui/src/server.lua b/modules/ExpGamingCore/Gui/src/server.lua index 2df65c10..11e944dc 100644 --- a/modules/ExpGamingCore/Gui/src/server.lua +++ b/modules/ExpGamingCore/Gui/src/server.lua @@ -4,9 +4,10 @@ local Game = require('FactorioStdLib.Game@^0.8.0') local Server = require('ExpGamingCore.Server@^4.0.0') +Server.add_module_to_interface('ExpGui','ExpGamingCore.Gui') + --- Adds a server thread that allows the camera follows to be toggled off and on --- @function __comment -script.on_event(-1,function(event) +return function(event) Server.new_thread{ name='camera-follow', data={cams={},cam_index=1,players={}} @@ -39,6 +40,4 @@ script.on_event(-1,function(event) end end end):open() -end) - -Server.add_module_to_interface('ExpGui','ExpGamingCore.Gui') \ No newline at end of file +end \ No newline at end of file diff --git a/modules/ExpGamingCore/Role/control.lua b/modules/ExpGamingCore/Role/control.lua index 21a49ab1..783c6a96 100644 --- a/modules/ExpGamingCore/Role/control.lua +++ b/modules/ExpGamingCore/Role/control.lua @@ -147,7 +147,7 @@ function Role.unassign(player,role,by_player,batch) -- this loops over a table of role if given; will return if ipairs returns, else will asume it was ment to be a role and error if is_type(role,'table') and not role.name then local ctn = 0 - for _,_role in ipairs(role) do ctn=ctn+1 Role.unassign(player,_role,by_player,role) end + for n,_role in ipairs(role) do ctn=ctn+1 Role.unassign(player,_role,by_player,{n,role}) end if ctn > 0 then if not batch then table.insert(global.changes[player.index],{'unassign',role}) global.latest_change = {player.index,'unassign',role} end return end end local role = Role.get(role) @@ -442,26 +442,28 @@ script.on_event(role_change_event_id,function(event) local player = Game.get_player(event) local by_player = Game.get_player(event.by_player_index) or SERVER local role = Role.get(event.role_name) - local highest = Role.get_highest(player) or {__faild=true,tag='',name='None'} + local highest = Role.get_highest(player) + if not highest then Role.meta.default:add_player(player) highest = Role.meta.default end -- gets the falgs the player currently has for flag,callback in pairs(Role.flags) do if is_type(callback,'function') then callback(player,Role.has_flag(player,flag)) end end -- assign new tag and group of highest role - if highest.__faild then Group.get(player):remove_player(player) - else Group.assign(player,highest.group) end + Group.assign(player,highest.group) local old_highest_tag = Role.get(event.old_highest).tag or '' local start, _end = string.find(player.tag,old_highest_tag,1,true) if start and old_highest_tag ~= highest.tag then player.tag = string.sub(player.tag,0,start-1)..highest.tag..string.sub(player.tag,_end+1) end if not start then player.tag = highest.tag player_return({'ExpGamingCore-Role.tag-reset'},nil,player) end - -- play a sound to the player - if event.effect == 'assign' and not role.is_jail then player.play_sound{path='utility/achievement_unlocked'} - else player.play_sound{path='utility/game_lost'} end if player.online_time > 60 then -- send a message to other players if event.batch_index == 1 then local names = {} for _,name in pairs(event.batch) do local role = Role.get(name) if role then table.insert(names,role.name) end end - if event.effect == 'assign' then game.print{'ExpGamingCore-Role.default-print',{'ExpGamingCore-Role.assign',player.name,table.concat(names,', '),by_player.name}} - else game.print{'ExpGamingCore-Role.default-print',{'ExpGamingCore-Role.unassign',player.name,name,by_player.name}} end + if event.effect == 'assign' then + if not role.is_jail then player.play_sound{path='utility/achievement_unlocked'} end + game.print{'ExpGamingCore-Role.default-print',{'ExpGamingCore-Role.assign',player.name,table.concat(names,', '),by_player.name}} + else + player.play_sound{path='utility/game_lost'} + game.print{'ExpGamingCore-Role.default-print',{'ExpGamingCore-Role.unassign',player.name,table.concat(names,', '),by_player.name}} + end end -- log change to file game.write_file('role-change.json', diff --git a/modules/ExpGamingCore/Server/control.lua b/modules/ExpGamingCore/Server/control.lua index 4d024e6b..847bd10e 100644 --- a/modules/ExpGamingCore/Server/control.lua +++ b/modules/ExpGamingCore/Server/control.lua @@ -263,6 +263,8 @@ function Server._thread:create(obj) obj.uuid = tostring(Server.uuid) obj._env = get_env() obj._env.obj = nil -- provents infinte recusion + local name = obj.name or 'Anon' + verbose('Created new thread: '..name..' ('..obj.uuid..')') return obj end @@ -327,6 +329,8 @@ function Server._thread:open() table.insert(global.events[event],uuid) end,global,self.uuid) end + local name = self.name or 'Anon' + verbose('Opened thread: '..name..' ('..self.uuid..')') return true end @@ -365,6 +369,8 @@ function Server._thread:close() -- else it will just be wiped from the global index else global.all[uuid] = nil global.all._n = global.all._n-1 end end + local name = self.name or 'Anon' + verbose('Closed thread: '..name..' ('..self.uuid..')') return _return end diff --git a/modules/ExpGamingPlayer/playerInfo/control.lua b/modules/ExpGamingPlayer/playerInfo/control.lua index 33470504..a5a4817e 100644 --- a/modules/ExpGamingPlayer/playerInfo/control.lua +++ b/modules/ExpGamingPlayer/playerInfo/control.lua @@ -28,7 +28,7 @@ local function get_player_info(player,frame,add_cam) if frame then local frame = frame.add{type='frame',direction='vertical',style='image_frame'} frame.style.width = 200 - if Role then frame.style.height = 275 + if Role then frame.style.height = 300 else frame.style.height = 260 end frame.add{type='label',caption={'ExpGamingPlayer-playerInfo.name',_player.index,_player.name},style='caption_label'} local _online = {'ExpGamingPlayer-playerInfo.no'}; if _player.online then _online = {'ExpGamingPlayer-playerInfo.yes'} end diff --git a/modules/WornPaths/control.lua b/modules/WornPaths/control.lua index 540618d0..3b6b713e 100644 --- a/modules/WornPaths/control.lua +++ b/modules/WornPaths/control.lua @@ -82,7 +82,7 @@ script.on_event({defines.events.on_built_entity,on_robot_built_entity}, function for x = box.left_top.x,box.right_bottom.x do for y = box.left_top.y,box.right_bottom.y do local pos = {x=entity.position.x+x,y=entity.position.y+y} local tile = surface.get_tile(pos).name - if paths[tile] and math.random() < paths[tile][1]*size/(-2) then + if paths[tile] and math.random() < paths[tile][1]*size*(-2) then ThisModule.down_grade(surface,pos) end end end