aboutsummaryrefslogtreecommitdiff
path: root/gamemode/shared/itemsystem/foodstuffs/watermelon.lua
blob: 2b9f7cbd0d553bd6811eb5b99d7a604ab5271eb1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
--[[
    An example item
]]
local item = {}

--Required, a name, all item names must be unique
item.Name = "Watermelon"

--Optional, a tooltip to display when hovered over
item.Tooltip = "Where do they grow these in an apocolyptic wasteland???"

--Required Returns the data needed to rebuild this item, should only contain the minimum data nessessary since this gets sent over the network
item.Serialize = function(self)
    print("Trying to serailize!")
    return ""
end

--Required, Rebuilds the item from data created in Serialize, if the item is different from the "main" copy of the item, it should retun a tabl.Copy(self), with the appropriate fields set.
item.DeSerialize = function(self,string)
    print("Trying to deserialize!")
    return self
end
if SERVER then
	util.AddNetworkString("eat_watermelon")
	net.Receive("eat_watermelon", function(len,ply)
		local row,col,bp = ply:HasItem("Watermelon")
	    if row and col and bp then
	        ply:RemoveItemAt(bp,row,col)
		end
	end)
end
--Optional, when the player clicks this item, a menu will show up, if the menu item is clicked, the function is ran. This is all run client side, so if you want it to do something server side, you'll need to use the net library. Remember that items are in the shared domain, so you can define what it does in the same file!
function item.GetOptions(self)
    local options = {}
    options["eat"] = function()
		net.Start("eat_watermelon")
		net.SendToServer()
	end
    return options
end

--Required, the shape of this item in a backpack.
item.Shape = {
    {true,true,true},
    {true,true,true},
    {true,true,true},
}

item.onDropped = function(self, ent)
    ART.ApplyPAC(ent,"Watermelon")
end

print("Hello from exampleitem.lua")
--Don't forget to register the item!
ART.RegisterItem(item)