aboutsummaryrefslogtreecommitdiff
path: root/gamemode/itemsystem/exampleitem.lua
diff options
context:
space:
mode:
authorAlexander Pickering <alexandermpickering@gmail.com>2017-01-08 22:28:08 -0500
committerAlexander Pickering <alexandermpickering@gmail.com>2017-01-08 22:28:08 -0500
commit98e0462e4f6b13ff26af5211409352d45dd9453e (patch)
treefbff14dc9a0fffdda409d9989f2e34cd4bb265f6 /gamemode/itemsystem/exampleitem.lua
parent4879eb1d78520ce0ac9b0bb0ef5244cf65ad7c99 (diff)
downloadartery-98e0462e4f6b13ff26af5211409352d45dd9453e.tar.gz
artery-98e0462e4f6b13ff26af5211409352d45dd9453e.tar.bz2
artery-98e0462e4f6b13ff26af5211409352d45dd9453e.zip
Add a ton of icons, more work on refactoring
Diffstat (limited to 'gamemode/itemsystem/exampleitem.lua')
-rw-r--r--gamemode/itemsystem/exampleitem.lua85
1 files changed, 85 insertions, 0 deletions
diff --git a/gamemode/itemsystem/exampleitem.lua b/gamemode/itemsystem/exampleitem.lua
new file mode 100644
index 0000000..066e107
--- /dev/null
+++ b/gamemode/itemsystem/exampleitem.lua
@@ -0,0 +1,85 @@
+--[[
+ An example item
+]]
+local item = {}
+
+--Required, a name, all item names must be unique
+item.Name = "Test item"
+
+--Optional, a tooltip to display when hovered over
+item.Tooltip = "An old axe, probably good for fighting."
+
+--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
+
+--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["test"] = function() print("You pressed test!") end
+ options["toste"] = function() print("You pressed toste!") end
+ return options
+end
+
+--Optional. Something run once when this item is drawn in a backpack
+function item.DoOnPanel(dimagebutton)
+ dimagebutton:SetImage( "weapons/rustyaxe/rustyaxe.png")
+end
+
+--Optional. Something run once when this item is drawn in an equiped slot
+function item.DoOnEqupPanel(dimagebutton)
+ print("called with panel:",panel)
+ dimagebutton:SetImage( "weapons/rustyaxe/rustyaxe_eq.png")
+end
+
+--Optional. Called continuously, use if you need the item to display different stuff at different tiems in the backpack.
+function item.Paint(self,width,height)
+ draw.RoundedBox(4, 0,0,width,height,Color(0,100,0))
+end
+
+--Optional. Called continuously, use if you need the item to display different stuff at different tiems when equiped.
+function item.PaintEquiped(self,width,height)
+ draw.RoundedBox(4, 0,0,width,height,Color(0,100,0))
+end
+
+--Required, the shape of this item in a backpack.
+item.Shape = {
+ {true},
+ {true},
+ {true},
+}
+
+--Optional, If this item can be equiped in any player slots, put them here.
+item.Equipable = "Right"
+
+--Optional, what to do when the player clicks, and this item is in the slot in inventory. only works for items equipable in left and right
+item.onClick = function(self,owner)
+ print("pew pew!")
+end
+
+--Optional, if we should do something special on equip(like draw the PAC for this weapon). See ART.ApplyPAC in /gamemode/shared/sh_pac.lua
+item.onEquip = function(self,who)
+ print("Oh boy! I'm getting used!")
+end
+
+--Optional, if we should do something speical on unequip(like setting PAC back to normal). Sett ART.RemovePAC in /gamemode/shared/sh_pac.lua
+item.onUnEquip = function(self,who)
+ print("Aw, I'm being stored :(")
+end
+
+--Technically optional, but item will display as a rock if you don't have it. If you want to do something other than drop on dropped, remove ent.
+item.onDropped = function(self,ent)
+ print("I've been dropped!(BUVVV WUB WUB WUB WUB WUB)")
+end
+
+print("Hello from exampleitem.lua")
+--Don't forget to register the item!
+nrequire("item.lua").RegisterItem(item)