summaryrefslogtreecommitdiff
path: root/gamemode/itemsystem
diff options
context:
space:
mode:
authorAlexander Pickering <alexandermpickering@gmail.com>2016-05-22 14:18:52 -0400
committerAlexander Pickering <alexandermpickering@gmail.com>2016-05-22 14:18:52 -0400
commite014b7940d59c791c4a6e96ec27aa3232d3a39a1 (patch)
tree515ff14cf73b236d2159ea2703502abce0f3781f /gamemode/itemsystem
parenteea3fcb40b4a52e5985859bf6bb77d3384d4d0f7 (diff)
downloadgmstranded-e014b7940d59c791c4a6e96ec27aa3232d3a39a1.tar.gz
gmstranded-e014b7940d59c791c4a6e96ec27aa3232d3a39a1.tar.bz2
gmstranded-e014b7940d59c791c4a6e96ec27aa3232d3a39a1.zip
Cleaned up the comments in the itemsystem
Diffstat (limited to 'gamemode/itemsystem')
-rw-r--r--gamemode/itemsystem/common.lua10
-rw-r--r--gamemode/itemsystem/common_dropable.lua25
-rw-r--r--gamemode/itemsystem/common_plantable.lua12
-rw-r--r--gamemode/itemsystem/items/aaaItemExample.lua2
-rw-r--r--gamemode/itemsystem/loaditems.lua15
5 files changed, 42 insertions, 22 deletions
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)