From 74c7a160da34897ebdf18aaff02b8c9b65809949 Mon Sep 17 00:00:00 2001 From: Alexander Pickering Date: Mon, 24 Oct 2016 12:12:19 -0400 Subject: Various other updates and bugfixes --- gamemode/client/areas/loadareas.lua | 3 + gamemode/client/cl_systems.lua | 4 -- gamemode/client/qpanels/inventory.lua | 11 ++++ gamemode/shared.lua | 42 ++++++++++++ gamemode/shared/animations/move_evade.lua | 75 ++++++++++++++++++++++ gamemode/shared/inventory.lua | 2 +- gamemode/shared/itemcommon/common_inventory.lua | 4 -- gamemode/shared/itemsystem/armor/balaclava.lua | 2 - .../shared/itemsystem/foodstuffs/watermelon.lua | 51 +++++++++++++++ gamemode/shared/itemsystem/quest/rougebadge.lua | 38 +++++++++++ gamemode/shared/sh_buff.lua | 31 --------- 11 files changed, 221 insertions(+), 42 deletions(-) create mode 100644 gamemode/client/areas/loadareas.lua delete mode 100644 gamemode/client/cl_systems.lua create mode 100644 gamemode/shared/animations/move_evade.lua delete mode 100644 gamemode/shared/itemcommon/common_inventory.lua create mode 100644 gamemode/shared/itemsystem/foodstuffs/watermelon.lua create mode 100644 gamemode/shared/itemsystem/quest/rougebadge.lua delete mode 100644 gamemode/shared/sh_buff.lua (limited to 'gamemode') diff --git a/gamemode/client/areas/loadareas.lua b/gamemode/client/areas/loadareas.lua new file mode 100644 index 0000000..a8c506d --- /dev/null +++ b/gamemode/client/areas/loadareas.lua @@ -0,0 +1,3 @@ +--[[ + Loads the area names for the current map +]] diff --git a/gamemode/client/cl_systems.lua b/gamemode/client/cl_systems.lua deleted file mode 100644 index 0165239..0000000 --- a/gamemode/client/cl_systems.lua +++ /dev/null @@ -1,4 +0,0 @@ ---[[ - Something to display all the systems delt with serverside -]] -local systems = {} diff --git a/gamemode/client/qpanels/inventory.lua b/gamemode/client/qpanels/inventory.lua index f4adad6..9fec1cc 100644 --- a/gamemode/client/qpanels/inventory.lua +++ b/gamemode/client/qpanels/inventory.lua @@ -4,6 +4,17 @@ invfuncs = ART.invfuncs --invfuncs = include("../shared/inventory_common.lua") assert(invfuncs ~= nil, "Dependency failed") +local function createMenuFor(menu, tbl) + for k,v in pairs(tbl) do + if isfunction(v) then --This is a dead-end, add the menu + local thisoption = menu:AddOption(k,v) + else --Otherwise it should be a table, recursively call to create + local submenu = menu:AddSubMenu(k) + createMenuFor(submenu,v) + end + end +end + local function DrawBackpackOnDPanel(dp, backpack, backpacknum, tent) local width = ScrW() local height = ScrH() diff --git a/gamemode/shared.lua b/gamemode/shared.lua index c69113f..8f8483f 100644 --- a/gamemode/shared.lua +++ b/gamemode/shared.lua @@ -12,10 +12,52 @@ GM.Email = "apickx@cogarr.org" GM.Website = "cogarr.net" --Some global functions that are helpful +-- printf +-- assertf +-- curry +-- typecheck + +--printf from C function printf(fmt, ...) print(string.format(fmt,...)) end +--Assert with a formated string +function assertf(cond, fmt, ...) + assert(cond,string.format(fmt,...)) +end + +--Curry from lisp, allows you to store variables "in" a function, so you can call it with fewer arguments if you'll be repeating arguments a lot +--Ex: +-- >dbprint = curry(print,"[Debug]") +-- >dbprint("Hello, world!") +-- [Debug] Hello, world! +-- > +function curry(fnc, ...) + local oarg = {...} + return function(...) + return fnc(unpack(oarg),unpack({...})) + end +end + +--Does type checking for functions, use by supplying a table whith the variables and the types they should be +--Ex: +-- >local somefunction(str, tbl, num) +-- >>typecheck({ +-- >> str,"string", +-- >> tbl,"table", +-- >> num,"number" +-- >>}) +-- > +function typecheck(...) + local tbl = {...} + tbl = type(tbl[1]) == "table" and tbl[1] or tbl + for k=1,#tbl,2 do + local t,n = type(tbl[k]),tbl[k+1] + assertf(t == n, "Passed argument of wrong type, should have been %q but was %q",t,n ) + end +end + --Add a thing to report errors to a master server --TODO:Set up a master server to collect errors for correction local olderr = error diff --git a/gamemode/shared/animations/move_evade.lua b/gamemode/shared/animations/move_evade.lua new file mode 100644 index 0000000..a5595aa --- /dev/null +++ b/gamemode/shared/animations/move_evade.lua @@ -0,0 +1,75 @@ +RegisterLuaAnimation('evade_left', { + FrameData = { + { + BoneInfo = { + ['ValveBiped.Bip01_L_Calf'] = { + }, + ['ValveBiped.Bip01_L_Thigh'] = { + }, + ['ValveBiped.Bip01_R_Thigh'] = { + }, + ['ValveBiped.Bip01_Pelvis'] = { + } + }, + FrameRate = 1 + }, + { + BoneInfo = { + ['ValveBiped.Bip01_L_Calf'] = { + RU = -44.9346, + RR = -4.9288, + RF = 5.1193 + }, + ['ValveBiped.Bip01_L_Thigh'] = { + RU = 49.7508, + RR = 11.8895, + RF = 74.14 + }, + ['ValveBiped.Bip01_R_Thigh'] = { + RU = 6.3191, + RR = 12.8315, + RF = -4.8611 + }, + ['ValveBiped.Bip01_Pelvis'] = { + } + }, + FrameRate = 4 + }, + { + BoneInfo = { + ['ValveBiped.Bip01_L_Calf'] = { + RU = -44.9346, + RR = -4.9288, + RF = 5.1193 + }, + ['ValveBiped.Bip01_L_Thigh'] = { + RU = 49.7508, + RR = 11.8895, + RF = 74.14 + }, + ['ValveBiped.Bip01_Pelvis'] = { + }, + ['ValveBiped.Bip01_R_Thigh'] = { + RU = 6.3191, + RR = 12.8315, + RF = -4.8611 + } + }, + FrameRate = 4 + }, + { + BoneInfo = { + ['ValveBiped.Bip01_L_Calf'] = { + }, + ['ValveBiped.Bip01_L_Thigh'] = { + }, + ['ValveBiped.Bip01_Pelvis'] = { + }, + ['ValveBiped.Bip01_R_Thigh'] = { + } + }, + FrameRate = 2 + } + }, + Type = TYPE_STANCE +}) diff --git a/gamemode/shared/inventory.lua b/gamemode/shared/inventory.lua index 382ebd5..f83bb77 100644 --- a/gamemode/shared/inventory.lua +++ b/gamemode/shared/inventory.lua @@ -97,7 +97,7 @@ end -- @return n The backpack number the item was found in. function pmeta:HasItem(nameorcomparitor) local comparitor - if type(param) == "String" then + if type(nameorcomparitor) == "string" then comparitor = function(t) return t.Name == nameorcomparitor end else comparitor = nameorcomparitor diff --git a/gamemode/shared/itemcommon/common_inventory.lua b/gamemode/shared/itemcommon/common_inventory.lua deleted file mode 100644 index f541ecc..0000000 --- a/gamemode/shared/itemcommon/common_inventory.lua +++ /dev/null @@ -1,4 +0,0 @@ ---[[ - Stores some common functions related to items -]] -local common = {} diff --git a/gamemode/shared/itemsystem/armor/balaclava.lua b/gamemode/shared/itemsystem/armor/balaclava.lua index 177fa93..d77da61 100644 --- a/gamemode/shared/itemsystem/armor/balaclava.lua +++ b/gamemode/shared/itemsystem/armor/balaclava.lua @@ -77,5 +77,3 @@ end print("Hello from balaclava.lua") --Don't forget to register the item! ART.RegisterItem(item) -print("After registering balaclava, items are:") -PrintTable(ART.Items) diff --git a/gamemode/shared/itemsystem/foodstuffs/watermelon.lua b/gamemode/shared/itemsystem/foodstuffs/watermelon.lua new file mode 100644 index 0000000..76c0398 --- /dev/null +++ b/gamemode/shared/itemsystem/foodstuffs/watermelon.lua @@ -0,0 +1,51 @@ +--[[ + 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}, +} + +print("Hello from exampleitem.lua") +--Don't forget to register the item! +ART.RegisterItem(item) diff --git a/gamemode/shared/itemsystem/quest/rougebadge.lua b/gamemode/shared/itemsystem/quest/rougebadge.lua new file mode 100644 index 0000000..dad0f71 --- /dev/null +++ b/gamemode/shared/itemsystem/quest/rougebadge.lua @@ -0,0 +1,38 @@ +--[[ + An example item +]] +local item = {} + +--Required, a name, all item names must be unique +item.Name = "Rouge Newbie Badge" + +--Optional, a tooltip to display when hovered over +item.Tooltip = "A tiny peice of metal, kinda looks like a dagger." + +--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 + +--Required, the shape of this item in a backpack. +item.Shape = { + {true} +} + + +ART.RegisterItem(item) diff --git a/gamemode/shared/sh_buff.lua b/gamemode/shared/sh_buff.lua deleted file mode 100644 index ac46df9..0000000 --- a/gamemode/shared/sh_buff.lua +++ /dev/null @@ -1,31 +0,0 @@ ---This was probably a mistake -do return end - -local pmeta = FindMetaTable("Player") - -pmeta.buffs = {} -local buffid = 0 -function pmeta:ApplyBuff(buff) - if self.buffs[buff.type] == nil then - self.buffs[buff.type] = {} - end - local id = buffid - buffid = buffid + 1 - self.buffs[buff.type][id] = buff - self.buffs[id] = buff.type - return id -end - -function pmeta:RemoveBuff(buffid) - local bufftype = self.buffs[buffid] - self.buffs[buff.type][buffid] = nil - self.buffs[buffid] = nil -end - -hook.Add("EntityTakeDamage","arterybuffs",function(ent,info) - -end) - ---[[ - Add buff types here I guess -]] -- cgit v1.2.3-70-g09d2