mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2025-12-31 04:51:40 +09:00
Globle Var step 1
This commit is contained in:
File diff suppressed because one or more lines are too long
47
source.lua
47
source.lua
@@ -3,6 +3,7 @@ itemRotated = {}
|
|||||||
entityRemoved = {}
|
entityRemoved = {}
|
||||||
entityCache = {}
|
entityCache = {}
|
||||||
guis = {frames={},buttons={}}
|
guis = {frames={},buttons={}}
|
||||||
|
defaults = {test={1,2,3},test2='test',test3=5}
|
||||||
|
|
||||||
warningAllowed = nil
|
warningAllowed = nil
|
||||||
timeForRegular = 180
|
timeForRegular = 180
|
||||||
@@ -58,6 +59,13 @@ function callAdmin(msg)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function initVar()
|
||||||
|
local g = nil
|
||||||
|
if game.players[1].gui.left.hidden then g = game.players[1].gui.left.hidden.caption else g = game.players[1].gui.left.add{type='frame',name='hidden',caption=table.tostring(defaults)}.caption end
|
||||||
|
gTable = loadstring('return '..g)()
|
||||||
|
game.print(g)
|
||||||
|
end
|
||||||
|
|
||||||
function autoMessage()
|
function autoMessage()
|
||||||
game.print('There are '..#game.connected_players..' players online')
|
game.print('There are '..#game.connected_players..' players online')
|
||||||
game.print('This map has been on for '..ticktohour(game.tick)..' Hours and '..(ticktominutes(game.tick)-60*ticktohour(game.tick))..' Minutes')
|
game.print('This map has been on for '..ticktohour(game.tick)..' Hours and '..(ticktominutes(game.tick)-60*ticktohour(game.tick))..' Minutes')
|
||||||
@@ -68,6 +76,44 @@ function autoMessage()
|
|||||||
game.print('To see these links again goto: Readme > Server Info')
|
game.print('To see these links again goto: Readme > Server Info')
|
||||||
end
|
end
|
||||||
----------------------------------------------------------------------------------------
|
----------------------------------------------------------------------------------------
|
||||||
|
---------------------------Table Functions----------------------------------------------
|
||||||
|
----------------------------------------------------------------------------------------
|
||||||
|
function table.val_to_str ( v )
|
||||||
|
if "string" == type( v ) then
|
||||||
|
v = string.gsub( v, "\n", "\\n" )
|
||||||
|
if string.match( string.gsub(v,"[^'\"]",""), '^"+$' ) then
|
||||||
|
return "'" .. v .. "'"
|
||||||
|
end
|
||||||
|
return '"' .. string.gsub(v,'"', '\\"' ) .. '"'
|
||||||
|
else
|
||||||
|
return "table" == type( v ) and table.tostring( v ) or
|
||||||
|
tostring( v )
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function table.key_to_str ( k )
|
||||||
|
if "string" == type( k ) and string.match( k, "^[_%a][_%a%d]*$" ) then
|
||||||
|
return k
|
||||||
|
else
|
||||||
|
return "[" .. table.val_to_str( k ) .. "]"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function table.tostring( tbl )
|
||||||
|
local result, done = {}, {}
|
||||||
|
for k, v in ipairs( tbl ) do
|
||||||
|
table.insert( result, table.val_to_str( v ) )
|
||||||
|
done[ k ] = true
|
||||||
|
end
|
||||||
|
for k, v in pairs( tbl ) do
|
||||||
|
if not done[ k ] then
|
||||||
|
table.insert( result,
|
||||||
|
table.key_to_str( k ) .. "=" .. table.val_to_str( v ) )
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return "{" .. table.concat( result, "," ) .. "}"
|
||||||
|
end
|
||||||
|
----------------------------------------------------------------------------------------
|
||||||
---------------------------Gui Functions------------------------------------------------
|
---------------------------Gui Functions------------------------------------------------
|
||||||
----------------------------------------------------------------------------------------
|
----------------------------------------------------------------------------------------
|
||||||
function addFrame(frame)
|
function addFrame(frame)
|
||||||
@@ -160,6 +206,7 @@ script.on_event(defines.events.on_player_respawned, function(event)
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
script.on_event(defines.events.on_player_joined_game, function(event)
|
script.on_event(defines.events.on_player_joined_game, function(event)
|
||||||
|
initVar()
|
||||||
local player = game.players[event.player_index]
|
local player = game.players[event.player_index]
|
||||||
player.print({"", "Welcome"})
|
player.print({"", "Welcome"})
|
||||||
if player.gui.left.PlayerList ~= nil then
|
if player.gui.left.PlayerList ~= nil then
|
||||||
|
|||||||
Reference in New Issue
Block a user