summaryrefslogtreecommitdiff
path: root/gamemode/itemsystem/items/aaaItemExample.lua
blob: eb06b3b413fdab3fff787e9a39d77518aa5522b4 (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
--This file is to help developers add new items to the game

ITEM = {}

--The name of this item
ITEM.Name = "An Example"

--A description that shows up when hovering over the item in the inventory
ITEM.Description = "Why did I even write this? No one will ever read it!"

--The icon that this item uses, relative to the gmsurvival/content/materials directory
ITEM.Icon = "test.png"

--If this item has "unique data", for example batteries that run out of charge
--If true, then the item must define a table .UniqueFields, an array of strings that tell what fields are unique.
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!
--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 = {}

--Additional function you might want to use:
--[[
makeGenericDroppable(ITEM)
  Allows the resource to be dropped in multiples of 1, half, all, or X
  Located in common_droppable.lua
makeGenericPlantable(ITEM)
  Make sure you have a ITEM.GrowTime set to a number, and a ITEM.OnGrow = function(self, aor, owner)
  Located in common_plantable.lua
]]

--Be sure to register when everything is said and done!
GMS.RegisterResource(ITEM)