Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function init_global( )
- global["newForceModData"] = {}
- end
- function set_gloal(name,value)
- if (global["newForceModData"] == nil) then
- init_global()
- end
- global["newForceModData"][name] = value
- end
- function get_global(name)
- if (global["newForceModData"] == nil) then
- init_global()
- end
- return global["newForceModData"][name]
- end
- function befriendRadarForce(force)
- local radar_force = get_global("radar_force")
- if(radar_force == nil) then
- radar_force = game.create_force("Radars Force")
- set_gloal("radar_force",radar_force)
- radar_force.share_chart = true
- end
- radar_force.set_friend(force,true)
- force.set_friend(radar_force,true)
- end
- function createPlayerForce( player )
- local player_forces = get_global("player forces")
- if (player_forces == nil) then
- player_forces = {}
- end
- local newForceName = player.name .. " force"
- local newForce = game.create_force(newForceName)
- player_forces[newForceName] = newForce
- set_gloal("player forces",player_forces) --update global variable
- return newForce
- end
- function on_player_created(event)
- local player = game.players[event.player_index]
- local newForce = createPlayerForce(player)
- game.print('1' .. player.force.name)
- game.print('2' .. newForce.name)
- player.force = newForce
- game.print('3' .. player.force.name)
- game.print('4' .. newForce.name)
- newForce.share_chart = true
- befriendRadarForce(newForce)
- game.print('5' .. player.force.name)
- game.print('6' .. newForce.name)
- end
- function on_built_entity(event)
- local entity = event.created_entity
- if (entity.name == "radar") then
- entity.surface.create_entity{name="radar", position=entity.position, force=get_global("radar_force")}
- entity.destroy()
- end
- end
- script.on_event(defines.events.on_player_created, on_player_created)
- script.on_event(defines.events.on_built_entity, on_built_entity)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement