server-interface clean

This commit is contained in:
Cooldude2606
2017-10-15 00:07:26 +01:00
parent 73e442bc4b
commit 6dbdec5c8f
3 changed files with 18 additions and 20 deletions

View File

@@ -44,8 +44,8 @@ function table.val_to_str ( v )
return '"' .. string.gsub(v,'"', '\\"' ) .. '"' return '"' .. string.gsub(v,'"', '\\"' ) .. '"'
else else
return "table" == type( v ) and table.tostring( v ) or return "table" == type( v ) and table.tostring( v ) or
"function" == type( v ) and '"cant_display_function"' or "function" == type( v ) and '"cant-display-function"' or
"userdata" == type( v ) and '"cant_display_userdata"' or "userdata" == type( v ) and '"cant-display-userdata"' or
tostring( v ) tostring( v )
end end
end end

View File

@@ -5,21 +5,10 @@ This file can be used with permission but this and the credit below must remain
Contact a member of management on our discord to seek permission to use our code. Contact a member of management on our discord to seek permission to use our code.
Any changes that you may make to the code are yours but that does not make the script yours. Any changes that you may make to the code are yours but that does not make the script yours.
Discord: https://discord.gg/XSsBV6b Discord: https://discord.gg/XSsBV6b
The credit below may be used by another script do not remove.
]] ]]
local credits = {{
name='Explosive Gaming Server Interface',
owner='Explosive Gaming',
dev='Cooldude2606',
description='A way of talking with the server with out breaking achievements',
factorio_version='0.15.23',
show=true
}}
local function credit_loop(reg) for _,cred in pairs(reg) do table.insert(credits,cred) end end
--Please Only Edit Below This Line----------------------------------------------------------- --Please Only Edit Below This Line-----------------------------------------------------------
--this command is just a way or using loadstring from in game while keeping achievements --this command is just a way or using loadstring from in game while keeping achievements
define_command('server-interface','For use of the highest staff only',{'command',true},function(player,event,args) define_command('server-interface',{'server-interface.command-help'},{'command',true},function(player,event,args)
if player == '<server>' then if player == '<server>' then
local returned,value = pcall(loadstring(event.parameter)) local returned,value = pcall(loadstring(event.parameter))
if type(value) == 'table' then game.write_file('server-interface.log', '\n'..game.tick..' Ran by: <server> Code: '..event.parameter..'\n Returned: '..table.tostring(value), true, 0) print(table.tostring(value)) if type(value) == 'table' then game.write_file('server-interface.log', '\n'..game.tick..' Ran by: <server> Code: '..event.parameter..'\n Returned: '..table.tostring(value), true, 0) print(table.tostring(value))
@@ -31,7 +20,7 @@ define_command('server-interface','For use of the highest staff only',{'command'
end end
end) end)
--runs a server interface command with debug on and does not return any values to the user --runs a server interface command with debug on and does not return any values to the user
define_command('debug','For use of the highest staff only, this will lag A LOT',{'command',true},function(player,event,args) define_command('debug',{'server-interface.debug-command-help'},{'command',true},function(player,event,args)
global.exp_core.debug.state = true global.exp_core.debug.state = true
debug_write({'START'},game.tick..' '..event.parameter) debug_write({'START'},game.tick..' '..event.parameter)
global.exp_core.debug.triggered = false global.exp_core.debug.triggered = false
@@ -77,7 +66,7 @@ end
function get_sudo_info(string) function get_sudo_info(string)
local lenth = 0 local lenth = 0
for _,v in pairs(global.exp_core.sudo.temp_varibles) do lenth = lenth + 1 end for _,v in pairs(global.exp_core.sudo.temp_varibles) do lenth = lenth + 1 end
if string then return 'At game tick: '..game.tick..' Queue Lenth: '..#global.exp_core.sudo.commands..' Number of temp vars: '..lenth if string then return {'server-interface.sudo-info',game.tick,#global.exp_core.sudo.commands,lenth}
else return {tick=game.tick,commands=#global.exp_core.sudo.commands,temp_varibles=#global.exp_core.sudo.temp_varibles} end else return {tick=game.tick,commands=#global.exp_core.sudo.commands,temp_varibles=#global.exp_core.sudo.temp_varibles} end
end end
-- stops all sudo commands -- stops all sudo commands
@@ -114,6 +103,4 @@ Event.register(defines.events.on_tick, function(event)
if data.remove_time <= game.tick then global.exp_core.sudo.temp_varibles[name] = nil end if data.remove_time <= game.tick then global.exp_core.sudo.temp_varibles[name] = nil end
end end
end) end)
Event.register(Event.soft_init,function() global.exp_core.sudo = {commands={},temp_varibles={}} end) Event.register(Event.soft_init,function() global.exp_core.sudo = {commands={},temp_varibles={}} end)
--Please Only Edit Above This Line-----------------------------------------------------------
return credits

View File

@@ -3,4 +3,15 @@ all-rank-print=\[Everyone\]: __1__
rank-up=__1__ was promoted to __2__ by __3__ rank-up=__1__ was promoted to __2__ by __3__
rank-down=__1__ was demoted to __2__ by __3__ rank-down=__1__ was demoted to __2__ by __3__
rank-given=You have been given the __1__ Rank! rank-given=You have been given the __1__ Rank!
tag-reset=Your Tag was reset due to a Rank change tag-reset=Your Tag was reset due to a Rank change
[commands]
no-help=__1__ No Help Given
unauthorized=401 - Unauthorized: Access is denied due to invalid credentials
invalid-inputs=Invalid Input, /__1__ __2__
command-ran=Command Complete
[server-interface]
command-help=For use of the highest staff only
debug-command-help=For use of the highest staff only, this will lag A LOT
sudo-info=At game tick: __1__ Queue Lenth: __2__ Number of temp vars: __3__