diff options
| author | Bob Blackmon <bob.blackmon@ymail.com> | 2017-04-02 23:19:54 -0400 |
|---|---|---|
| committer | Bob Blackmon <bob.blackmon@ymail.com> | 2017-04-02 23:19:54 -0400 |
| commit | bae27f6ca05df3f0f34bbc2513852abaf20c34a8 (patch) | |
| tree | e882693c4380d00544986aa92b03b4bc70b2bae1 | |
| parent | 940238713695ff5ef4d516ca7322bafca23b3a89 (diff) | |
| download | zones-bae27f6ca05df3f0f34bbc2513852abaf20c34a8.tar.gz zones-bae27f6ca05df3f0f34bbc2513852abaf20c34a8.tar.bz2 zones-bae27f6ca05df3f0f34bbc2513852abaf20c34a8.zip | |
Moved Docs
| -rw-r--r-- | zone_example.lua | 82 | ||||
| -rw-r--r-- | zones/lua/zones.lua | 74 |
2 files changed, 81 insertions, 75 deletions
diff --git a/zone_example.lua b/zone_example.lua index 509eb88..737c706 100644 --- a/zone_example.lua +++ b/zone_example.lua @@ -1,4 +1,6 @@ ---This is an example usage of the zones system. +-- This is an example usage of the zones system. +-- Lots of formal documentation is at the bottom of this file. + AddCSLuaFile("zones.lua") include("zones.lua") @@ -66,3 +68,81 @@ hook.Add("ScalePlayerDamage","Arena Zone",function(ply, hitgroup, dmginfo) end end end) + + + +--[[ + --Example structure of a zone. + zones.List[1] = { -- 1 is the zone ID. Automatically assigned. + + -- points, height, bounds, and class are reserved. + points = { --List of areas in 3D space which define the zone. + { --each area is a list of points. Areas should intersect with one another but they don't have to. + Vector(), + Vector(), + Vector(), + }, + { + Vector(), + Vector(), + Vector(), + }, + }, + height = {200,100}, -- How tall each area of the zone is. Each entry corresponds to an area listed above. + bounds = { --List of the min/max points in each area. Used to speed up point-in-zone testing. These are calculated when the zone is created/changed. + { + mins=Vector(), + maxs=Vector(), + }, + { + mins=Vector(), + maxs=Vector(), + }, + }, + class = "GMaps Area", -- Zones with different classes are created and treated separately. Use zones.RegisterClass to create a new one. + + -- Zones can have any other values saved to them. If you save a player, make sure to save it as a steamid. + + } + + -- Example of the ShowZoneOptions hook. + -- This hook lets you build your custom VGUI for your zone class which will pop up when players make a new zone or edit an existing one. Clientside. + -- Arguments are: + -- zone - The full zone table of the zone we are editing. + -- class - The class of the zone. + -- DPanel - The DPanel which your VGUI elements should be parented to. + -- zoneID - The ID of the zone. + -- DFrame - The DFrame which holds it all. Not likely you will need this but it's here anyway. + -- You must return: + -- width, height; How large you want the DPanel to be. It will automatically resize. + hook.Add("ShowZoneOptions","hookname_unique",function(zone,class,DPanel,zoneID,DFrame) + if class == "Baby Got Back" then --always check class. + local w,h = 80, 100 + + local mul = vgui.Create("DNumberWang",DPanel) --parent to the panel. + mul:SetPos(5,10) + mul:SetValue(zone.onlyIfShes) --The default value should be set in the OnZoneCreated hook. + mul:SetDecimals(1) + mul:SetMinMax(0,10) + function mul:OnValueChanged(new) + -- Do your stuff here. + end + + return w, h + end + end) + + -- Example of the OnZoneCreated hook. + -- This hook lets you set up your newly created zones with default values. Only called serverside. + -- Arguments are: + -- zone - The full zone table of the zone we are editing. + -- class - The class of the zone. + -- zoneID - The ID of the zone. + hook.Add("OnZoneCreated","hookname_unique",function(zone,class,zoneID) + if class == "Baby Got Back" then --always check class. + zone.waistSize = Vector(36,24,36) + zone.onlyIfShes = "5'3\"" + end + end) +]] + diff --git a/zones/lua/zones.lua b/zones/lua/zones.lua index a903f93..80aaa91 100644 --- a/zones/lua/zones.lua +++ b/zones/lua/zones.lua @@ -52,80 +52,6 @@ zones.version = version zones.Classes = zones.Classes or {} zones.List = zones.List or {} ---[[ - --Example structure of a zone. - zones.List[1] = { -- 1 is the zone ID. Automatically assigned. - - -- points, height, bounds, and class are reserved. - points = { --List of areas in 3D space which define the zone. - { --each area is a list of points. Areas should intersect with one another but they don't have to. - Vector(), - Vector(), - Vector(), - }, - { - Vector(), - Vector(), - Vector(), - }, - }, - height = {200,100}, -- How tall each area of the zone is. Each entry corresponds to an area listed above. - bounds = { --List of the min/max points in each area. Used to speed up point-in-zone testing. These are calculated when the zone is created/changed. - { - mins=Vector(), - maxs=Vector(), - }, - { - mins=Vector(), - maxs=Vector(), - }, - }, - class = "GMaps Area", -- Zones with different classes are created and treated separately. Use zones.RegisterClass to create a new one. - - -- Zones can have any other values saved to them. If you save a player, make sure to save it as a steamid. - - } - - -- Example of the ShowZoneOptions hook. - -- This hook lets you build your custom VGUI for your zone class which will pop up when players make a new zone or edit an existing one. Clientside. - -- Arguments are: - -- zone - The full zone table of the zone we are editing. - -- class - The class of the zone. - -- DPanel - The DPanel which your VGUI elements should be parented to. - -- zoneID - The ID of the zone. - -- DFrame - The DFrame which holds it all. Not likely you will need this but it's here anyway. - -- You must return: - -- width, height; How large you want the DPanel to be. It will automatically resize. - hook.Add("ShowZoneOptions","hookname_unique",function(zone,class,DPanel,zoneID,DFrame) - if class == "Baby Got Back" then --always check class. - local w,h = 80, 100 - - local mul = vgui.Create("DNumberWang",DPanel) --parent to the panel. - mul:SetPos(5,10) - mul:SetValue(zone.onlyIfShes) --The default value should be set in the OnZoneCreated hook. - mul:SetDecimals(1) - mul:SetMinMax(0,10) - function mul:OnValueChanged(new) - -- Do your stuff here. - end - - return w, h - end - end) - - -- Example of the OnZoneCreated hook. - -- This hook lets you set up your newly created zones with default values. Only called serverside. - -- Arguments are: - -- zone - The full zone table of the zone we are editing. - -- class - The class of the zone. - -- zoneID - The ID of the zone. - hook.Add("OnZoneCreated","hookname_unique",function(zone,class,zoneID) - if class == "Baby Got Back" then --always check class. - zone.waistSize = Vector(36,24,36) - zone.onlyIfShes = "5'3\"" - end - end) -]] //Common interface functions: |
