Change to role.assign

This commit is contained in:
Cooldude2606
2018-10-14 18:44:49 +01:00
parent 00e741937d
commit ad94a41702
3 changed files with 6 additions and 6 deletions

View File

@@ -195,7 +195,6 @@ Manager.global=setmetatable({__defaults={},__global={
for key,value in pairs(Global) do rawset(Global,key,nil) end
for key,value in pairs(rawget(rawget(tbl,'__defaults'),tostring(module_name))) do rawset(Global,key,deepcopy(value)) end
end
if game then game.write_file('global/'..game.tick,serpent.line(_G.global)) end
return setmetatable(Global,{
__call=function(tbl,default) return Manager.global(default,tbl) end,
__index=function(tbl,key) return rawget(Manager.global(),key) or moduleIndex[key] and Manager.global(key) end,

View File

@@ -120,7 +120,7 @@ end
function Role.assign(player,role,by_player,batch)
local player = Game.get_player(player)
if not player then error('Invalid player #1 given to Role.assign.',2) return end
if not role then return end
verbose('Assigning Roles: '..serpent.line(role)..' to: '..player.name)
-- 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
@@ -146,6 +146,7 @@ end
function Role.unassign(player,role,by_player,batch)
local player = Game.get_player(player)
if not player then error('Invalid player #1 given to Role.unassign.',2) return end
verbose('Assigning Roles: '..serpent.line(role)..' to: '..player.name)
-- 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

View File

@@ -45,7 +45,7 @@ global = _global{
function ThisModule.remove_warp_point(name)
local warp = global.warps[name]
if not warp then return end
local surface = warp.surface
local surface = game.surfaces[warp.surface]
local offset = warp.position
local tiles = {}
local tiles = {}
@@ -102,7 +102,7 @@ function ThisModule.make_warp_point(position,surface,force,name)
text='Warp: '..name,
icon={type='item',name=warp_item}
})
global.warps[name] = {tag=tag,surface=surface,position=tag.position,old_tile=old_tile}
global.warps[name] = {tag=tag,surface=surface.index,position=tag.position,old_tile=old_tile}
local _temp = {Spawn=global.warps.Spawn}
global.warps.Spawn = nil
for name,data in pairs(table.keysort(global.warps)) do _temp[name] = data end
@@ -133,7 +133,7 @@ local go_to_warp = Gui.inputs{
if player.vehicle then player.vehicle.set_driver(nil) end
if player.vehicle then player.vehicle.set_passenger(nil) end
if player.vehicle then return end
player.teleport(warp.surface.find_non_colliding_position('player',warp.position,32,1),warp.surface)
player.teleport(game.surfaces[warp.surface].find_non_colliding_position('player',warp.position,32,1),game.surfaces[warp.surface])
if not Role and not player.admin or Role and not Role.allowed(player,'always-warp') then
event.element.parent.parent.parent.parent.style.visible = false
global.cooldowns[event.player_index] = warp_limit
@@ -161,7 +161,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(warp.surface,{
player.force.add_chart_tag(game.surfaces[warp.surface],{
position=warp.position,
text='Warp: '..name,
icon={type='item',name=warp_item}