summaryrefslogtreecommitdiff
path: root/lua/autorun/zone_output.lua
diff options
context:
space:
mode:
authorAlexander Pickering <alexandermpickering@gmail.com>2017-09-02 17:33:23 -0400
committerAlexander Pickering <alexandermpickering@gmail.com>2017-09-02 17:33:23 -0400
commit9cafd07d43443a662bd279d4a303586e29d92a4e (patch)
tree91f10000f6ec6ef0e004c146909945ffed885772 /lua/autorun/zone_output.lua
parent147c4b979de268fdf45c01beb0bb877d32e3e32c (diff)
downloadartery_editor-9cafd07d43443a662bd279d4a303586e29d92a4e.tar.gz
artery_editor-9cafd07d43443a662bd279d4a303586e29d92a4e.tar.bz2
artery_editor-9cafd07d43443a662bd279d4a303586e29d92a4e.zip
Various updates
Diffstat (limited to 'lua/autorun/zone_output.lua')
-rw-r--r--lua/autorun/zone_output.lua66
1 files changed, 66 insertions, 0 deletions
diff --git a/lua/autorun/zone_output.lua b/lua/autorun/zone_output.lua
new file mode 100644
index 0000000..d887386
--- /dev/null
+++ b/lua/autorun/zone_output.lua
@@ -0,0 +1,66 @@
+--[[
+ A hunting ground zone will occasionally spawn a monster near a player that will go attack the player
+]]
+zones.RegisterClass("artery_outpost",Color(0,255,0))
+
+--Use this to set default properties. Only called on server.
+hook.Add("OnZoneCreated","artery_outpost",function(zone,class,zoneID)
+ if class == "artery_artery_outpost" then
+ zone.datatbl = {}
+ end
+end)
+
+-- Use this hook to let a player change a zone after making it or with the edit tool.
+-- class is zone.class, zone is the zone's full table, DPanel is a panel to parent your things to, zoneID is the zone's ID, DFrame is the whole frame.
+-- Return your preferred width and height for the panel and the frame will size to it.
+hook.Add("ShowZoneOptions","artery_outpost",function(zone,class,DPanel,zoneID,DFrame)
+ if class == "artery_town" then
+ local w,h = 500, 400
+
+ local scroll = vgui.Create( "DScrollPanel",DPanel)
+ scroll:Dock(FILL)
+
+ function synctbl()
+ net.Start("artery_outpost_settbl")
+ net.WriteFloat(zoneID)
+ net.WriteTable(zone.datatbl)
+ net.SendToServer()
+ end
+
+ print("Displaying table, my table is")
+ PrintTable(zone.datatbl)
+
+ local monsterlb = vgui.Create("DLabel",DPanel)
+ monsterlb:Dock(TOP)
+ monsterlb:SetText("Town name:")
+ monsterlb:SetDark(true)
+ monsterlb:SizeToContents()
+ local groundsname = vgui.Create("DTextEntry",DPanel)
+ groundsname:SetText(zone.datatbl.Name or "")
+ groundsname:Dock(TOP)
+ groundsname.OnEnter = function()
+ zone.datatbl.Name = groundsname:GetValue()
+ synctbl()
+ end
+
+ return w, h -- Specify the width and height for the DPanel container. The frame will resize accordingly.
+
+ end
+end)
+
+if SERVER then
+ util.AddNetworkString("artery_town_settbl")
+ net.Receive("artery_town_settbl",function(len,ply)
+ print("Server change received!")
+ local id, new = net.ReadFloat(), net.ReadTable()
+ print("New table is:")
+ PrintTable(new)
+ if not ply:IsAdmin() then return end
+ local zone = zones.List[id]
+ zone.datatbl = new
+ if new.Name then
+ zone.Name = new.Name
+ end
+ zones.Sync()
+ end)
+end