summaryrefslogtreecommitdiff
path: root/gamemode/itemsystem/items/berry.lua
diff options
context:
space:
mode:
Diffstat (limited to 'gamemode/itemsystem/items/berry.lua')
-rw-r--r--gamemode/itemsystem/items/berry.lua49
1 files changed, 48 insertions, 1 deletions
diff --git a/gamemode/itemsystem/items/berry.lua b/gamemode/itemsystem/items/berry.lua
index 610147f..2021ffd 100644
--- a/gamemode/itemsystem/items/berry.lua
+++ b/gamemode/itemsystem/items/berry.lua
@@ -1,6 +1,53 @@
ITEM = {}
-ITEM.Name = "Berry"
+ITEM.Name = "Berries"
ITEM.Description = "A delicious edible!"
+ITEM.Icon = "test.png"
+ITEM.UniqueData = false
+
+if(SERVER) then
+ util.AddNetworkString( "gms_eatberry" )
+end
+
+local eat = function(ln, player)
+ if(CLIENT) then
+ net.Start("gms_eatberry")
+ net.SendToServer()
+ end
+ if(SERVER) then
+ if(player.Resources[ITEM.Name] <= 0) then
+ player:SendMessage( "You don't have enough to do that!", 3, Color( 10, 200, 10, 255 ) )
+ return
+ end
+ startProcessGeneric(player,"Eating some berries",3,function()
+ player:DecResource( "Berries", 1 )
+ player:SendMessage( "You're a little less hungry and thirsty now.", 3, Color( 10, 200, 10, 255 ) )
+ --Set hunger and thirst
+ player:SetFood(math.Clamp(player.Hunger+100,0,1000))
+ player:SetThirst(math.Clamp(player.Thirst+100,0,1000))
+ end)
+ end
+end
+net.Receive( "gms_eatberry", eat)
+
+local drop1 = function(player)
+ genericDropResource(player,ITEM.Name,1)
+end
+
+local dropall = function(player)
+ genericDropResource(player,ITEM.Name,9999)
+end
+
+local dropx = function(player)
+ print("Drop x called")
+end
+
+ITEM.Actions = {}
+ITEM.Actions["EatBerry"] = eat
+
+ITEM.Actions["Drop"] = {}
+ITEM.Actions["Drop"]["Drop 1"] = drop1
+ITEM.Actions["Drop"]["Drop all"] = dropall
+ITEM.Actions["Drop"]["Drop X"] = dropx
GMS.RegisterResource(ITEM)