From e014b7940d59c791c4a6e96ec27aa3232d3a39a1 Mon Sep 17 00:00:00 2001 From: Alexander Pickering Date: Sun, 22 May 2016 14:18:52 -0400 Subject: Cleaned up the comments in the itemsystem --- gamemode/configure_me.lua | 23 +++++++++-------------- gamemode/itemsystem/common.lua | 10 +++++++--- gamemode/itemsystem/common_dropable.lua | 25 +++++++++++++------------ gamemode/itemsystem/common_plantable.lua | 12 ++++++++---- gamemode/itemsystem/items/aaaItemExample.lua | 2 +- gamemode/itemsystem/loaditems.lua | 15 +++++++++++++-- 6 files changed, 51 insertions(+), 36 deletions(-) (limited to 'gamemode') diff --git a/gamemode/configure_me.lua b/gamemode/configure_me.lua index 4c007f7..f7651af 100644 --- a/gamemode/configure_me.lua +++ b/gamemode/configure_me.lua @@ -27,20 +27,14 @@ GMS.NETINT_BITCOUNT = 16 // time in seconds GMS.graveTime = { - - { - - rank = "user", - time = "300", - - }, - { - - rank = "superadmin", - time = "420", - - }, - + { + rank = "user", + time = "300", + }, + { + rank = "superadmin", + time = "420", + }, } //NPC's that drop loot balls @@ -76,6 +70,7 @@ GMS.AllowedStools = { "material", } +GAMEMODE = GM or {} //Configuration for how data is saved //Can be: "GLON", "VON"(CURRENTLY BROKEN), "PON", "JSON" GAMEMODE.Compressor = "PON" diff --git a/gamemode/itemsystem/common.lua b/gamemode/itemsystem/common.lua index 512bec5..edaac31 100644 --- a/gamemode/itemsystem/common.lua +++ b/gamemode/itemsystem/common.lua @@ -1,9 +1,13 @@ --This file holds a bunch of common functions that happen in items. They're seperated out here so that they're easy to change if there's a bug somewhere. +--[[ +Provides: + startProcessGeneric(player_player, string_message, number_time, function_ondone) + Freezes the player, creates the loading bar, and calls ondone when the timer is up. +]] ---Freezes the player, creates the loading bar, and calls ondone when the timer is up. function startProcessGeneric(player, string, time, ondone) - if(player.InProcess) then - self.Owner:SendMessage("You can't do that much at once!", 3, Color(255, 255, 255, 255)) + if (player.InProcess) then + player:SendMessage("You can't do that much at once!", 3, Color(255, 255, 255, 255)) return end player.InProcess = true diff --git a/gamemode/itemsystem/common_dropable.lua b/gamemode/itemsystem/common_dropable.lua index 046d628..b77b336 100644 --- a/gamemode/itemsystem/common_dropable.lua +++ b/gamemode/itemsystem/common_dropable.lua @@ -1,10 +1,11 @@ ---Adds a function to to allow the player to drop this item, in quantities of 1, half, all, or X, which brings up a menu asking the player how many they would like to drop --[[ - genericMakeDroppable(ITEM) + Provides: + genericMakeDroppable(table_item) + Adds a function to to allow the player to drop this item, in quantities of 1, half, all, or X, which brings up a menu asking the player how many they would like to drop ]] function genericMakeDroppable(tbl) - if(SERVER) then return end + if (SERVER) then return end local drop1 = function(player) genericDropResource(player,tbl.Name,1) end @@ -12,10 +13,10 @@ function genericMakeDroppable(tbl) genericDropResource(player,tbl.Name,Resources[tbl.Name]) end local drophalf = function(player) - genericDropResource(player,tbl.Name,math.ceil(Resources[tbl.Name]/2.0)) + genericDropResource(player,tbl.Name,math.ceil(Resources[tbl.Name] / 2.0)) end local dropx = function(player) - if(SERVER) then return end + if (SERVER) then return end local frame = vgui.Create( "DFrame" ) frame:SetSize( 400, 60 ) frame:Center() @@ -26,16 +27,16 @@ function genericMakeDroppable(tbl) TextEntry:SetSize( 360, 20 ) TextEntry:SetText( "Number to drop:" ) TextEntry.OnEnter = function( self ) - if(tonumber(self:GetValue(),10) == nil) then return end + if (tonumber(self:GetValue(),10) == nil) then return end genericDropResource(player,tbl.Name,self:GetValue()) frame:Close() end end - if(tbl.Actions == nil) then + if (tbl.Actions == nil) then tbl.Actions = {} end - if(tbl.Actions["Drop"] == nil) then + if (tbl.Actions["Drop"] == nil) then tbl.Actions["Drop"] = {} end tbl.Actions["Drop"]["Drop 1"] = drop1 @@ -45,18 +46,18 @@ function genericMakeDroppable(tbl) end -if(SERVER) then +if (SERVER) then util.AddNetworkString( "gms_dropresources" ) end function genericDropResource(player, resource, ammount) - if(CLIENT) then + if (CLIENT) then net.Start("gms_dropresources") net.WriteString(resource) net.WriteInt(ammount,GMS.NETINT_BITCOUNT) net.SendToServer() end - if(SERVER) then - if(player.Resources[resource] < ammount) then + if (SERVER) then + if (player.Resources[resource] < ammount) then player:SendMessage("You don't have that many to drop!", 3, Color(255, 255, 255, 255)) return end diff --git a/gamemode/itemsystem/common_plantable.lua b/gamemode/itemsystem/common_plantable.lua index d99a8d5..4570dc8 100644 --- a/gamemode/itemsystem/common_plantable.lua +++ b/gamemode/itemsystem/common_plantable.lua @@ -1,7 +1,11 @@ --[[ -You can call genericMakePlantable(ITEM) on items to make them have a plant option. -Before genericMakePlantable get called, be sure the item has an .GrowTime =number -and a .OnGrow = function(player) +Provides: + genericMakePlantable(table_item) + You can call genericMakePlantable(table_item) on items to make them have a plant option. Before genericMakePlantable get called, be sure the item has an .GrowTime =number and a .OnGrow = function(player_player) + GAMEMODE.MakeGenericPlantChild(player_ply, vector_pos, string_model, entity_parent) + Creates a child on the plant(like oranges or melons on their bush), with player as the owner, at the given position(relative to the plant), with the given model, the parrent is the entity that will be removed once all the children are removed. If ply is nil, then the plant will be owned by world. + GAMEMODE.MakeGenericPlant(player_ply, vector_pos, string_model, boolean_isWorld ) + Creates a plant with the specified string, at the position, with ply as the ower. If isWorld is true, the owner is the world instead (like trees) ]] if (SERVER) then @@ -18,7 +22,7 @@ local function plant(player, resourcename) assert(tbl.GrowTime != nil,tbl.Name .. " .GrowTime is nil!") assert(isfunction(tbl.OnGrow),tbl.Name .. " .OnGrow is not a table") - if(player:GetNWInt("plants") > GetConVar("gms_PlantLimit"):GetInt()-1) then + if (player:GetNWInt("plants") > GetConVar("gms_PlantLimit"):GetInt() - 1) then player:SendMessage( "You man only have " .. GetConVar("gms_PlantLimit"):GetInt() .. " plants at a time.", 3, Color( 10, 200, 10, 255 ) ) return end diff --git a/gamemode/itemsystem/items/aaaItemExample.lua b/gamemode/itemsystem/items/aaaItemExample.lua index eb06b3b..bd1623e 100644 --- a/gamemode/itemsystem/items/aaaItemExample.lua +++ b/gamemode/itemsystem/items/aaaItemExample.lua @@ -17,7 +17,7 @@ ITEM.UniqueData = false --A table of strings to functions that show up when the player clicks the item in their inventory. --The you may also use strings to tables of strings to functions (and so on) to make drop-down menus. ---Keep in mind these are called on the CLIENT, so if you want something to happen on the server, you have to send it net! +--Keep in mind these are called on the CLIENT, so if you want something to happen on the server, you have to send it with the net library! --Example: --[[ ITEM.Actions = { diff --git a/gamemode/itemsystem/loaditems.lua b/gamemode/itemsystem/loaditems.lua index 225e56d..8afd9b9 100644 --- a/gamemode/itemsystem/loaditems.lua +++ b/gamemode/itemsystem/loaditems.lua @@ -1,16 +1,27 @@ //Loads Loads all the items in the gamemode, these should go into gamemode/itemsystem/itmes folder. //Also adds a console command gms_printrestable, that prints all the (base) resource tables and their values. //Keep in mind that if an item has UniqueData set to true, it's instance may be different than that shown in gms_printrestable +--[[ +Provides: + GMS.Resources + A table of resources, keyed by name. You probably shouldn't modify this directly. + GMS.RegisterResource(table_resource) + Adds the table to GMS.Resources, keep in mind that items are indexed by name, so 2 items may not share the same name. The table must also have a .Name field. + GMS.GetResourceByName(string_name) + Returns the resource table associated with the name. + gms_printrestable + A console command that prints out the entire resource table, useful for developers! +]] GMS.Resources = {} function GMS.RegisterResource( tbl ) assert(tbl != nil,"Attempted to register a nil entity! This might be a bug!") assert(tbl.Name != nil,"Attempted to register an item with no name:") - if(tbl.UniqueData) then + if (tbl.UniqueData) then tbl.UniqueDataID = -1 end - GMS.Resources[tbl.Name] = tbl + GMS.Resources[tbl.Name] = tbl end function GMS.GetResourceByName(name) -- cgit v1.2.3-70-g09d2