summaryrefslogtreecommitdiff
path: root/gamemode
diff options
context:
space:
mode:
Diffstat (limited to 'gamemode')
-rw-r--r--gamemode/itemsystem/common.lua12
-rw-r--r--gamemode/itemsystem/common_dropable.lua5
-rw-r--r--gamemode/itemsystem/common_plantable.lua1
-rw-r--r--gamemode/itemsystem/items/anexample.lua18
-rw-r--r--gamemode/itemsystem/items/baits.lua2
-rw-r--r--gamemode/itemsystem/items/bananaseeds.lua1
-rw-r--r--gamemode/itemsystem/items/grainseeds.lua1
-rw-r--r--gamemode/itemsystem/items/melonseeds.lua1
-rw-r--r--gamemode/itemsystem/items/orangeseeds.lua1
9 files changed, 40 insertions, 2 deletions
diff --git a/gamemode/itemsystem/common.lua b/gamemode/itemsystem/common.lua
index 674c0ce..5a47c24 100644
--- a/gamemode/itemsystem/common.lua
+++ b/gamemode/itemsystem/common.lua
@@ -17,6 +17,16 @@ function startProcessGeneric(player, string, time, ondone)
end)
end
-function genericMakePlantable( tbl )
+local function plant(player, planttype)
+ print("Plant method called!")
+end
+function genericMakePlantable( tbl )
+ local plant = function(player)
+ plant(player,tbl.Name)
+ end
+ if(tbl.Actions == nil) then
+ tbl.Actions = {}
+ end
+ tbl.Actions["Plant " .. tbl.Name] = plant
end
diff --git a/gamemode/itemsystem/common_dropable.lua b/gamemode/itemsystem/common_dropable.lua
index 1f4ec7e..2b8446d 100644
--- a/gamemode/itemsystem/common_dropable.lua
+++ b/gamemode/itemsystem/common_dropable.lua
@@ -1,4 +1,5 @@
function genericMakeDroppable(tbl)
+ if(SERVER) then return end
local drop1 = function(player)
genericDropResource(player,tbl.Name,1)
end
@@ -7,6 +8,9 @@ function genericMakeDroppable(tbl)
print("Ammount:" .. Resources[tbl.Name])
genericDropResource(player,tbl.Name,Resources[tbl.Name])
end
+ local drophalf = function(player)
+ genericDropResource(player,tbl.Name,math.ceil(Resources[tbl.Name]/2.0))
+ end
local dropx = function(player)
if(SERVER) then return end
local frame = vgui.Create( "DFrame" )
@@ -32,6 +36,7 @@ function genericMakeDroppable(tbl)
tbl.Actions["Drop"] = {}
end
tbl.Actions["Drop"]["Drop 1"] = drop1
+ tbl.Actions["Drop"]["Drop Half"] = drophalf
tbl.Actions["Drop"]["Drop all"] = dropall
tbl.Actions["Drop"]["Drop X"] = dropx
end
diff --git a/gamemode/itemsystem/common_plantable.lua b/gamemode/itemsystem/common_plantable.lua
new file mode 100644
index 0000000..383d8d2
--- /dev/null
+++ b/gamemode/itemsystem/common_plantable.lua
@@ -0,0 +1 @@
+print("Hello from common_plantable.lua!")
diff --git a/gamemode/itemsystem/items/anexample.lua b/gamemode/itemsystem/items/anexample.lua
index 19cdbd7..100096f 100644
--- a/gamemode/itemsystem/items/anexample.lua
+++ b/gamemode/itemsystem/items/anexample.lua
@@ -14,5 +14,23 @@ ITEM.Icon = "test.png"
--If this item has "unique data", for example batteries that run out of charge
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.
+--Example:
+--[[
+ITEM.Actions = {
+ "Click me!" = functions(player) print("I was clicked!") end
+ "Or me!" = functions(player) print("I was clicked by " .. player:Name()) end
+ "Drop down" = {
+ "This is an item in a drop down" = function(player) print("Drop1") end
+ "Drop downs can have more drop downs!" = {
+ "Drop2" = function(player) print("Drop2") end
+ "Drop3" = function(player) print("Drop3") end
+ }
+ }
+}
+--]]
+ITEM.Actions = {}
+
--Be sure to register when everything is said and done!
GMS.RegisterResource(ITEM)
diff --git a/gamemode/itemsystem/items/baits.lua b/gamemode/itemsystem/items/baits.lua
index f6824cd..47a6fbb 100644
--- a/gamemode/itemsystem/items/baits.lua
+++ b/gamemode/itemsystem/items/baits.lua
@@ -1,7 +1,7 @@
ITEM = {}
ITEM.Name = "Baits"
-ITEM.Description = "Something you can plant!"
+ITEM.Description = "Something you can use to fish with! (Consumed automatically)"
ITEM.Icon = "test.png"
ITEM.UniqueData = false
diff --git a/gamemode/itemsystem/items/bananaseeds.lua b/gamemode/itemsystem/items/bananaseeds.lua
index 103bca9..72e14b0 100644
--- a/gamemode/itemsystem/items/bananaseeds.lua
+++ b/gamemode/itemsystem/items/bananaseeds.lua
@@ -5,6 +5,7 @@ ITEM.Description = "Something you can plant!"
ITEM.Icon = "test.png"
ITEM.UniqueData = false
+genericMakePlantable(ITEM)
genericMakeDroppable(ITEM)
GMS.RegisterResource(ITEM)
diff --git a/gamemode/itemsystem/items/grainseeds.lua b/gamemode/itemsystem/items/grainseeds.lua
index be81e5f..9057df8 100644
--- a/gamemode/itemsystem/items/grainseeds.lua
+++ b/gamemode/itemsystem/items/grainseeds.lua
@@ -5,6 +5,7 @@ ITEM.Description = "Something you can plant, or mash up into flour"
ITEM.Icon = "test.png"
ITEM.UniqueData = false
+genericMakePlantable(ITEM)
genericMakeDroppable(ITEM)
GMS.RegisterResource(ITEM)
diff --git a/gamemode/itemsystem/items/melonseeds.lua b/gamemode/itemsystem/items/melonseeds.lua
index 84d4f95..8ddaea5 100644
--- a/gamemode/itemsystem/items/melonseeds.lua
+++ b/gamemode/itemsystem/items/melonseeds.lua
@@ -6,5 +6,6 @@ ITEM.Icon = "test.png"
ITEM.UniqueData = false
genericMakeDroppable(ITEM)
+genericMakePlantable(ITEM)
GMS.RegisterResource(ITEM)
diff --git a/gamemode/itemsystem/items/orangeseeds.lua b/gamemode/itemsystem/items/orangeseeds.lua
index 39a2bec..01122c3 100644
--- a/gamemode/itemsystem/items/orangeseeds.lua
+++ b/gamemode/itemsystem/items/orangeseeds.lua
@@ -5,6 +5,7 @@ ITEM.Description = "Something you can plant!"
ITEM.Icon = "test.png"
ITEM.UniqueData = false
+genericMakePlantable(ITEM)
genericMakeDroppable(ITEM)
GMS.RegisterResource(ITEM)