Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- ******************************************************
- -- *** GUI ***
- -- ******************************************************
- script.on_event(defines.events.on_player_joined_game,function(n)
- local player=game.players[n.player_index]
- if player.gui.center.README~=nil then player.gui.center.README.destroy() end
- if player.gui.left.PlayerList~=nil then player.gui.left.PlayerList.destroy() end
- if player.gui.top.PlayerList~=nil then player.gui.top.PlayerList.destroy() end
- drawToolbar()
- drawPlayerList()
- -- local v=encode(game.players,"players",{"name","admin","online_time","connected","index"})
- -- game.write_file("players.json",v,false)
- if (player.admin == false) and (ticktominutes(player.online_time)<1) then ReadmeGui(player,"Welcome") end
- end)
- script.on_event(defines.events.on_player_left_game,function(n)
- -- local m=game.players[n.player_index]
- drawPlayerList()
- end)
- function clearElement(s)
- if s~=nil then
- for t,u in pairs(s.children_names) do
- s[u].destroy()
- end
- end
- end
- function drawToolbar()
- for t,I in pairs(game.players) do
- local z=I.gui.top
- clearElement(z)
- -- z.add{name="btn_toolbar_rocket_score",type="button",caption="Score",tooltip="Show the satellites launched."}
- z.add{name="btn_toolbar_score",type="button",caption="Score",tooltip="Shows how well you are performing."}
- z.add{name="btn_toolbar_playerList",type="button",caption="Playerlist",tooltip="Lists player connected."}
- z.add{name="btn_readme",type="button",caption="Readme",tooltip="Rules, Server info."}
- if I.name == "Altaric" then z.add{name="btn_toolbar_spectate",type="button",caption="Spectate",tooltip="Turn into a ghost."} end
- if I.name == "Altaric" then z.add{name="btn_toolbar_test",type="button",caption="Test",tooltip="For science !"} end
- I.gui.left.direction = "vertical"
- if (I.gui.left.score == nil) then
- local frame = I.gui.left.add{name = "score", type = "frame", direction = "vertical"}
- if I.admin then frame.add{name="debug", type = "label", caption="-- Debug --"} end
- frame.add{name="difficulty", type = "label", caption="Difficulty = "}
- if (GAME_SETTING == "Comet Catcher") then
- frame.add{name="", type = "label", caption="Kill alien structures to raise your morale."}
- frame.add{name="label", type = "label", caption="Alien homes burned recently: 0"}
- end
- end
- end
- end
- function scoreGuiSwitch(J)
- if J.gui.left.score~=nil then
- J.gui.left.score.style.visible = not J.gui.left.score.style.visible
- end
- end
- function satelliteGuiSwitch(J)
- if J.gui.left.rocket_score~=nil then
- J.gui.left.rocket_score.style.visible = not J.gui.left.rocket_score.style.visible
- end
- end
- function playerListGuiSwitch(J)
- if J.gui.left.PlayerList~=nil then
- J.gui.left.PlayerList.style.visible = not J.gui.left.PlayerList.style.visible
- end
- end
- function spectate(m)
- if m.character~=nil then
- spectating[m.index]=m.character
- m.character=nil
- m.print("You are spectating.")
- else
- m.character=spectating[m.index]
- spectating[m.index]=nil
- m.print("You are no longer spectating.")
- end
- end
- function drawPlayerList()
- for _,I in pairs(game.players) do
- if I.gui.left.PlayerList==nil then I.gui.left.add{name="PlayerList",type="frame",direction="vertical"} end
- clearElement(I.gui.left.PlayerList)
- for t,m in pairs(game.connected_players) do
- if m.admin==true then
- I.gui.left.PlayerList.add{type="label",name=m.name,style="caption_label_style",caption={"",ticktominutes(m.online_time)," mn - ",m.name," [Admin]"}}
- I.gui.left.PlayerList[m.name].style.font_color={r=233,g=63,b=233}
- m.tag="*"
- else
- -- if ticktominutes(m.online_time)>=timeforRegular then
- I.gui.left.PlayerList.add{type="label",name=m.name,style="caption_label_style",caption={"",ticktominutes(m.online_time)," mn - ",m.name}}
- I.gui.left.PlayerList[m.name].style.font_color={r=24,g=172,b=188}
- m.tag=""
- -- else
- -- I.gui.left.PlayerList.add{type="label",name=m.name,style="caption_label_style",caption={"",ticktominutes(m.online_time)," mn - ",t}}
- -- I.gui.left.PlayerList[m.name].style.font_color={r=255,g=159,b=27}m.tag="[Guest]"
- -- end
- end
- end
- end
- end
- function ReadmeGui(player,page)
- if player.gui.center.README~=nil then player.gui.center.README.destroy() end
- local gui=player.gui.center.add{name="README",type="frame",direction="vertical"}
- gui.add{type="scroll-pane",name="flowContent",direction="vertical",vertical_scroll_policy="always",horizontal_scroll_policy="never"}
- gui.add{type="flow",name="flowNavigation",direction="horizontal"}
- gui.flowNavigation.add{name="btn_readme_welcome",type="button",caption="Welcome !",tooltip="Welcome message and rules."}
- gui.flowNavigation.add{name="btn_readme_scenario_info",type="button",caption="Scenario info",tooltip="Scenario information."}
- gui.flowNavigation.add{name="btn_readme_close",type="button",caption="Close",tooltip="Close the readme."}
- gui.flowContent.style.maximal_height=450
- gui.flowContent.style.minimal_height=450
- gui.flowContent.style.maximal_width=500
- gui.flowContent.style.minimal_width=500
- gui.flowNavigation.style.maximal_width=500
- gui.flowNavigation.style.minimal_width=500
- if page == "Welcome" then
- gui.caption="Welcome fellow pilgrim !"
- gui.flowContent.add{type="label",caption=[===[
- We hope that you will enjoy you stay here !
- Coding and hosting by Altaric.
- We have a few rules you will have to respect :
- - No griefing.
- - No offending language.
- We will kick/ban/rollback as necessary.
- Discord channel available at : ]===], single_line = false}
- gui.flowContent.add{type="textfield",text="https://discord.gg/kf8KKyY"}.style.minimal_width=200
- gui.flowContent.add{type="label",caption=[===[
- We value your feedback on :
- - Difficulty of the game,
- - How do you like our custom events,
- - Your ideas on things to implement,
- - Anything you like :)
- Visit us on the forums at : ]===], single_line = false}
- gui.flowContent.add{type="textfield",text="https://forums.factorio.com/viewtopic.php?f=53&t=42966"}.style.minimal_width=400
- end
- if (page == "Scenario") then fill_Readme(gui) end
- end
- script.on_event(defines.events.on_gui_click,function(n)
- local player=game.players[n.player_index]
- if n.element.name=="btn_readme" then ReadmeGui(player,"Welcome") else
- if n.element.name=="btn_readme_welcome" then ReadmeGui(player,"Welcome") else
- if n.element.name=="btn_readme_scenario_info" then ReadmeGui(player,"Scenario") else
- if n.element.name=="btn_readme_close" then player.gui.center.README.destroy() else
- if n.element.name=="btn_toolbar_spectate" then spectate(player) else
- if n.element.name=="btn_toolbar_test" then test() else
- if n.element.name=="btn_toolbar_playerList" then playerListGuiSwitch(player) else
- if n.element.name=="btn_toolbar_score" then scoreGuiSwitch(player) else
- -- if n.element.name=="btn_toolbar_rocket_score" then satelliteGuiSwitch(player)
- end end end end end end end end
- end)
- function fill_Readme(gui)
- if GAME_SETTING == "Archipellago" then
- gui.caption="Now playing : Archipellago"
- gui.flowContent.add{type="label",caption=[===[
- After the recent exploration missions, our resources are getting low.
- We have selected this planet to set up a new excavation.
- You are to pump as much resources into orbit as possible, so we can
- fuel more missions!
- Scenario details:
- - Biter bowels spit aliens every now and then
- - No evolution over time
- - Evolution from pollution: x2.5
- - Evolution from killing nest: x1
- - Pollution diffusion: x4
- - Trees: 10 times less
- This is a builder game.]===], single_line = false}
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement