aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Pickering <alexandermpickering@gmail.com>2017-01-04 23:27:36 -0500
committerAlexander Pickering <alexandermpickering@gmail.com>2017-01-04 23:27:36 -0500
commit4879eb1d78520ce0ac9b0bb0ef5244cf65ad7c99 (patch)
treeac47724191a8959c19b2408d4da384d64b6098ec
parent2c4329e2b6e19182a441f79a5c3010011f8ae767 (diff)
downloadartery-4879eb1d78520ce0ac9b0bb0ef5244cf65ad7c99.tar.gz
artery-4879eb1d78520ce0ac9b0bb0ef5244cf65ad7c99.tar.bz2
artery-4879eb1d78520ce0ac9b0bb0ef5244cf65ad7c99.zip
Started refactoring item and inventory system
-rw-r--r--entities/entities/art_chest/cl_init.lua2
-rw-r--r--entities/entities/art_chipmill/cl_init.lua121
-rw-r--r--entities/entities/art_chipmill/init.lua81
-rw-r--r--entities/entities/art_chipmill/shared.lua30
-rw-r--r--entities/entities/art_lootchest/cl_init.lua1
-rw-r--r--entities/entities/art_lootchest/init.lua6
-rw-r--r--entities/entities/npc_shop/cl_init.lua1
-rw-r--r--entities/entities/npc_shop/init.lua41
-rw-r--r--gamemode/autolua.lua1
-rw-r--r--gamemode/client/cl_inventory.lua163
-rw-r--r--gamemode/client/cl_legs.lua47
-rw-r--r--gamemode/client/hud/cl_healthbar.lua (renamed from gamemode/client/healthbar.lua)0
-rw-r--r--gamemode/client/qpanels/inventory.lua1
-rw-r--r--gamemode/client/qpanels/prayers.lua2
-rw-r--r--gamemode/client/qpanels/quests.lua2
-rw-r--r--gamemode/client/qpanels/skills.lua2
-rw-r--r--gamemode/config/colortheme.lua29
-rw-r--r--gamemode/core/inventory/inventory.lua135
-rw-r--r--gamemode/core/inventory/item.lua67
-rw-r--r--gamemode/init.lua2
-rw-r--r--gamemode/inventorysystem/equipment.lua67
-rw-r--r--gamemode/nrequire.lua171
-rw-r--r--gamemode/server/test/testfile.lua48
-rw-r--r--gamemode/shared.lua78
-rw-r--r--gamemode/shared/aes.lua524
-rw-r--r--gamemode/shared/inventory.lua2
-rw-r--r--gamemode/shared/inventory_common.lua1
-rw-r--r--gamemode/shared/itemsystem/exampleitem.lua2
-rw-r--r--gamemode/shared/loadnpcs.lua2
-rw-r--r--gamemode/shared/loadprayers.lua1
-rw-r--r--gamemode/shared/lockbox/array.lua210
-rw-r--r--gamemode/shared/lockbox/base64.lua157
-rw-r--r--gamemode/shared/lockbox/bit.lua11
-rw-r--r--gamemode/shared/lockbox/ecb.lua191
-rw-r--r--gamemode/shared/lockbox/padding.lua21
-rw-r--r--gamemode/shared/lockbox/queue.lua47
-rw-r--r--gamemode/shared/lockbox/stream.lua112
-rw-r--r--gamemode/shared/log.lua23
-rw-r--r--gamemode/utility/fn.lua229
-rw-r--r--gamemode/utility/fuzzel.lua (renamed from gamemode/shared/fuzzel.lua)0
-rw-r--r--gamemode/utility/stream.lua85
41 files changed, 875 insertions, 1841 deletions
diff --git a/entities/entities/art_chest/cl_init.lua b/entities/entities/art_chest/cl_init.lua
index 1ba18b4..89745c0 100644
--- a/entities/entities/art_chest/cl_init.lua
+++ b/entities/entities/art_chest/cl_init.lua
@@ -1,6 +1,6 @@
include('shared.lua')
--local invfuncs = include("../../../gamemode/shared/inventory_common.lua")
-local invfuncs = ART.invfuncs
+local invfuncs = nrequire("inventory/inventory.lua")
ENT.RenderGroup = RENDERGROUP_BOTH
diff --git a/entities/entities/art_chipmill/cl_init.lua b/entities/entities/art_chipmill/cl_init.lua
deleted file mode 100644
index 6eb1d1f..0000000
--- a/entities/entities/art_chipmill/cl_init.lua
+++ /dev/null
@@ -1,121 +0,0 @@
-
-ART.chips = {}
-ART.RegisterChipType = function(tbl)
- assert(ART.chips[tbl.Name] == nil,"Trying to register a chip twice:"..tbl.Name)
- ART.chips[tbl.Name] = tbl
-end
-include('shared.lua')
-
-ENT.RenderGroup = RENDERGROUP_BOTH
-
-function ENT:Initialize()
-end
-
-function ENT:OnRemove()
-end
-
-function ENT:Think()
-end
-
-local function drawchipsavaliable(panel, chips)
- for k,v in pairs(chips) do
- local chiptbl = ART.chips[k]
- local chippanel = vgui.Create("DPanel",panel)
- chippanel:SetSize(64,80)
- chippanel.chip = chiptbl
- chippanel:Droppable("chiptype")
- local chipitem = vgui.Create( "DImage",chippanel )
- chipitem:SetMaterial( chiptbl:GetImage() )
- chipitem:SetSize(64,64)
- local chipname = vgui.Create("DLabel",chippanel)
- chipname:SetPos( 0, 64 )
- chipname:SetText( k )
- chipname:SetDark(true)
- chipname:SetContentAlignment(5)
- --chipitem:Dock(TOP)
- panel:AddItem(chippanel)
- end
-end
-local workspacesize = {5,5}
-local workspacegridemptys = {}
-local workspacechips = {}
-for k=1,workspacesize[2] do
- workspacechips[k] = {}
-end
-local function drawworkgrid(panel,blocks)
- workspacegridemptys = {}
- local grid = vgui.Create( "DGrid", panel )
- grid:SetPos( 0, 0 )
- grid:SetCols( workspacesize[1] )
- grid:SetColWide( 64 )
- grid:SetRowHeight(64)
-
- for i = 1, workspacesize[1] * workspacesize[2] do
- local griditem = vgui.Create( "DPanel" )
- griditem:SetText( i )
- griditem:SetSize( 64, 64 )
- grid:AddItem( griditem )
- griditem:Receiver( "chiptype", function(receiver,
- tableOfDroppedPanels,
- isDropped,
- menuIndex,
- mouseX,
- mouseY )
- local chiptbl = tableOfDroppedPanels[1].chip
- print("Chiptable was:")
- PrintTable(chiptbl)
- print("Receiver was:",receiver)
- if isDropped then
- --workspacechips[i]
- print("The icon was dropped on me!")
- elseif griditem.image == nil then
- for k,v in pairs(workspacegridemptys) do
- if v.ghostimage == nil then continue end
- v.ghostimage:Remove()
- v.ghostimage = nil
- end
- griditem.ghostimage = vgui.Create( "DImage", griditem )
- griditem.ghostimage:SetMaterial( chiptbl:GetImage() )
- griditem.ghostimage:SetSize(64,64)
- end
- print("Something was dragged and dropped!")
- end, {} )
- table.insert(workspacegridemptys,griditem)
- end
-end
-
-net.Receive("openchipmill",function()
- local width,height = ScrW(),ScrH()
- local chipframe = vgui.Create( "DFrame" )
- chipframe:SetPos( width / 10, height / 10 )
- chipframe:SetSize( width / 1.25, height / 1.25 )
- chipframe:SetTitle( "Chip mill" )
- chipframe:SetDraggable( true )
- chipframe:MakePopup()
-
- local chipsavaliable = {
- ["Clock"] = 1,
- }
- chipsavaliablepanel = vgui.Create( "DPanel", chipframe )
- chipsavaliablepanel:Dock(RIGHT)
- local chipscroll = vgui.Create( "DScrollPanel", chipsavaliablepanel )
- chipscroll:Dock(FILL)
- drawchipsavaliable(chipscroll,chipsavaliable)
-
- chipworkspace = vgui.Create( "DPanel",chipframe )
- chipworkspace:Dock(FILL)
- drawworkgrid(chipworkspace,{})
-
- chiptools = vgui.Create( "DPanel",chipframe )
- chiptools:Dock(LEFT)
-
- millfunctions = vgui.Create( "DPanel",chipframe )
- millfunctions:Dock(BOTTOM)
-
-
-end)
-
-function ENT:Draw()
-
- self:DrawModel()
-end
diff --git a/entities/entities/art_chipmill/init.lua b/entities/entities/art_chipmill/init.lua
deleted file mode 100644
index aa1f0e7..0000000
--- a/entities/entities/art_chipmill/init.lua
+++ /dev/null
@@ -1,81 +0,0 @@
-AddCSLuaFile( "cl_init.lua" )
-AddCSLuaFile( "shared.lua" )
-
-ART.RegisterChipType = function(tbl)
- print("Trying to register chip type!")
-end
-include("shared.lua")
-
-local mdltbl = {
-{"models/props_c17/furnituretable002a.mdl",
-Vector(2,1,-30),
-Angle(0,-90,0)},
-{"models/props_junk/meathook001a.mdl",
-Vector(22,10,2),
-Angle(-1,126,160)},
-{"models/props_interiors/pot01a.mdl",
-Vector(2,-3,-13),
-Angle(0,180,180)},
-{"models/props_junk/metal_paintcan001a.mdl",
-Vector(-4,-2,-16),
-Angle(0,-45,0)},
-{"models/props_c17/furnituretable002a.mdl",
-Vector(2,-3,-30),
-Angle(85,-90,1)},
-{"models/props_c17/tools_wrench01a.mdl",
-Vector(-23,2,-10),
-Angle(-2,-26,0)},
-{"models/props_c17/trappropeller_lever.mdl",
-Vector(21,-2,-10),
-Angle(88,-104,63)},
-{"models/props_junk/garbage_takeoutcarton001a.mdl",
-Vector(23,11,11),
-Angle(-11,39,-179)},
-{"models/props_junk/garbage_milkcarton002a.mdl",
-Vector(17,6,16),
-Angle(71,34,177)},
-{"models/props_junk/garbage_metalcan001a.mdl",
-Vector(12,2,13),
-Angle(-5,-42,-162)},
-{"models/props_junk/flare.mdl",
-Vector(8,0,10),
-Angle(-13,-89,152)},
-}
-
-function ENT:Initialize()
- self:SetModel("models/hunter/blocks/cube2x2x1.mdl")
- self:SetAngles(Angle(90,90,180))
- self:PhysicsInit( SOLID_VPHYSICS )
- self:SetMoveType( MOVETYPE_NONE )
- self:SetSolid( SOLID_VPHYSICS )
- self:SetCollisionGroup( COLLISION_GROUP_INTERACTIVE )
- self:SetUseType(SIMPLE_USE)
-
- local phys = self:GetPhysicsObject()
- --Wait a second so that we have a valid pos, self:GetPos() will return origin without this.
- timer.Simple(1,function()
- self:SetPos(self:GetPos() + Vector(0,0,30))
- self:SetColor( Color( 0, 0, 0, 0 ) )
- self:SetRenderMode( RENDERMODE_TRANSALPHA )
- for k,v in pairs(mdltbl) do
- print("Createing a " .. k)
- local part = ents.Create("prop_dynamic")
- part:SetModel(v[1])
- part:SetPos(self:GetPos() + v[2])
- part:SetAngles(v[3])
- part:Spawn()
- end
- end)
-
-
- phys:EnableMotion(false)
- phys:Sleep()
-end
-
-util.AddNetworkString("openchipmill")
-
-function ENT:Use(ply)
- net.Start("openchipmill")
- net.WriteEntity(self)
- net.Send(ply)
-end
diff --git a/entities/entities/art_chipmill/shared.lua b/entities/entities/art_chipmill/shared.lua
deleted file mode 100644
index 82eef2c..0000000
--- a/entities/entities/art_chipmill/shared.lua
+++ /dev/null
@@ -1,30 +0,0 @@
-ENT.Type = "anim"
-ENT.Base = "base_anim"
-
---[[
- The different kinds of chips
-]]
-
-local clockon = Material("materials/chipicons/clock1.png")
-local clockoff = Material("materials/chipicons/clock2.png")
-local clocktype = {
- ["Name"] = "Clock",
- ["GetImage"] = function(self)
- if self.A == 1 then
- return clockon
- else
- return clockoff
- end
- end,
- ["OnTick"] = function(self)
- self.A = self.A == 1 and 0 or 1
- end,
- ["Inputs"] = {},
- ["Outputs"] = {
- ["A"] = function(self)
- return self.A
- end,
- },
-}
-
-ART.RegisterChipType(clocktype)
diff --git a/entities/entities/art_lootchest/cl_init.lua b/entities/entities/art_lootchest/cl_init.lua
index 4cfd132..5eb6b76 100644
--- a/entities/entities/art_lootchest/cl_init.lua
+++ b/entities/entities/art_lootchest/cl_init.lua
@@ -1,5 +1,4 @@
include('shared.lua')
--local invfuncs = include("../../../gamemode/shared/inventory_common.lua")
-local invfuncs = ART.invfuncs
ENT.RenderGroup = RENDERGROUP_BOTH
diff --git a/entities/entities/art_lootchest/init.lua b/entities/entities/art_lootchest/init.lua
index 516dc98..2ef04a7 100644
--- a/entities/entities/art_lootchest/init.lua
+++ b/entities/entities/art_lootchest/init.lua
@@ -2,12 +2,6 @@ AddCSLuaFile( "cl_init.lua" )
AddCSLuaFile( "shared.lua" )
include("shared.lua")
-local invfuncs = include("../../../gamemode/shared/inventory_common.lua")
-
---Some things that can be looted
-local lootables = {
-
-}
function CreateRandomLoot(time)
diff --git a/entities/entities/npc_shop/cl_init.lua b/entities/entities/npc_shop/cl_init.lua
index 4cfd132..5eb6b76 100644
--- a/entities/entities/npc_shop/cl_init.lua
+++ b/entities/entities/npc_shop/cl_init.lua
@@ -1,5 +1,4 @@
include('shared.lua')
--local invfuncs = include("../../../gamemode/shared/inventory_common.lua")
-local invfuncs = ART.invfuncs
ENT.RenderGroup = RENDERGROUP_BOTH
diff --git a/entities/entities/npc_shop/init.lua b/entities/entities/npc_shop/init.lua
index 93b5755..a6d49d3 100644
--- a/entities/entities/npc_shop/init.lua
+++ b/entities/entities/npc_shop/init.lua
@@ -2,12 +2,6 @@ AddCSLuaFile( "cl_init.lua" )
AddCSLuaFile( "shared.lua" )
include("shared.lua")
-local invfuncs = include("../../../gamemode/shared/inventory_common.lua")
-
---Some things that can be looted
-local lootables = {
-
-}
function CreateRandomLoot(time)
@@ -15,32 +9,33 @@ end
function ENT:Initialize()
- self.Openedby = {}
+ self.Openedby = {}
- self:PhysicsInit( SOLID_VPHYSICS )
- self:SetMoveType( MOVETYPE_NONE )
- self:SetUseType(SIMPLE_USE)
+ self:PhysicsInit( SOLID_VPHYSICS )
+ self:SetMoveType( MOVETYPE_NONE )
+ self:SetUseType(SIMPLE_USE)
- self:SetSolid(SOLID_BBOX )
- self:SetCollisionGroup(COLLISION_GROUP_NPC )
+ self:SetSolid(SOLID_BBOX )
+ self:SetCollisionGroup(COLLISION_GROUP_NPC )
- print("Initalizeing shop npc")
- if(self.Model) then self:SetModel(self.Model)
- else print("NPC created without model, this might be a bug!") end
+ print("Initalizeing shop npc")
+ if self.Model then self:SetModel(self.Model)
+ else print("NPC created without model, this might be a bug!") end
- if self.Pos then self:SetPos(self.Pos)
- else print("NPC created without a position, this might be a bug!") end
+ if self.Pos then self:SetPos(self.Pos)
+ else print("NPC created without a position, this might be a bug!") end
- self.talking = false
+ self.talking = false
- if self.Name then self:SetName(self.Name)
- else print("NPC created without a name! They won't be able to open doors!") end
+ if self.Name then self:SetName(self.Name)
+ else print("NPC created without a name! They won't be able to open doors!") end
- if self.OnSpawn then self.OnSpawn(self) end
+ if self.OnSpawn then self.OnSpawn(self) end
- self:SetUseType( SIMPLE_USE )
+ self:SetUseType( SIMPLE_USE )
end
function ENT:Use(ply)
- ART.OpenShop(self.shopitems,ply)
+ --TODO:Fix shop
+ ART.OpenShop(self.shopitems,ply)
end
diff --git a/gamemode/autolua.lua b/gamemode/autolua.lua
index 44e146c..c17ae3b 100644
--- a/gamemode/autolua.lua
+++ b/gamemode/autolua.lua
@@ -9,6 +9,7 @@
a.AddSHLuaFolder(foldername,recursive) :: nil
a.AddSVLuaFolder(foldername,recursive) :: nil
]]
+do return end
-- @module autolua
local auto = {}
diff --git a/gamemode/client/cl_inventory.lua b/gamemode/client/cl_inventory.lua
index a40a5f8..84cb347 100644
--- a/gamemode/client/cl_inventory.lua
+++ b/gamemode/client/cl_inventory.lua
@@ -4,21 +4,23 @@
print("Hello from cl_inventory.lua")
--debug.Trace()
-ART.PrayerEquiped = ART.PrayerEquiped or {
- false,false,false,false
+local prayerequiped = {
+ false,false,false,false,false
}
+
net.Receive("equiphelpprayer",function()
print("equiphelp received client side!")
- ART.PrayerEquiped[4] = "Noob Help"
+ prayerequiped[4] = "Noob Help"
end)
-
local lastpanel = lastpanel or 1
local inventorysheets = {}
+--[[
ART.RegisterInventorySheet = function(func)
inventorysheets[#inventorysheets + 1] = func
end
+]]
local plyisininventory = false
@@ -37,6 +39,7 @@ local function createMenuFor(menu, tbl)
end
end
+--[[
function ART.RefreshDisplays()
local discopy = LocalPlayer().invdisplays
LocalPlayer().invdisplays = {}
@@ -52,6 +55,7 @@ function ART.RefreshDisplays()
ptbl.redraw()
end
end
+]]
local sheet
function ShowInventory(ply,cmd,args)
@@ -83,157 +87,6 @@ function ShowInventory(ply,cmd,args)
tsheet.sheetnum = name
end
sheet:SwitchToName(lastpanel)
-
- --[[
-
- local prayersheet = vgui.Create( "DListLayout", sheet)
- sheet:AddSheet( "Prayers", prayersheet, "icon16/coins.png")
-
- --Prayers
- local prayergridscroll = vgui.Create("DScrollPanel")
- prayergridscroll:SetSize( (width / 4) - 20, height / 3 )
- prayergridscroll:SetPos( 5, 5 )
- prayersheet:Add(prayergridscroll)
- local prayergrid = vgui.Create( "DGrid", prayergridscroll )
- prayergrid:SetPos( 5 , 5 )
- prayergrid:Dock(FILL)
-
- prayergrid:SetCols( (width / 4) / 64 )
- prayergrid:SetColWide( 64 )
- prayergrid:SetRowHeight(64)
- prayergridscroll:AddItem(prayergrid)
-
- for k,v in pairs(ART.Prayer) do
- local but = vgui.Create( "DButton", prayergrid )
- but:SetText( v.Name )
- but:SetSize( 64, 64 )
- but:SetWrap(true)
- prayergrid:AddItem( but )
- but.PrayerName = v.Name
- but:Droppable("PrayerBind")
- end
-
- local prayerbindgrid = vgui.Create("DGrid")
- prayerbindgrid:SetPos(height * (2 / 3),5)
- prayerbindgrid:SetSize((width / 4) - 20, height / 3)
- prayerbindgrid:SetColWide(64)
- prayerbindgrid:SetRowHeight(64)
- function prayerbindgrid:Paint(w,h)
- draw.RoundedBox( 8, 0, 0, w, h, Color( 0, 255, 0 ) )
- end
- local n = 0
- for k,v in pairs(ART.PrayerEquiped) do
- n = n + 1
- local but = vgui.Create( "DPanel", prayerbindgrid )
- but:SetSize(64, 64)
- if v ~= false then
- local prayerbut = vgui.Create( "DLabel", but )
- prayerbut:SetText( v.Name )
- prayerbut:SetSize( 64, 64 )
- prayerbut:SetWrap(true)
- else
- local blabel = vgui.Create( "DLabel", but )
- blabel:SetText( "F" .. k )
- blabel:SetDark(true)
- but:Receiver( "PrayerBind", function( self, tableOfDroppedPanels, isDropped, menuIndex, mouseX, mouseY )
- if not isDropped then return end
- ART.PrayerEquiped[k] = tableOfDroppedPanels.PrayerName
- print("Prayer bound to " .. k)
- end)
- end
- prayerbindgrid:AddItem(but)
- end
- prayersheet:Add(prayerbindgrid)
-
- --Display quests
- local questselector = vgui.Create( "DScrollPanel", questsheet )
- questselector:SetSize((width / 4) - 20, (height / 2) - 40)
- questselector:SetPos(0,0)
- local questinfo = vgui.Create("DScrollPanel", questsheet)
- questinfo:SetSize(width / 4, height / 2)
- questinfo:SetPos(0,height / 2)
- for k,v in pairs(LocalPlayer().Quests or {}) do
- print("Displaying quest:" .. k)
- local questbutton = vgui.Create( "DButton" , questselector )
- questbutton:Dock(TOP)
- questbutton:SetText(k)
- questbutton.DoClick = function()
- print("At point of clicking, art is:")
- PrintTable(ART)
- ART.GetQuest(k).DrawQuestInfo(questinfo,v)
- end
- end
-
- --Display gear
- local slotsize = math.Round(width / 32)
- local displaypos = {
- ["Head"] = {(width / 8) - slotsize, 25},
- ["Body"] = {(width / 8) - slotsize, slotsize + 26},
- ["Legs"] = {(width / 8) - slotsize, (slotsize * 2) + 27},
- ["Boots"] = {(width / 8) - slotsize, (slotsize * 3) + 28},
- ["Gloves"] = {(width / 8) + (slotsize), (slotsize * 2) + 27},
- ["Left"] = {(width / 8) - (1.5 * slotsize), (slotsize * 4) + 29},
- ["Right"] = {(width / 8) - (0.5 * slotsize), (slotsize * 4) + 29}
- }
- print("Displaying inventory:")
- PrintTable(LocalPlayer().Inventory.Equiped)
- for k,v in pairs (LocalPlayer().Inventory.Equiped) do
- if v == false then
- local eqslot = vgui.Create( "DPanel", invsheet )
- eqslot:SetSize( slotsize, slotsize )
- eqslot:SetPos(displaypos[k][1],displaypos[k][2])
- eqslot:Receiver( "Inventory", function( receiver, tableOfDroppedPanels, isDropped, menuIndex, mouseX, mouseY )
- if not isDropped then return end
- print("Attempting to equip")
- local icon = tableOfDroppedPanels[1]
- local item = icon.Item
- PrintTable(item)
- print("In",k)
- if item.Equipable == k then
- net.Start("equipitem")
- net.WriteUInt(icon.backpacknum,16) -- Backpack number
- local fromtbl = icon.invpos
- net.WriteUInt(fromtbl[1],16) -- From position
- net.WriteUInt(fromtbl[2],16)
- print("Writing string",k)
- net.WriteString(k)
- net.SendToServer()
- end
- end, {} )
- else
- print("eqslot",k,"was not false, it was")
- PrintTable(v)
- local eqslot = vgui.Create("DImageButton",invsheet)
- eqslot:SetSize(slotsize,slotsize)
- eqslot:SetPos(displaypos[k][1],displaypos[k][2])
- if v.PaintEquiped then
- eqslot.Paint = v.PaintEquiped
- end
- if v.DoOnEqupPanel then
- v.DoOnEqupPanel(eqslot)
- end
- eqslot:Droppable("Inventory")
- eqslot.Item = v
- eqslot.wasequiped = k
- end
- end
-
- local backpacksheet = vgui.Create( "DPropertySheet", invsheet )
- backpacksheet:SetPos(0,slotsize * 6)
- backpacksheet:SetSize((width / 4) - 25, height - (slotsize * 6) - 50)
- print("Displaying backpacks:")
- PrintTable(LocalPlayer().Inventory.Backpacks)
- print("That was all the backpacks")
- for k,v in pairs(LocalPlayer().Inventory.Backpacks) do
- local tbacksheet = vgui.Create( "DPanel", backpacksheet )
- tbacksheet.Paint = function( self, w, h ) draw.RoundedBox( 4, 0, 0, w, h, Color( 157, 160, 167 ) ) end
- backpacksheet:AddSheet( v[3], tbacksheet, "icon16/cross.png" )
-
- DrawBackpackOnDPanel(tbacksheet,v,k,LocalPlayer())
- end
-
- ]]
-
end
diff --git a/gamemode/client/cl_legs.lua b/gamemode/client/cl_legs.lua
index 1bfaa99..c9703e1 100644
--- a/gamemode/client/cl_legs.lua
+++ b/gamemode/client/cl_legs.lua
@@ -1,12 +1,13 @@
--[[
-
+
The purpose of this file is to render the client's legs
for realism purposes, this file wasn't coded by any of the
NightZ team it was however coded by Valkyrie:
-
+
http://facepunch.com/showthread.php?t=1227980&p=38680440&viewfull=1#post38680440
-
+
--]]
+if SERVER then error("What happened?") end
local Legs = {}
Legs.LegEnt = nil
@@ -149,7 +150,7 @@ Legs.BoneHoldTypes = { ["none"] = {
"ValveBiped.Bip01_Spine2",
}
}
-
+
Legs.BonesToRemove = {}
Legs.BoneMatrix = nil
@@ -193,16 +194,16 @@ function Legs:Think( maxseqgroundspeed )
self.OldWeapon = LocalPlayer():GetActiveWeapon()
self:WeaponChanged( self.OldWeapon )
end
-
+
if self.LegEnt:GetModel() != self:FixModelName( LocalPlayer():GetModel() ) then
self.LegEnt:SetModel( self:FixModelName( LocalPlayer():GetModel() ) )
end
-
+
self.LegEnt:SetMaterial( LocalPlayer():GetMaterial() )
self.LegEnt:SetSkin( LocalPlayer():GetSkin() )
self.Velocity = LocalPlayer():GetVelocity():Length2D()
-
+
self.PlaybackRate = 1
if self.Velocity > 0.5 then
@@ -213,32 +214,32 @@ function Legs:Think( maxseqgroundspeed )
self.PlaybackRate = math.Clamp( self.PlaybackRate, 0.01, 10 )
end
end
-
+
self.LegEnt:SetPlaybackRate( self.PlaybackRate )
-
+
self.Sequence = LocalPlayer():GetSequence()
-
+
if ( self.LegEnt.Anim != self.Sequence ) then
self.LegEnt.Anim = self.Sequence
self.LegEnt:ResetSequence( self.Sequence )
end
-
+
self.LegEnt:FrameAdvance( CurTime() - self.LegEnt.LastTick )
self.LegEnt.LastTick = CurTime()
-
+
Legs.BreathScale = sharpeye and sharpeye.GetStamina and math.Clamp( math.floor( sharpeye.GetStamina() * 5 * 10 ) / 10, 0.5, 5 ) or 0.5
-
- if Legs.NextBreath <= CurTime() then
+
+ if Legs.NextBreath <= CurTime() then
Legs.NextBreath = CurTime() + 1.95 / Legs.BreathScale
self.LegEnt:SetPoseParameter( "breathing", Legs.BreathScale )
end
-
+
self.LegEnt:SetPoseParameter( "move_x", ( LocalPlayer():GetPoseParameter( "move_x" ) * 2 ) - 1 )
self.LegEnt:SetPoseParameter( "move_y", ( LocalPlayer():GetPoseParameter( "move_y" ) * 2 ) - 1 )
self.LegEnt:SetPoseParameter( "move_yaw", ( LocalPlayer():GetPoseParameter( "move_yaw" ) * 360 ) - 180 )
self.LegEnt:SetPoseParameter( "body_yaw", ( LocalPlayer():GetPoseParameter( "body_yaw" ) * 180 ) - 90 )
self.LegEnt:SetPoseParameter( "spine_yaw",( LocalPlayer():GetPoseParameter( "spine_yaw" ) * 180 ) - 90 )
-
+
if ( LocalPlayer():InVehicle() ) then
self.LegEnt:SetColor( color_transparent )
self.LegEnt:SetPoseParameter( "vehicle_steer", ( LocalPlayer():GetVehicle():GetPoseParameter( "vehicle_steer" ) * 2 ) - 1 )
@@ -271,7 +272,7 @@ end
hook.Add( "RenderScreenspaceEffects", "Legs:Render", function()
cam.Start3D( EyePos(), EyeAngles() )
if ShouldDrawLegs() then
-
+
Legs.RenderPos = LocalPlayer():GetPos()
if LocalPlayer():InVehicle() then
Legs.RenderAngle = LocalPlayer():GetVehicle():GetAngles()
@@ -283,7 +284,7 @@ hook.Add( "RenderScreenspaceEffects", "Legs:Render", function()
Legs.ForwardOffset = -22
Legs.RenderPos.x = Legs.RenderPos.x + math.cos( Legs.RadAngle ) * Legs.ForwardOffset
Legs.RenderPos.y = Legs.RenderPos.y + math.sin( Legs.RadAngle ) * Legs.ForwardOffset
-
+
if LocalPlayer():GetGroundEntity() == NULL then
Legs.RenderPos.z = Legs.RenderPos.z + 8
if LocalPlayer():KeyDown( IN_DUCK ) then
@@ -291,14 +292,14 @@ hook.Add( "RenderScreenspaceEffects", "Legs:Render", function()
end
end
end
-
+
Legs.RenderColor = LocalPlayer():GetColor()
-
+
local bEnabled = render.EnableClipping( true )
- render.PushCustomClipPlane( Legs.ClipVector, Legs.ClipVector:Dot( EyePos() ) )
+ render.PushCustomClipPlane( Legs.ClipVector, Legs.ClipVector:Dot( EyePos() ) )
render.SetColorModulation( Legs.RenderColor.r / 255, Legs.RenderColor.g / 255, Legs.RenderColor.b / 255 )
render.SetBlend( Legs.RenderColor.a / 255 )
- hook.Call( "PreLegsDraw", GAMEMODE, Legs.LegEnt )
+ hook.Call( "PreLegsDraw", GAMEMODE, Legs.LegEnt )
Legs.LegEnt:SetRenderOrigin( Legs.RenderPos )
Legs.LegEnt:SetRenderAngles( Legs.RenderAngle )
Legs.LegEnt:SetupBones()
@@ -312,4 +313,4 @@ hook.Add( "RenderScreenspaceEffects", "Legs:Render", function()
render.EnableClipping( bEnabled )
end
cam.End3D()
-end ) \ No newline at end of file
+end )
diff --git a/gamemode/client/healthbar.lua b/gamemode/client/hud/cl_healthbar.lua
index 67a3090..67a3090 100644
--- a/gamemode/client/healthbar.lua
+++ b/gamemode/client/hud/cl_healthbar.lua
diff --git a/gamemode/client/qpanels/inventory.lua b/gamemode/client/qpanels/inventory.lua
index b366c7a..2850e1d 100644
--- a/gamemode/client/qpanels/inventory.lua
+++ b/gamemode/client/qpanels/inventory.lua
@@ -1,3 +1,4 @@
+do return end
local invfuncs
invfuncs = ART.invfuncs
--invfuncs = include("../gamemodes/artery/gamemode/shared/inventory_common.lua")
diff --git a/gamemode/client/qpanels/prayers.lua b/gamemode/client/qpanels/prayers.lua
index bc955ce..cdcb742 100644
--- a/gamemode/client/qpanels/prayers.lua
+++ b/gamemode/client/qpanels/prayers.lua
@@ -1,4 +1,4 @@
-
+do return end
local refreshboundprayers
local infopart
local prayersheet
diff --git a/gamemode/client/qpanels/quests.lua b/gamemode/client/qpanels/quests.lua
index 1ca723b..015fc97 100644
--- a/gamemode/client/qpanels/quests.lua
+++ b/gamemode/client/qpanels/quests.lua
@@ -1,4 +1,4 @@
-
+do return end
ART.RegisterInventorySheet(function()
diff --git a/gamemode/client/qpanels/skills.lua b/gamemode/client/qpanels/skills.lua
index 4693032..6d71442 100644
--- a/gamemode/client/qpanels/skills.lua
+++ b/gamemode/client/qpanels/skills.lua
@@ -1,4 +1,4 @@
-
+do return end
ART.RegisterInventorySheet(function()
diff --git a/gamemode/config/colortheme.lua b/gamemode/config/colortheme.lua
new file mode 100644
index 0000000..ac803cc
--- /dev/null
+++ b/gamemode/config/colortheme.lua
@@ -0,0 +1,29 @@
+--[[
+ This file needs some text so gmod dosn't throw a fit
+]]
+
+local theme = {}
+
+--Not technically correct colors, but they look nice togeather, generated by http://terminal.sexy
+theme.console = {
+ background = Color(254,249,236),
+ foreground = Color(109,114,126),
+ gray = Color(197,193,180),
+ gray_bold = Color(161,166,178),
+ red = Color(231,92,88),
+ red_bold = Color(178,43,49),
+ green = Color(0,162,80),
+ green_bold = Color(0,116,39),
+ yellow = Color(160,138,0),
+ yellow_bold = Color(113,95,0),
+ blue = Color(32,143,251),
+ blue_bold = Color(0,101,202),
+ magenta = Color(209,96,196),
+ magenta_bold = Color(160,49,150),
+ cyan = Color(0,164,193),
+ cyan_bold = Color(0,118,147),
+ black = Color(62,66,77),
+ black_bold = Color(40,44,54),
+}
+
+return theme
diff --git a/gamemode/core/inventory/inventory.lua b/gamemode/core/inventory/inventory.lua
new file mode 100644
index 0000000..59c2bba
--- /dev/null
+++ b/gamemode/core/inventory/inventory.lua
@@ -0,0 +1,135 @@
+--[[
+ Public functions:
+ RegisterInventory(tbl_inventory) ::nil
+ CreateInventory(string_name) ::table_inventory
+ CreateInventoryFromData(string_name,string_data)::table_inventory)
+ DeriveInventory(string_name) ::table_inventory
+ Inventories have the following structure
+ inv.Name ::string
+ inv:FindPlaceFor(item) ::table_position or nil
+ inv:CanFitIn(table_position,item) ::true or string_explanation
+ inv:Put(table_position,item) ::nil
+ inv:Has(string_or_compare_func) ::table_position or nil
+ inv:Remove(position) ::table_item
+ inv:Get(position) ::table_item
+ inv:Serialize() ::string
+ inv:DeSerialize(str) ::table_inventory
+ The above fields must be defined for new inventories.
+ -----------------------------------------------------
+ The below are automatically made if they do not exist.
+ inv:AddObserver(tbl_other) ::number_id
+ inv:RemoveObserver(number_id) ::nil
+
+ The table used for "position" is not defined, and may vary from inventory to inventory, but a single inventory type should only use a single type of position.
+
+ The AddObserver will call tbl_other's Put() and Remove() methods(same arguments as the inventory) when this inventories Put() and Remove() methods are called. This will hopefully make it easy to have multiple players viewing the same inventory, and all get updates.
+
+ Serialize() should take this inventories contents and return a string that it can recreate this inventory from. DeSerialize should create a self.Copy() with the appropriate fields set. Take advantage of the fact that items must also have Serialize() and DeSerialize() methods.
+]]
+
+local thm = nrequire("colortheme.lua")
+local log = nrequire("log.lua")
+
+local inv = {}
+
+--Creates a partial copy of a table(tables are copied, functions are not)
+local function TableCopy(tbl)
+ local ntbl = {}
+ for k,v in pairs(tbl) do
+ if type(v) == "table" then
+ ntbl[k] = TableCopy(v)
+ else
+ ntbl[k] = v
+ end
+ end
+ return ntbl
+end
+
+--Holds different types of inventories to be made
+local inventories = {} --Master list
+
+local function DefaultAddObserver(self,tbl)
+ if self.observers == nil then self.observers = {} end
+ self.observers[#observers + 1] = tbl
+ return #observers
+end
+local function DefaultRemoveObserver(self,observer_id)
+ for i = observer_id, #self.observers do
+ self.observers[i] = self.observers + 1
+ end
+end
+local function SetDefaultObservers(tbl)
+ tbl.AddObserver = DefaultAddObserver
+ tbl.RemoveObserver = DefaultRemoveObserver
+ --Call the observer's puts as well as this inventory's put.
+ local oldput,oldremove = tbl.Put,tbl.Remove
+ tbl.Put = function(self,position,item)
+ for k,v in pairs(self.observers) do
+ v:Put(position,item)
+ end
+ oldput(self,position,item)
+ end
+ tbl.Remove = function(self,position)
+ for k,v in pairs(self.observers) do
+ v:Remove(position)
+ end
+ oldremove(self,position)
+ end
+end
+
+local required_fields = {
+ {"Name","string"},
+ {"FindPlaceFor","function"},
+ {"CanFitIn","function"},
+ {"Put","function"},
+ {"Has","function"},
+ {"Remove","function"},
+ {"Get","function"},
+ {"Serialize","function"},
+ {"DeSerialize","function"},
+}
+function inv.RegisterInventory(tbl)
+ assert(type(tbl) == "table",
+ "Attempted to register inventory that was not a table")
+ for k,v in pairs(required_fields) do
+ assert(tbl[v[1]] ~= nil,
+ string.format("Attempted to register inventory without field %q",v[1]))
+ assert(type(tbl[v[1]]) == v[2],
+ string.format("Attempted to register inventory with field %q of type %q when it should have been %q",v[1],type(tbl[v[1]]),v[2]))
+ end
+ assert(inventories[tbl.Name] == nil,
+ "Attempted to register 2 inventories with the same name")
+ assert((tbl.AddObserver == nil and tbl.RemoveObserver == nil) or
+ (tbl.AddObserver ~= nil and tbl.RemoveObserver ~= nil),
+ "AddObserver and RemoveObserver must be defined in pairs")
+ if tbl.AddObserver == nil then
+ SetDefaultObservers(tbl)
+ end
+ inventories[tbl.Name] = tbl
+ log.debug("Registered item: " .. tbl.Name)
+end
+
+--Create an inventory
+function inv.CreateInventory(name)
+ return table_copy(inventories[name])
+end
+
+--Recreates an inventory from data
+function inv.CreateInventoryFromData(name,data)
+ return create_inventory(name):DeSerialize(data)
+end
+
+--Must be called in a coroutine.
+function inv.DeriveInventory(name)
+ while inventories[name] == nil do
+ coroutine.yield()
+ end
+ --Create a shallow copy
+ local ret = {}
+ for k,v in pairs(inventories[name]) do
+ ret[k] = v
+ end
+ return ret
+end
+
+return inv
diff --git a/gamemode/core/inventory/item.lua b/gamemode/core/inventory/item.lua
new file mode 100644
index 0000000..ef6ec1d
--- /dev/null
+++ b/gamemode/core/inventory/item.lua
@@ -0,0 +1,67 @@
+--[[
+ An itemsystem
+ public functions:
+ RegisterItem(table_item) ::nil
+ Registers a new item
+ GetItemByName(string_name) ::table_item
+ Returns the master copy of an item by name
+ DeriveItem(table_item,string_name) ::nil
+ Sets the table to a copy of an item. Copying happens in order, so if two items we derive from have a "DoThing" method, and "DoThing" is not defined in the item, the second derived item's "DoThing" method gets called on .DoThing()
+ Item:
+ item.Name ::string
+ Items must have unique names
+ item:Serialize() ::string
+ Turn any instace specific data of this item into a string, should be able to recreate an exact copy of this item in DeSerialize with this data
+ item:DeSerialize(string_data) ::nil
+ Recreate an item. If this item has any instance specific data, it should return a table.Copy(self) with the appropriate fields set.
+ The above must be defined for every item
+ Items may also have methods from one or more interfaces registered with RegisterInterface
+]]
+local log = nrequire("log.lua")
+
+local itm = {}
+local required_fields = {
+ "Name","Serialize","DeSerialize"
+}
+
+local items = {} --Master table of all item prototypes
+function itm.RegisterItem(tbl)
+ for k,v in pairs(required_fields) do
+ assert(tbl[v] ~= nil, string.format("Attempted to register item without field %q",v))
+ end
+ assert(items[tbl.Name] == nil, string.format("Attempted to register 2 items with the same name %q",tbl.Name))
+ log.debug("Registered item: " .. tbl.Name)
+end
+
+function itm.GetItemByName(name)
+ assert(items[name] ~= nil,string.format("Attempted to get item with invalid name %q",name))
+ return items[name]
+end
+
+function itm.GetItemFromData(name,data)
+ assert(items[name] ~= nil,string.format("Attempted to get item with invalid name %q",name))
+ return items[name]:DeSerialize(data)
+end
+
+--Must be called in a coroutine.
+function itm.DeriveItem(tbl,name)
+ while items[name] == nil do
+ coroutine.yield()
+ end
+ --Create a flywieght copy
+ local ret = tbl
+ local mt = {
+ __index = function(tbl,key)
+ return items[name][key]
+ end
+ }
+ setmetatable(ret,mt)
+end
+
+concommand.Add("art_printitems",function()
+ for k,v in pairs(items) do
+ print(k)
+ end
+end)
+
+return itm
diff --git a/gamemode/init.lua b/gamemode/init.lua
index b4f5c76..5b28d32 100644
--- a/gamemode/init.lua
+++ b/gamemode/init.lua
@@ -1,7 +1,7 @@
AddCSLuaFile( "autolua.lua" )
AddCSLuaFile( "shared.lua" )
AddCSLuaFile( "cl_init.lua" )
-
+AddCSLuaFile("nrequire.lua")
include( "shared.lua" )
local pmeta = FindMetaTable("Player")
diff --git a/gamemode/inventorysystem/equipment.lua b/gamemode/inventorysystem/equipment.lua
new file mode 100644
index 0000000..710c6b8
--- /dev/null
+++ b/gamemode/inventorysystem/equipment.lua
@@ -0,0 +1,67 @@
+--[[
+ A simple inventory that holds 1 item
+]]
+local itm = nrequire("item.lua")
+local ste = nrequire("utility/stream.lua")
+local inventory = nrequire("inventory/inventory.lua")
+local slots = {
+ "Head",
+ "Shoulders",
+ "Chest",
+ "Arms",
+ "Hands",
+ "Legs",
+ "Belt",
+ "Feet",
+ "Back",
+}
+
+for k,v in pairs(slots) do
+ local inv = {}
+ inv.Name = "inv_" .. v
+ inv.FindPlaceFor = function(self, item)
+ if self.item == nil then return {} else return nil end
+ end
+ inv.CanFitIn = function(self,position,item)
+ if self.item == nil then return true else return "Inventory slot occupied by a(n)" .. self.item.Name end
+ end
+ inv.Put = function(self,pos,item)
+ self.item = item
+ end
+ inv.Has = function(self,prt)
+ if type(prt) == "string" then
+ if self.item ~= nil and self.item.Name == prt then return {} else return nil end
+ elseif type(prt) == "function" then
+ if prt(self.item) then return {} else return nil end
+ end
+ error(string.format("Passed a %s to %s:Has(), expected string or function",type(prt),self.Name))
+ end
+ inv.Remove = function(self,pos)
+ self.item = nil
+ end
+ inv.Get = function(self,pos)
+ return self.item
+ end
+ inv.Serialize = function(self)
+ if self.item then
+ local data = ste.CreateStream()
+ local itemname = self.item.Name
+ local itemdata = self.item:Serialize()
+ data:WriteString(itemname)
+ data:WriteString(itemdata)
+ return data:ToString()
+ end
+ return ""
+ end
+ inv.DeSerialize = function(self,str)
+ if str == "" then
+ return table.Copy(self)
+ else
+ local data = ste.CreateStream(str)
+ local itemname = data:ReadString()
+ local itemdata = data:ReadString()
+ self.item = itm.GetItemFromData(itemname,itemdata)
+ end
+ end
+ inventory.RegisterInventory(inv)
+end
diff --git a/gamemode/nrequire.lua b/gamemode/nrequire.lua
new file mode 100644
index 0000000..ba71f17
--- /dev/null
+++ b/gamemode/nrequire.lua
@@ -0,0 +1,171 @@
+--[[
+ A replacement for require
+]]
+if nrequire ~= nil then return end
+print("hello from nrequire!")
+local path = (GM or GAMEMODE).Folder:gsub("gamemodes/","") .. "/gamemode"
+local function TraverseFolder(dir, func)
+ local fpath = table.concat({path,dir,"/*"})
+ local files, directories = file.Find(fpath,"LUA")
+ for k,v in pairs(files) do
+ if string.GetExtensionFromFilename(v) == "lua" then
+ local callpath = table.concat({path,dir,"/",v})
+ func(callpath)
+ end
+ end
+ for k,v in pairs(directories) do
+ local npath = table.concat({dir,"/",v})
+ TraverseFolder(npath,func)
+ end
+end
+
+local function rebuild_include_table(f)
+ local ret = {}
+ for k,v in pairs(f) do
+ local pathparts = {}
+ for part in v:gmatch("/?[%w_]+/") do
+ pathparts[#pathparts + 1] = part:gsub("/$",""):gsub("^/","")
+ end
+ local filename = v:gfind("[%w_]+%.lua$")()
+ if ret[filename] == nil then
+ ret[filename] = {}
+ end
+ local cursor = ret[filename]
+ for folder = #pathparts, 2, -1 do
+ if cursor[pathparts[folder]] == nil then
+ cursor[pathparts[folder]] = {}
+ end
+ cursor = cursor[pathparts[folder]]
+ end
+ assert(cursor[pathparts[1]] == nil,string.format("Found 2 files with the same path:\n\t%s\n\t%s",cursor[pathparts[1]],pathparts[1]))
+ cursor[pathparts[1]] = v
+ end
+ return ret
+end
+
+--Finds the number of elements in a table, even if it is not an array
+local function tbllen(tbl)
+ local count = 0
+ for k,v in pairs(tbl) do count = count + 1 end
+ return count
+end
+
+--[[
+ Finds all the paths from a pretable
+]]
+local function collect_paths(pretbl)
+ local ret = {}
+ for k,v in pairs(pretbl) do
+ if type(v) ~= "string" then
+ local resp = collect_paths(v)
+ for i,j in pairs(resp) do
+ ret[#ret + 1] = j
+ end
+ else
+ ret[#ret + 1] = v
+ end
+ end
+ return ret
+end
+
+--[[
+ Scans the prefix table built by rebuild_include_table to find the file path for the partial name of an included file.
+]]
+local function scan(pretbl, name)
+ local pathparts = {}
+ for part in name:gmatch("/?[%w_]+/") do
+ pathparts[#pathparts + 1] = part:gsub("/$",""):gsub("^/","")
+ end
+ local filename = name:gfind("[%w_]+%.lua")()
+ local cursor = pretbl[filename]
+ assert(cursor ~= nil,string.format("Scan did not find a file named %q, valid files are:\n\t%s",filename,table.concat(pretbl,"\n\t")))
+ local rev = {}
+ for i = 1, #pathparts do rev[#pathparts - i + 1] = pathparts[i] end
+ for k,v in ipairs(rev) do cursor = cursor[v] end
+ while type(cursor) ~= "string" do
+ assert(type(cursor) ~= "nil",string.format("Could not find a valid file for path %q, file paths:\n\t%s",name,table.concat(collect_paths(pretbl),"\n\t")))
+ assert(tbllen(cursor) == 1,string.format("Ambiguous scan, there are two or more paths that match %q\n\t%s",name,table.concat(collect_paths(cursor),"\n\t")))
+ cursor = cursor[next(cursor)]
+ end
+ return cursor
+end
+
+local paths = {}
+local ins = function(n) paths[#paths + 1] = n end
+TraverseFolder("",ins)
+local ntbl = rebuild_include_table(paths)
+local reqtbl = {}
+for k,v in pairs(paths) do
+ if SERVER and not v:match("/?sv_[%w_]+%.lua$") then
+ print("Adding CS lua file",v)
+ AddCSLuaFile(v)
+ end
+end
+
+local pathstack = {}
+local incyields = {}
+function nrequire(req)
+ print("nrequire")
+ local tpath = scan(ntbl,req)
+ if reqtbl[tpath] then
+ print("nrequire cache hit")
+ return reqtbl[tpath]
+ end
+ for k,v in pairs(pathstack) do
+ assert(v ~= tpath,string.format("Circular dependancy detected:\n\t%s",table.concat(pathstack,"\n\t\t|\n\t\tv\n\t")))
+ end
+ print(string.format("Including %q\n",tpath))
+ pathstack[#pathstack + 1] = tpath
+ reqtbl[#reqtbl + 1] = include(tpath)
+ print(string.format("Included %q\n",tpath))
+ return reqtbl[#reqtbl]
+ --[[
+ incyields[#incyields + 1] = coroutine.create(function()
+ print(string.format("Including %q\n",tpath))
+ reqtbl[#reqtbl + 1] = include(tpath)
+ print(string.format("Included %q\n",tpath))
+ end)
+ ]]
+end
+
+local function doincludes()
+ print("doing includes")
+ paths = {}
+ TraverseFolder("",ins)
+ ntbl = rebuild_include_table(paths)
+ reqtbl = {}
+ for k,v in pairs(paths) do
+ if v:match("/?sv_[%w_]+%.lua$") then
+ if SERVER then
+ nrequire(v)
+ end
+ elseif v:match("/?cl_[%w_]+%.lua$") then
+ if CLIENT then
+ nrequire(v)
+ end
+ else
+ nrequire(v)
+ end
+ pathstack = {}
+ end
+
+ while #incyields > 0 do
+ for k,v in pairs(incyields) do
+ if coroutine.status(v) == "dead" then
+ incyields[k] = nil
+ else
+ coroutine.resume(v)
+ end
+ end
+ end
+end
+
+doincludes()
+if SERVER then util.AddNetworkString("art_refresh") end
+if CLIENT then net.Receive("art_refresh",doincludes) end
+
+concommand.Add("art_manualrefresh",function(ply,cmd,args)
+ doincludes()
+ net.Start("art_refresh")
+ net.Broadcast()
+end)
diff --git a/gamemode/server/test/testfile.lua b/gamemode/server/test/testfile.lua
deleted file mode 100644
index 95e40fa..0000000
--- a/gamemode/server/test/testfile.lua
+++ /dev/null
@@ -1,48 +0,0 @@
---print("This is a test file to see if it gets included! Test!")
---Msg("Testing heatmap.lua\n")
-local hm = heatmap.CreateHeatMap()
---PrintTable(hm)
---PrintTable(heatmap)
---local effect = heatmap.UniformInfiniteForever(5)
---hm:RegisterEffect(effect,Vector(0,0,0))
---PrintTable(hm)
---local neweffect = heatmap.LinearInfiniteForeverGrounded(2000,Vector(0,0,0))
---hm:RegisterEffect(neweffect,Vector(0,0,0))
---PrintTable(hm)
-local decayeffect =
-heatmap.LinearInfiniteLinearDecayGrounded(2000,5)
-hm:RegisterEffect(decayeffect,Vector(4000,4000,0))
-local bubbleeffect = heatmap.ParabolicInfiniteForeverGrounded(1000,2.5)
-hm:RegisterEffect(bubbleeffect,Vector(0,0,0))
-
-function sendHeatMap(ply)
- local points = {}
- net.Start("showheatmap")
- for i=0,10000,100 do
- points[i] = {}
- for j=0,10000,100 do
- local offset = --[[ply:GetPos() + ]]Vector(i,j,0) + Vector(-5000,-5000,0)
- points[i][j] = hm:CalculateFor(offset, 0)
- --net.WriteVector(offset)
- net.WriteFloat(points[i][j])
- --print("at ("..i..","..j..") is ")
- --print(points[i][j])
- end
- end
- net.Send(ply)
-end
-
-function callloop(ply)
- sendHeatMap(ply)
- hm.curtime = hm.curtime + 0.5
- timer.Simple(0.5,function() callloop(ply) end)
-end
-
-util.AddNetworkString("showheatmap")
-concommand.Add("ShowHeatMap",function(ply,cmd,args)
- callloop(ply)
-end)
-
-concommand.Add("HeatMapAt",function(ply,cmd,args)
- print(hm:CalculateFor(ply:GetPos(),0))
-end)
diff --git a/gamemode/shared.lua b/gamemode/shared.lua
index 38e63bb..588b81f 100644
--- a/gamemode/shared.lua
+++ b/gamemode/shared.lua
@@ -1,72 +1,6 @@
-local a = include("autolua.lua")
-
-ART = {}
-a.AddLuaSHFolder("utility",true)
-a.AddMixedFolder("core",true)
-a.AddLuaSHFolder("shared",true)
-a.AddLuaCSFolder("client",true)
-a.AddLuaSVFolder("server",true)
-a.AddMixedFolder("tools",true)
-
-
-GM.Name = "Artery"
-GM.Author = "Alexander \"Apickx\" Pickering"
-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
-function error(str)
- print("I got an error!")
- olderr(str)
-end
-]]
+include("nrequire.lua")
+local ngm = GM or GAMEMODE
+ngm.Name = "Artery"
+ngm.Author = "Alexander \"Apickx\" Pickering"
+ngm.Email = "apickx@cogarr.org"
+ngm.Website = "cogarr.net"
diff --git a/gamemode/shared/aes.lua b/gamemode/shared/aes.lua
deleted file mode 100644
index 244dc22..0000000
--- a/gamemode/shared/aes.lua
+++ /dev/null
@@ -1,524 +0,0 @@
-local Stream = include("lockbox/stream.lua");
-local Array = include("lockbox/array.lua");
-
-local Bit = include("lockbox/bit.lua");
---local Math = require("math");
-
-
-local AND = bit.band;
-local OR = bit.bor;
-local NOT = bit.bnot;
-local XOR = bit.bxor;
---local LROT = Bit.lrotate;
---local RROT = Bit.rrotate;
-local LSHIFT = bit.lshift;
-local RSHIFT = bit.rshift;
-
-local SBOX = {
- [0]=0x63, 0x7C, 0x77, 0x7B, 0xF2, 0x6B, 0x6F, 0xC5, 0x30, 0x01, 0x67, 0x2B, 0xFE, 0xD7, 0xAB, 0x76,
- 0xCA, 0x82, 0xC9, 0x7D, 0xFA, 0x59, 0x47, 0xF0, 0xAD, 0xD4, 0xA2, 0xAF, 0x9C, 0xA4, 0x72, 0xC0,
- 0xB7, 0xFD, 0x93, 0x26, 0x36, 0x3F, 0xF7, 0xCC, 0x34, 0xA5, 0xE5, 0xF1, 0x71, 0xD8, 0x31, 0x15,
- 0x04, 0xC7, 0x23, 0xC3, 0x18, 0x96, 0x05, 0x9A, 0x07, 0x12, 0x80, 0xE2, 0xEB, 0x27, 0xB2, 0x75,
- 0x09, 0x83, 0x2C, 0x1A, 0x1B, 0x6E, 0x5A, 0xA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, 0x0E, 0xAA, 0x18, 0xBE, 0x1B,
- 0xFC, 0x56, 0x3E, 0x4B, 0xC6, 0xD2, 0x79, 0x20, 0x9A, 0xDB, 0xC0, 0xFE, 0x78, 0xCD, 0x5A, 0xF4,
- 0x1F, 0xDD, 0xA8, 0x33, 0x88, 0x07, 0xC7, 0x31, 0xB1, 0x12, 0x10, 0x59, 0x27, 0x80, 0xEC, 0x5F,
- 0x60, 0x51, 0x7F, 0xA9, 0x19, 0xB5, 0x4A, 0x0D, 0x2D, 0xE5, 0x7A, 0x9F, 0x93, 0xC9, 0x9C, 0xEF,
- 0xA0, 0xE0, 0x3B, 0x4D, 0xAE, 0x2A, 0xF5, 0xB0, 0xC8, 0xEB, 0xBB, 0x3C, 0x83, 0x53, 0x99, 0x61,
- 0x17, 0x2B, 0x04, 0x7E, 0xBA, 0x77, 0xD6, 0x26, 0xE1, 0x69, 0x14, 0x63, 0x55, 0x21, 0x0C, 0x7D};
-
-local ROW_SHIFT = { 1, 6, 11, 16, 5, 10, 15, 4, 9, 14, 3, 8, 13, 2, 7, 12,};
-local IROW_SHIFT = { 1, 14, 11, 8, 5, 2, 15, 12, 9, 6, 3, 16, 13, 10, 7, 4,};
-
-local ETABLE = {
- [0]=0x01, 0x03, 0x05, 0x0F, 0x11, 0x33, 0x55, 0xFF, 0x1A, 0x2E, 0x72, 0x96, 0xA1, 0xF8, 0x13, 0x35,
- 0x5F, 0xE1, 0x38, 0x48, 0xD8, 0x73, 0x95, 0xA4, 0xF7, 0x02, 0x06, 0x0A, 0x1E, 0x22, 0x66, 0xAA,
- 0xE5, 0x34, 0x5C, 0xE4, 0x37, 0x59, 0xEB, 0x26, 0x6A, 0xBE, 0xD9, 0x70, 0x90, 0xAB, 0xE6, 0x31,
- 0x53, 0xF5, 0x04, 0x0C, 0x14, 0x3C, 0x44, 0xCC, 0x4F, 0xD1, 0x68, 0xB8, 0xD3, 0x6E, 0xB2, 0xCD,
- 0x4C, 0xD4, 0x67, 0xA9, 0xE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49, 0xEC, 0xD8, 0x43, 0x1F, 0x2D, 0xA4, 0x76, 0x7B, 0xB7,
- 0xCC, 0xBB, 0x3E, 0x5A, 0xFB, 0x60, 0xB1, 0x86, 0x3B, 0x52, 0xA1, 0x6C, 0xAA, 0x55, 0x29, 0x9D,
- 0x97, 0xB2, 0x87, 0x90, 0x61, 0xBE, 0xDC, 0xFC, 0xBC, 0x95, 0xCF, 0xCD, 0x37, 0x3F, 0x5B, 0xD1,
- 0x53, 0x39, 0x84, 0x3C, 0x41, 0xA2, 0x6D, 0x47, 0x14, 0x2A, 0x9E, 0x5D, 0x56, 0xF2, 0xD3, 0xAB,
- 0x44, 0x11, 0x92, 0xD9, 0x23, 0x20, 0x2E, 0x89, 0xB4, 0x7C, 0xB8, 0x26, 0x77, 0x99, 0xE3, 0xA5,
- 0x67, 0x4A, 0xED, 0xDE, 0xC5, 0x31, 0xFE, 0x18, 0x0D, 0x63, 0x8C, 0x80, 0xC0, 0xF7, 0x70, 0x07};
-
-local MIXTABLE = {
- 0x02, 0x03, 0x01, 0x01,
- 0x01, 0x02, 0x03, 0x01,
- 0x01, 0x01, 0x02, 0x03,
- 0x03, 0x01, 0x01, 0x02};
-
-local IMIXTABLE = {
- 0x0E, 0x0B, 0x0D, 0x09,
- 0x09, 0x0E, 0x0B, 0x0D,
- 0x0D, 0x09, 0x0E, 0x0B,
- 0x0B, 0x0D, 0x09, 0x0E};
-
-local RCON = {
-[0] = 0x8d, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36, 0x6c, 0xd8, 0xab, 0x4d, 0x9a,
-0x2f, 0x5e, 0xbc, 0x63, 0xc6, 0x97, 0x35, 0x6a, 0xd4, 0xb3, 0x7d, 0xfa, 0xef, 0xc5, 0x91, 0x39,
-0x72, 0xe4, 0xd3, 0xbd, 0x61, 0xc2, 0x9f, 0x25, 0x4a, 0x94, 0x33, 0x66, 0xcc, 0x83, 0x1d, 0x3a,
-0x74, 0xe8, 0x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5, 0x91, 0x39, 0x72, 0xe4, 0xd3, 0xbd,
-0x61, 0xc2, 0x9f, 0x25, 0x4a, 0x94, 0x33, 0x66, 0xcc, 0x83, 0x1d, 0x3a, 0x74, 0xe8, 0xcb, 0x8d};
-
-
-local GMUL = function(A,B)
- if(A == 0x01) then return B; end
- if(B == 0x01) then return A; end
- if(A == 0x00) then return 0; end
- if(B == 0x00) then return 0; end
- print("Gettin gthe LTable of " .. A)
- print("Getting the LTable of " .. B)
- local LA = LTABLE[A];
- local LB = LTABLE[B];
-
- local sum = LA + LB;
- if (sum > 0xFF) then sum = sum - 0xFF; end
-
- return ETABLE[sum];
-end
-
-local byteSub = Array.substitute;
-
-local shiftRow = Array.permute;
-
-local mixCol = function(i,mix)
- local out = {};
-
- local a,b,c,d;
- print("I is:")
- PrintTable(i)
- a = GMUL(i[ 1],mix[ 1]);
- b = GMUL(i[ 2],mix[ 2]);
- c = GMUL(i[ 3],mix[ 3]);
- d = GMUL(i[ 4],mix[ 4]);
- out[ 1] = XOR(XOR(a,b),XOR(c,d));
- a = GMUL(i[ 1],mix[ 5]);
- b = GMUL(i[ 2],mix[ 6]);
- c = GMUL(i[ 3],mix[ 7]);
- d = GMUL(i[ 4],mix[ 8]);
- out[ 2] = XOR(XOR(a,b),XOR(c,d));
- a = GMUL(i[ 1],mix[ 9]);
- b = GMUL(i[ 2],mix[10]);
- c = GMUL(i[ 3],mix[11]);
- d = GMUL(i[ 4],mix[12]);
- out[ 3] = XOR(XOR(a,b),XOR(c,d));
- a = GMUL(i[ 1],mix[13]);
- b = GMUL(i[ 2],mix[14]);
- c = GMUL(i[ 3],mix[15]);
- d = GMUL(i[ 4],mix[16]);
- out[ 4] = XOR(XOR(a,b),XOR(c,d));
-
-
- a = GMUL(i[ 5],mix[ 1]);
- b = GMUL(i[ 6],mix[ 2]);
- c = GMUL(i[ 7],mix[ 3]);
- d = GMUL(i[ 8],mix[ 4]);
- out[ 5] = XOR(XOR(a,b),XOR(c,d));
- a = GMUL(i[ 5],mix[ 5]);
- b = GMUL(i[ 6],mix[ 6]);
- c = GMUL(i[ 7],mix[ 7]);
- d = GMUL(i[ 8],mix[ 8]);
- out[ 6] = XOR(XOR(a,b),XOR(c,d));
- a = GMUL(i[ 5],mix[ 9]);
- b = GMUL(i[ 6],mix[10]);
- c = GMUL(i[ 7],mix[11]);
- d = GMUL(i[ 8],mix[12]);
- out[ 7] = XOR(XOR(a,b),XOR(c,d));
- a = GMUL(i[ 5],mix[13]);
- b = GMUL(i[ 6],mix[14]);
- c = GMUL(i[ 7],mix[15]);
- d = GMUL(i[ 8],mix[16]);
- out[ 8] = XOR(XOR(a,b),XOR(c,d));
-
-
- a = GMUL(i[ 9],mix[ 1]);
- b = GMUL(i[10],mix[ 2]);
- c = GMUL(i[11],mix[ 3]);
- d = GMUL(i[12],mix[ 4]);
- out[ 9] = XOR(XOR(a,b),XOR(c,d));
- a = GMUL(i[ 9],mix[ 5]);
- b = GMUL(i[10],mix[ 6]);
- c = GMUL(i[11],mix[ 7]);
- d = GMUL(i[12],mix[ 8]);
- out[10] = XOR(XOR(a,b),XOR(c,d));
- a = GMUL(i[ 9],mix[ 9]);
- b = GMUL(i[10],mix[10]);
- c = GMUL(i[11],mix[11]);
- d = GMUL(i[12],mix[12]);
- out[11] = XOR(XOR(a,b),XOR(c,d));
- a = GMUL(i[ 9],mix[13]);
- b = GMUL(i[10],mix[14]);
- c = GMUL(i[11],mix[15]);
- d = GMUL(i[12],mix[16]);
- out[12] = XOR(XOR(a,b),XOR(c,d));
-
-
- a = GMUL(i[13],mix[ 1]);
- b = GMUL(i[14],mix[ 2]);
- c = GMUL(i[15],mix[ 3]);
- d = GMUL(i[16],mix[ 4]);
- out[13] = XOR(XOR(a,b),XOR(c,d));
- a = GMUL(i[13],mix[ 5]);
- b = GMUL(i[14],mix[ 6]);
- c = GMUL(i[15],mix[ 7]);
- d = GMUL(i[16],mix[ 8]);
- out[14] = XOR(XOR(a,b),XOR(c,d));
- a = GMUL(i[13],mix[ 9]);
- b = GMUL(i[14],mix[10]);
- c = GMUL(i[15],mix[11]);
- d = GMUL(i[16],mix[12]);
- out[15] = XOR(XOR(a,b),XOR(c,d));
- a = GMUL(i[13],mix[13]);
- b = GMUL(i[14],mix[14]);
- c = GMUL(i[15],mix[15]);
- d = GMUL(i[16],mix[16]);
- out[16] = XOR(XOR(a,b),XOR(c,d));
-
- return out;
-end
-
-local keyRound = function(key,round)
- local i=(round-1)*32;
- local out=key;
- print("Doing keyRound on key:")
- PrintTable(key)
- print("key[i+1]=")
- print(key[i+1])
- print("SBOX[out[30+i]]=")
- print(SBOX[out[30+i]])
- print("out[30+i]=")
- print(out[30+i])
- print("RCON[round]=")
- print(RCON[round])
- out[33+i] = XOR(key[ 1+i],XOR(SBOX[key[30+i]],RCON[round]));
- out[34+i] = XOR(key[ 2+i],SBOX[key[31+i]]);
- out[35+i] = XOR(key[ 3+i],SBOX[key[32+i]]);
- out[36+i] = XOR(key[ 4+i],SBOX[key[29+i]]);
-
- out[37+i] = XOR(out[33+i],key[ 5+i]);
- out[38+i] = XOR(out[34+i],key[ 6+i]);
- out[39+i] = XOR(out[35+i],key[ 7+i]);
- out[40+i] = XOR(out[36+i],key[ 8+i]);
-
- out[41+i] = XOR(out[37+i],key[ 9+i]);
- out[42+i] = XOR(out[38+i],key[10+i]);
- out[43+i] = XOR(out[39+i],key[11+i]);
- out[44+i] = XOR(out[40+i],key[12+i]);
-
- out[45+i] = XOR(out[41+i],key[13+i]);
- out[46+i] = XOR(out[42+i],key[14+i]);
- out[47+i] = XOR(out[43+i],key[15+i]);
- out[48+i] = XOR(out[44+i],key[16+i]);
-
-
- out[49+i] = XOR(SBOX[out[45+i]],key[17+i]);
- out[50+i] = XOR(SBOX[out[46+i]],key[18+i]);
- out[51+i] = XOR(SBOX[out[47+i]],key[19+i]);
- out[52+i] = XOR(SBOX[out[48+i]],key[20+i]);
-
- out[53+i] = XOR(out[49+i],key[21+i]);
- out[54+i] = XOR(out[50+i],key[22+i]);
- out[55+i] = XOR(out[51+i],key[23+i]);
- out[56+i] = XOR(out[52+i],key[24+i]);
-
- out[57+i] = XOR(out[53+i],key[25+i]);
- out[58+i] = XOR(out[54+i],key[26+i]);
- out[59+i] = XOR(out[55+i],key[27+i]);
- out[60+i] = XOR(out[56+i],key[28+i]);
-
- out[61+i] = XOR(out[57+i],key[29+i]);
- out[62+i] = XOR(out[58+i],key[30+i]);
- out[63+i] = XOR(out[59+i],key[31+i]);
- out[64+i] = XOR(out[60+i],key[32+i]);
-
- return out;
-end
-
-local keyExpand = function(key)
- local bytes = Array.copy(key);
-
- for i=1,7 do
- keyRound(bytes,i);
- end
-
- local keys = {};
-
- keys[ 1] = Array.slice(bytes,1,16);
- keys[ 2] = Array.slice(bytes,17,32);
- keys[ 3] = Array.slice(bytes,33,48);
- keys[ 4] = Array.slice(bytes,49,64);
- keys[ 5] = Array.slice(bytes,65,80);
- keys[ 6] = Array.slice(bytes,81,96);
- keys[ 7] = Array.slice(bytes,97,112);
- keys[ 8] = Array.slice(bytes,113,128);
- keys[ 9] = Array.slice(bytes,129,144);
- keys[10] = Array.slice(bytes,145,160);
- keys[11] = Array.slice(bytes,161,176);
- keys[12] = Array.slice(bytes,177,192);
- keys[13] = Array.slice(bytes,193,208);
- keys[14] = Array.slice(bytes,209,224);
- keys[15] = Array.slice(bytes,225,240);
-
- return keys;
-
-end
-
-local addKey = Array.XOR;
-
-
-
-local AES = {};
-
-AES.blockSize = 16;
-
-AES.encrypt = function(key,block)
- print("Calling keyExpand on :")
- PrintTable(key)
- local key = keyExpand(key);
-
- --round 0
- block = addKey(block,key[1]);
-
- print("block is:")
- PrintTable(block)
-
- --round 1
- block = byteSub(block,SBOX);
- block = shiftRow(block,ROW_SHIFT);
- block = mixCol(block,MIXTABLE);
- block = addKey(block,key[2]);
-
- --round 2
- block = byteSub(block,SBOX);
- block = shiftRow(block,ROW_SHIFT);
- block = mixCol(block,MIXTABLE);
- block = addKey(block,key[3]);
-
- --round 3
- block = byteSub(block,SBOX);
- block = shiftRow(block,ROW_SHIFT);
- block = mixCol(block,MIXTABLE);
- block = addKey(block,key[4]);
-
- --round 4
- block = byteSub(block,SBOX);
- block = shiftRow(block,ROW_SHIFT);
- block = mixCol(block,MIXTABLE);
- block = addKey(block,key[5]);
-
- --round 5
- block = byteSub(block,SBOX);
- block = shiftRow(block,ROW_SHIFT);
- block = mixCol(block,MIXTABLE);
- block = addKey(block,key[6]);
-
- --round 6
- block = byteSub(block,SBOX);
- block = shiftRow(block,ROW_SHIFT);
- block = mixCol(block,MIXTABLE);
- block = addKey(block,key[7]);
-
- --round 7
- block = byteSub(block,SBOX);
- block = shiftRow(block,ROW_SHIFT);
- block = mixCol(block,MIXTABLE);
- block = addKey(block,key[8]);
-
- --round 8
- block = byteSub(block,SBOX);
- block = shiftRow(block,ROW_SHIFT);
- block = mixCol(block,MIXTABLE);
- block = addKey(block,key[9]);
-
- --round 9
- block = byteSub(block,SBOX);
- block = shiftRow(block,ROW_SHIFT);
- block = mixCol(block,MIXTABLE);
- block = addKey(block,key[10]);
-
- --round 10
- block = byteSub(block,SBOX);
- block = shiftRow(block,ROW_SHIFT);
- block = mixCol(block,MIXTABLE);
- block = addKey(block,key[11]);
-
- --round 11
- block = byteSub(block,SBOX);
- block = shiftRow(block,ROW_SHIFT);
- block = mixCol(block,MIXTABLE);
- block = addKey(block,key[12]);
-
- --round 12
- block = byteSub(block,SBOX);
- block = shiftRow(block,ROW_SHIFT);
- block = mixCol(block,MIXTABLE);
- block = addKey(block,key[13]);
-
- --round 13
- block = byteSub(block,SBOX);
- block = shiftRow(block,ROW_SHIFT);
- block = mixCol(block,MIXTABLE);
- block = addKey(block,key[14]);
-
- --round 14
- block = byteSub(block,SBOX);
- block = shiftRow(block,ROW_SHIFT);
- block = addKey(block,key[15]);
-
- return block;
-
-end
-
-AES.decrypt = function(key,block)
-
- local key = keyExpand(key);
-
- --round 0
- block = addKey(block,key[15]);
-
- --round 1
- block = shiftRow(block,IROW_SHIFT);
- block = byteSub(block,ISBOX);
- block = addKey(block,key[14]);
- block = mixCol(block,IMIXTABLE);
-
- --round 2
- block = shiftRow(block,IROW_SHIFT);
- block = byteSub(block,ISBOX);
- block = addKey(block,key[13]);
- block = mixCol(block,IMIXTABLE);
-
- --round 3
- block = shiftRow(block,IROW_SHIFT);
- block = byteSub(block,ISBOX);
- block = addKey(block,key[12]);
- block = mixCol(block,IMIXTABLE);
-
- --round 4
- block = shiftRow(block,IROW_SHIFT);
- block = byteSub(block,ISBOX);
- block = addKey(block,key[11]);
- block = mixCol(block,IMIXTABLE);
-
- --round 5
- block = shiftRow(block,IROW_SHIFT);
- block = byteSub(block,ISBOX);
- block = addKey(block,key[10]);
- block = mixCol(block,IMIXTABLE);
-
- --round 6
- block = shiftRow(block,IROW_SHIFT);
- block = byteSub(block,ISBOX);
- block = addKey(block,key[9]);
- block = mixCol(block,IMIXTABLE);
-
- --round 7
- block = shiftRow(block,IROW_SHIFT);
- block = byteSub(block,ISBOX);
- block = addKey(block,key[8]);
- block = mixCol(block,IMIXTABLE);
-
- --round 8
- block = shiftRow(block,IROW_SHIFT);
- block = byteSub(block,ISBOX);
- block = addKey(block,key[7]);
- block = mixCol(block,IMIXTABLE);
-
- --round 9
- block = shiftRow(block,IROW_SHIFT);
- block = byteSub(block,ISBOX);
- block = addKey(block,key[6]);
- block = mixCol(block,IMIXTABLE);
-
- --round 10
- block = shiftRow(block,IROW_SHIFT);
- block = byteSub(block,ISBOX);
- block = addKey(block,key[5]);
- block = mixCol(block,IMIXTABLE);
-
- --round 11
- block = shiftRow(block,IROW_SHIFT);
- block = byteSub(block,ISBOX);
- block = addKey(block,key[4]);
- block = mixCol(block,IMIXTABLE);
-
- --round 12
- block = shiftRow(block,IROW_SHIFT);
- block = byteSub(block,ISBOX);
- block = addKey(block,key[3]);
- block = mixCol(block,IMIXTABLE);
-
- --round 13
- block = shiftRow(block,IROW_SHIFT);
- block = byteSub(block,ISBOX);
- block = addKey(block,key[2]);
- block = mixCol(block,IMIXTABLE);
-
- --round 14
- block = shiftRow(block,IROW_SHIFT);
- block = byteSub(block,ISBOX);
- block = addKey(block,key[1]);
-
- return block;
-end
-
-return AES;
diff --git a/gamemode/shared/inventory.lua b/gamemode/shared/inventory.lua
index 006a566..f06d053 100644
--- a/gamemode/shared/inventory.lua
+++ b/gamemode/shared/inventory.lua
@@ -1,3 +1,5 @@
+do return end
+
--[[
Various functions to work with inventories
player:GetCredits()
diff --git a/gamemode/shared/inventory_common.lua b/gamemode/shared/inventory_common.lua
index aaf6afb..c5553fe 100644
--- a/gamemode/shared/inventory_common.lua
+++ b/gamemode/shared/inventory_common.lua
@@ -1,6 +1,7 @@
--[[
Some functions that are needed multiple places in the code, to deal with player inventories.
]]
+do return end
print("Hello from inventory_common.lua")
local invfuncs = {}
diff --git a/gamemode/shared/itemsystem/exampleitem.lua b/gamemode/shared/itemsystem/exampleitem.lua
index a21def8..066e107 100644
--- a/gamemode/shared/itemsystem/exampleitem.lua
+++ b/gamemode/shared/itemsystem/exampleitem.lua
@@ -82,4 +82,4 @@ end
print("Hello from exampleitem.lua")
--Don't forget to register the item!
-ART.RegisterItem(item)
+nrequire("item.lua").RegisterItem(item)
diff --git a/gamemode/shared/loadnpcs.lua b/gamemode/shared/loadnpcs.lua
index 3e1861f..2906597 100644
--- a/gamemode/shared/loadnpcs.lua
+++ b/gamemode/shared/loadnpcs.lua
@@ -1,4 +1,4 @@
-
+do return end
local f = include("concommands.lua")
ART = ART or {}
diff --git a/gamemode/shared/loadprayers.lua b/gamemode/shared/loadprayers.lua
index 3c94b72..01d538c 100644
--- a/gamemode/shared/loadprayers.lua
+++ b/gamemode/shared/loadprayers.lua
@@ -1,6 +1,7 @@
--[[
This file loads in all the prayers
]]
+do return end
local concmd = include("concommands.lua")
--local autolua = include("../autolua.lua")
print("Hello from LoadItems.lua!")
diff --git a/gamemode/shared/lockbox/array.lua b/gamemode/shared/lockbox/array.lua
deleted file mode 100644
index 8a2fd30..0000000
--- a/gamemode/shared/lockbox/array.lua
+++ /dev/null
@@ -1,210 +0,0 @@
-local String = string
-local Bit = include("bit.lua");
-
-local XOR = Bit.bxor;
-
-local Array = {};
-
-Array.size = function(array)
- return #array;
-end
-
-Array.fromString = function(string)
- local bytes = {};
-
- local i=1;
- local byte = String.byte(string,i);
- while byte ~= nil do
- bytes[i] = byte;
- i = i + 1;
- byte = String.byte(string,i);
- end
-
- return bytes;
-
-end
-
-Array.toString = function(bytes)
- local chars = {};
- local i=1;
-
- local byte = bytes[i];
- while byte ~= nil do
- chars[i] = String.char(byte);
- i = i+1;
- byte = bytes[i];
- end
-
- return table.concat(chars,"");
-end
-
-Array.fromStream = function(stream)
- local array = {};
- local i=1;
-
- local byte = stream();
- while byte ~= nil do
- array[i] = byte;
- i = i+1;
- byte = stream();
- end
-
- return array;
-end
-
-Array.readFromQueue = function(queue,size)
- local array = {};
-
- for i=1,size do
- array[i] = queue.pop();
- end
-
- return array;
-end
-
-Array.writeToQueue = function(queue,array)
- local size = Array.size(array);
-
- for i=1,size do
- queue.push(array[i]);
- end
-end
-
-Array.toStream = function(array)
- local queue = Queue();
- local i=1;
-
- local byte = array[i];
- while byte ~= nil do
- queue.push(byte);
- i=i+1;
- byte = array[i];
- end
-
- return queue.pop;
-end
-
-
-local fromHexTable = {};
-for i=0,255 do
- fromHexTable[String.format("%02X",i)]=i;
- fromHexTable[String.format("%02x",i)]=i;
-end
-
-Array.fromHex = function(hex)
- local array = {};
-
- for i=1,String.len(hex)/2 do
- local h = String.sub(hex,i*2-1,i*2);
- array[i] = fromHexTable[h];
- end
-
- return array;
-end
-
-
-local toHexTable = {};
-for i=0,255 do
- toHexTable[i]=String.format("%02X",i);
-end
-
-Array.toHex = function(array)
- local hex = {};
- local i = 1;
-
- local byte = array[i];
- while byte ~= nil do
- hex[i] = toHexTable[byte];
- i=i+1;
- byte = array[i];
- end
-
- return table.concat(hex,"");
-
-end
-
-Array.concat = function(a,b)
- local concat = {};
- local out=1;
-
- local i=1;
- local byte = a[i];
- while byte ~= nil do
- concat[out] = byte;
- i = i + 1;
- out = out + 1;
- byte = a[i];
- end
-
- local i=1;
- local byte = b[i];
- while byte ~= nil do
- concat[out] = byte;
- i = i + 1;
- out = out + 1;
- byte = b[i];
- end
-
- return concat;
-end
-
-Array.truncate = function(a,newSize)
- local x = {};
-
- for i=1,newSize do
- x[i]=a[i];
- end
-
- return x;
-end
-
-Array.XOR = function(a,b)
- local x = {};
-
- for k,v in pairs(a) do
- x[k] = XOR(v,b[k]);
- end
-
- return x;
-end
-
-Array.substitute = function(input,sbox)
- local out = {};
-
- for k,v in pairs(input) do
- out[k] = sbox[v];
- end
-
- return out;
-end
-
-Array.permute = function(input,pbox)
- local out = {};
-
- for k,v in pairs(pbox) do
- out[k] = input[v];
- end
-
- return out;
-end
-
-Array.copy = function(input)
- local out = {};
-
- for k,v in pairs(input) do
- out[k] = v;
- end
- return out;
-end
-
-Array.slice = function(input,start,stop)
- local out = {};
-
- for i=start,stop do
- out[i-start+1] = input[i];
- end
- return out;
-end
-
-
-return Array;
diff --git a/gamemode/shared/lockbox/base64.lua b/gamemode/shared/lockbox/base64.lua
deleted file mode 100644
index 3d9ffc3..0000000
--- a/gamemode/shared/lockbox/base64.lua
+++ /dev/null
@@ -1,157 +0,0 @@
-local String = string
-local Bit = include("bit.lua");
-
-local Array = include("array.lua");
-local Stream = include("stream.lua");
-
-local AND = Bit.band;
-local OR = Bit.bor;
-local NOT = Bit.bnot;
-local XOR = Bit.bxor;
-local LROT = Bit.lrotate;
-local RROT = Bit.rrotate;
-local LSHIFT = Bit.lshift;
-local RSHIFT = Bit.rshift;
-
-
-local SYMBOLS = {
-[0]="A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P",
- "Q","R","S","T","U","V","W","X","Y","Z","a","b","c","d","e","f",
- "g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v",
- "w","x","y","z","0","1","2","3","4","5","6","7","8","9","+","/"};
-
-local LOOKUP = {};
-
-for k,v in pairs(SYMBOLS) do
- LOOKUP[k]=v;
- LOOKUP[v]=k;
-end
-
-
-local Base64 = {};
-
-Base64.fromStream = function(stream)
- local bits = 0x00;
- local bitCount = 0;
- local base64 = {};
-
- local byte = stream();
- while byte ~= nil do
- bits = OR(LSHIFT(bits,8),byte);
- bitCount = bitCount + 8;
- while bitCount >= 6 do
- bitCount = bitCount - 6;
- local temp = RSHIFT(bits,bitCount);
- table.insert(base64,LOOKUP[temp]);
- bits = AND(bits,NOT(LSHIFT(0xFFFFFFFF,bitCount)));
- end
- byte = stream();
- end
-
- if (bitCount == 4) then
- bits = LSHIFT(bits,2);
- table.insert(base64,LOOKUP[bits]);
- table.insert(base64,"=");
- elseif (bitCount == 2) then
- bits = LSHIFT(bits,4);
- table.insert(base64,LOOKUP[bits]);
- table.insert(base64,"==");
- end
-
- return table.concat(base64,"");
-end
-
-Base64.fromArray = function(array)
- local bits = 0x00;
- local bitCount = 0;
- local base64 = {};
-
- local ind = 1;
-
- local byte = array[ind]; ind = ind + 1;
- while byte ~= nil do
- bits = OR(LSHIFT(bits,8),byte);
- bitCount = bitCount + 8;
- while bitCount >= 6 do
- bitCount = bitCount - 6;
- local temp = RSHIFT(bits,bitCount);
- table.insert(base64,LOOKUP[temp]);
- bits = AND(bits,NOT(LSHIFT(0xFFFFFFFF,bitCount)));
- end
- byte = array[ind]; ind = ind + 1;
- end
-
- if (bitCount == 4) then
- bits = LSHIFT(bits,2);
- table.insert(base64,LOOKUP[bits]);
- table.insert(base64,"=");
- elseif (bitCount == 2) then
- bits = LSHIFT(bits,4);
- table.insert(base64,LOOKUP[bits]);
- table.insert(base64,"==");
- end
-
- return table.concat(base64,"");
-end
-
-Base64.fromString = function(string)
- return Base64.fromArray(Array.fromString(string));
-end
-
-
-
-Base64.toStream = function(base64)
- return Stream.fromArray(Base64.toArray(base64));
-end
-
-Base64.toArray = function(base64)
- local bits = 0x00;
- local bitCount = 0;
-
- local bytes = {};
-
- for c in String.gmatch(base64,".") do
- if (c == "=") then
- bits = RSHIFT(bits,2); bitCount = bitCount - 2;
- else
- bits = LSHIFT(bits,6); bitCount = bitCount + 6;
- bits = OR(bits,LOOKUP[c]);
- end
-
- while(bitCount >= 8) do
- bitCount = bitCount - 8;
- local temp = RSHIFT(bits,bitCount);
- table.insert(bytes,temp);
- bits = AND(bits,NOT(LSHIFT(0xFFFFFFFF,bitCount)));
- end
- end
-
- return bytes;
-end
-
-Base64.toString = function(base64)
- local bits = 0x00;
- local bitCount = 0;
-
- local chars = {};
-
- for c in String.gmatch(base64,".") do
- if (c == "=") then
- bits = RSHIFT(bits,2); bitCount = bitCount - 2;
- else
- bits = LSHIFT(bits,6); bitCount = bitCount + 6;
- bits = OR(bits,LOOKUP[c]);
- end
-
- while(bitCount >= 8) do
- bitCount = bitCount - 8;
- local temp = RSHIFT(bits,bitCount);
- table.insert(chars,String.char(temp));
- bits = AND(bits,NOT(LSHIFT(0xFFFFFFFF,bitCount)));
- end
- end
-
- return table.concat(chars,"");
-end
-
-return Base64;
diff --git a/gamemode/shared/lockbox/bit.lua b/gamemode/shared/lockbox/bit.lua
deleted file mode 100644
index 0ccdb82..0000000
--- a/gamemode/shared/lockbox/bit.lua
+++ /dev/null
@@ -1,11 +0,0 @@
-local e = bit
-
--- Workaround to support Lua 5.2 bit32 API with the LuaJIT bit one
-if e.rol and not e.lrotate then
- e.lrotate = e.rol
-end
-if e.ror and not e.rrotate then
- e.rrotate = e.ror
-end
-
-return bit
diff --git a/gamemode/shared/lockbox/ecb.lua b/gamemode/shared/lockbox/ecb.lua
deleted file mode 100644
index 67f4514..0000000
--- a/gamemode/shared/lockbox/ecb.lua
+++ /dev/null
@@ -1,191 +0,0 @@
-local Array = include("array.lua");
-local Stream = include("stream.lua");
-local Queue = include("queue.lua");
-
-local Bit = include("bit.lua");
-
-local CBC = {};
-
-CBC.Cipher = function()
-
- local public = {};
-
- local key;
- local blockCipher;
- local padding;
- local inputQueue;
- local outputQueue;
- local iv;
-
- public.setKey = function(keyBytes)
- print("Set key to:")
- print(keyBytes)
- key = keyBytes;
- return public;
- end
-
- public.setBlockCipher = function(cipher)
- blockCipher = cipher;
- return public;
- end
-
- public.setPadding = function(paddingMode)
- padding = paddingMode;
- return public;
- end
-
- public.init = function()
- inputQueue = Queue();
- outputQueue = Queue();
- iv = nil;
- return public;
- end
-
- public.update = function(messageStream)
- print("Entering update")
- local byte = messageStream();
- while (byte ~= nil) do
- print("processing byte")
- inputQueue.push(byte);
- print("inputQueue.size is:" .. inputQueue.size())
- print("blockCipher.blockSize:" .. blockCipher.blockSize)
- if(inputQueue.size() >= blockCipher.blockSize) then
- print("reading from queue")
- local block = Array.readFromQueue(inputQueue,blockCipher.blockSize);
- if(iv == nil) then
- print("iv was nil, iv is now")
- iv = block;
- PrintTable(block)
- else
- print("iv was not nil, doing thing")
- local out = Array.XOR(iv,block);
- print("Calling encrypt with key:")
- print(key)
- print("and out")
- print(out)
- out = blockCipher.encrypt(key,out);
- print("Out was:")
- print(out)
- Array.writeToQueue(outputQueue,out);
- iv = out;
- end
- end
- byte = messageStream();
- end
- print("Before update returned, blockCipher was ")
- PrintTable(blockCipher)
- return public;
- end
-
- public.finish = function()
- paddingStream = padding(blockCipher.blockSize,inputQueue.getHead());
- public.update(paddingStream);
-
- return public;
- end
-
- public.getOutputQueue = function()
- return outputQueue;
- end
-
- public.asHex = function()
- print("Outputqueue is:")
- PrintTable(outputQueue)
- return Stream.toHex(outputQueue.pop);
- end
-
- public.asBytes = function()
- return Stream.toArray(outputQueue.pop);
- end
-
- return public;
-
-end
-
-
-CBC.Decipher = function()
-
- local public = {};
-
- local key;
- local blockCipher;
- local padding;
- local inputQueue;
- local outputQueue;
- local iv;
-
- public.setKey = function(keyBytes)
- key = keyBytes;
- return public;
- end
-
- public.setBlockCipher = function(cipher)
- blockCipher = cipher;
- return public;
- end
-
- public.setPadding = function(paddingMode)
- padding = paddingMode;
- return public;
- end
-
- public.init = function()
- inputQueue = Queue();
- outputQueue = Queue();
- iv = nil;
- return public;
- end
-
- public.update = function(messageStream)
- print("Updateing decipher with messagestream")
- local byte = messageStream();
- while (byte ~= nil) do
- inputQueue.push(byte);
- if(inputQueue.size() >= blockCipher.blockSize) then
- local block = Array.readFromQueue(inputQueue,blockCipher.blockSize);
-
- if(iv == nil) then
- iv = block;
- print("Setting iv to ")
- PrintTable(iv)
- else
- local out = block;
- out = blockCipher.decrypt(key,out);
- out = Array.XOR(iv,out);
- Array.writeToQueue(outputQueue,out);
- iv = block;
- end
- end
- byte = messageStream();
- end
- return public;
- end
-
- public.finish = function()
- paddingStream = padding(blockCipher.blockSize,inputQueue.getHead());
- public.update(paddingStream);
-
- return public;
- end
-
- public.getOutputQueue = function()
- return outputQueue;
- end
-
- public.asHex = function()
- return Stream.toHex(outputQueue.pop);
- end
-
- public.asBytes = function()
- return Stream.toArray(outputQueue.pop);
- end
-
- public.asString = function()
- return Stream.toString(outputQueue.pop)
- end
-
- return public;
-
-end
-
-return CBC;
diff --git a/gamemode/shared/lockbox/padding.lua b/gamemode/shared/lockbox/padding.lua
deleted file mode 100644
index 72be077..0000000
--- a/gamemode/shared/lockbox/padding.lua
+++ /dev/null
@@ -1,21 +0,0 @@
-local Stream = include("stream.lua");
-
-local ZeroPadding = function(blockSize,byteCount)
-
- local paddingCount = blockSize - ((byteCount -1) % blockSize) + 1;
- local bytesLeft = paddingCount;
-
- local stream = function()
- if bytesLeft > 0 then
- bytesLeft = bytesLeft - 1;
- return 0x00;
- else
- return nil;
- end
- end
-
- return stream;
-
-end
-
-return ZeroPadding;
diff --git a/gamemode/shared/lockbox/queue.lua b/gamemode/shared/lockbox/queue.lua
deleted file mode 100644
index 55b067d..0000000
--- a/gamemode/shared/lockbox/queue.lua
+++ /dev/null
@@ -1,47 +0,0 @@
-local Queue = function()
- local queue = {};
- local tail = 0;
- local head = 0;
-
- local public = {};
-
- public.push = function(obj)
- queue[head] = obj;
- head = head + 1;
- return;
- end
-
- public.pop = function()
- if tail < head
- then
- local obj = queue[tail];
- queue[tail] = nil;
- tail = tail + 1;
- return obj;
- else
- return nil;
- end
- end
-
- public.size = function()
- return head - tail;
- end
-
- public.getHead = function()
- return head;
- end
-
- public.getTail = function()
- return tail;
- end
-
- public.reset = function()
- queue = {};
- head = 0;
- tail = 0;
- end
-
- return public;
-end
-
-return Queue;
diff --git a/gamemode/shared/lockbox/stream.lua b/gamemode/shared/lockbox/stream.lua
deleted file mode 100644
index aeb3b18..0000000
--- a/gamemode/shared/lockbox/stream.lua
+++ /dev/null
@@ -1,112 +0,0 @@
-local Queue = include("queue.lua");
-local String = string
-
-local Stream = {};
-
-
-Stream.fromString = function(string)
- local i=0;
- return function()
- print("string is:" .. string)
- print("len is:" .. string.len(string))
- print("i is:" .. i)
- i=i+1;
- if(i <= string.len(string)) then
- return string.byte(string,i);
- else
- return nil;
- end
- end
-end
-
-
-Stream.toString = function(stream)
- local array = {};
- local i=1;
-
- local byte = stream();
- while byte ~= nil do
- array[i] = String.char(byte);
- i = i+1;
- byte = stream();
- end
-
- return table.concat(array,"");
-end
-
-
-Stream.fromArray = function(array)
- local queue = Queue();
- local i=1;
-
- local byte = array[i];
- while byte ~= nil do
- queue.push(byte);
- i=i+1;
- byte = array[i];
- end
-
- return queue.pop;
-end
-
-
-Stream.toArray = function(stream)
- local array = {};
- local i=1;
-
- local byte = stream();
- while byte ~= nil do
- array[i] = byte;
- i = i+1;
- byte = stream();
- end
-
- return array;
-end
-
-
-local fromHexTable = {};
-for i=0,255 do
- fromHexTable[String.format("%02X",i)]=i;
- fromHexTable[String.format("%02x",i)]=i;
-end
-
-Stream.fromHex = function(hex)
- local queue = Queue();
-
- for i=1,String.len(hex)/2 do
- local h = String.sub(hex,i*2-1,i*2);
- queue.push(fromHexTable[h]);
- end
-
- return queue.pop;
-end
-
-
-
-local toHexTable = {};
-for i=0,255 do
- toHexTable[i]=String.format("%02X",i);
-end
-
-Stream.toHex = function(stream)
- print("tohex called with stream")
- print(stream)
- local hex = {};
- local i = 1;
-
- local byte = stream();
- print("First byte is")
- print(byte)
- while byte ~= nil do
- print("Createing hex:")
- print(table.concat(hex,""))
- hex[i] = toHexTable[byte];
- i=i+1;
- byte = stream();
- end
-
- return table.concat(hex,"");
-end
-
-return Stream;
diff --git a/gamemode/shared/log.lua b/gamemode/shared/log.lua
new file mode 100644
index 0000000..63d3e0e
--- /dev/null
+++ b/gamemode/shared/log.lua
@@ -0,0 +1,23 @@
+
+local fn = nrequire("fn.lua")
+local col = nrequire("colortheme.lua")
+local log = {}
+
+log.debug = fn.curry(
+ fn.curry(
+ MsgC,
+ col.console.cyan),
+ fn.curry(
+ string.format,
+ "[DEBUG] %s"))
+
+log.warn = fn.compose(
+ fn.curry(
+ MsgC,
+ col.console.yellow),
+ debug.traceback,
+ fn.curry(
+ ErrorNoHalt,
+ "[WARNING]"))
+
+return log
diff --git a/gamemode/utility/fn.lua b/gamemode/utility/fn.lua
new file mode 100644
index 0000000..7c53150
--- /dev/null
+++ b/gamemode/utility/fn.lua
@@ -0,0 +1,229 @@
+--[[
+ Various functional programming bits and bobs
+ Function signatures:
+ fn.curry(func,...) :: function(...) :: any
+ fn.map(tbl,func) :: table
+ fn.compose(...) :: function(...) :: any
+ fn.filter(tbl,func) :: table
+ fn.zip(...) :: table
+ fn.fill(arg,times) :: table
+ fn.amalg(...) :: function(...) :: any
+ fn.cycle(tbl) :: table
+ fn.fold(tbl) :: function(func(T1,T2)::T) :: T
+ fn.flatten(tbl) :: table
+]]
+--AddCSLuaFile()
+local fn = {}
+
+if table.Copy == nil then
+ function table.Copy(tbl)
+ local ntbl = {}
+ for k,v in pairs(tbl) do ntbl[k] = v end
+ return ntbl
+ end
+end
+
+--[[
+ Puts some arguments "in" a function so that it can be called with some number fewer arguments.
+ Ex:
+ local f = include("nightz/gamemode/utility/functional.lua")
+ local debugprint = f.curry(print,"[DEBUG]")
+ debugprint("Hello, world!")
+ --Is the same as
+ print("[DEBUG]","Hello, world!")
+]]
+function fn.curry(func,...)
+ local nargs = {...}
+ return function(...)
+ for k,v in pairs({...}) do
+ nargs[k + #nargs] = v
+ end
+ func(unpack(nargs))
+ end
+end
+
+--[[
+ calls each function from first to last on every element of tbl, and returns a table with the function called.
+ Ex:
+ local f = include("nightz/gamemode/utility/functional.lua")
+ local playerents = {
+ Player(1),
+ Player(2),
+ Player(3)
+ }
+ local getname = function(ply) return ply:Nick() end
+ local playernames = f.map(playerents)
+ --playernames is now a table {
+ "Player1_name",
+ "Player2_name",
+ "Player3_name"
+ }
+]]
+function fn.map(tbl,...)
+ local nfuncs = {...}
+ local ntbl = table.Copy(tbl)
+ for i,j in pairs(nfuncs) do
+ for k,v in pairs(tbl) do
+ ntbl[k] = j(v)
+ end
+ end
+ return ntbl
+end
+
+--[[
+ Calls a list of functions, starting with the last, going to the first, and passes the arguments as whatever was outputed from the previous function.
+ Ex:
+ local f = include("nightz/gamemode/utility/functional.lua")
+ local printf = f.compose(print,string.format)
+ printf("Thanks, I love %d",5)
+ --Is the same as
+ print(string.format("Thanks, I love %d", 5))
+]]
+function fn.compose(...)
+ local nargs = {...}
+ local n = #nargs
+ local lastresult
+ return function(...)
+ lastresult = {...}
+ while n > 0 do
+ lastresult = {nargs[n](unpack(lastresult))}
+ n = n - 1
+ end
+ end
+end
+
+--[[
+ Removes elements from tbl for which func returns nil or false (returns new table). this WILL mess up order for arrays.
+ Ex:
+ local f = include("nightz/gamemode/utility/functional.lua")
+ local sometable = {
+ 1,3,4,5,5,6,7,8,9
+ }
+ for k,v in pairs(sometable) do print(k,":",v) end
+ --this will print:
+ 1:1
+ 2:3
+ 3:4
+ 4:5
+ 5:5
+ 6:6
+ 7:7
+ 8:8
+ 9:9
+ local function iseven(k) return k%2 == 0 end
+ local evens = f.filter(sometable,iseven)
+ for k,v in pairs(evens) do print(k,":",v) end
+ --this will print:
+ 3:4
+ 6:6
+ 8:8
+]]
+function fn.filter(tbl,func)
+ local ntbl = table.Copy(tbl)
+ for k,v in pairs(ntbl) do
+ if not func(v) then
+ ntbl[k] = nil
+ end
+ end
+end
+
+--Takes n tables that have the same indexes, and returns a table that for every index, it's value is {tbl1[index],tbl2[index],...,tbln[index]}
+function fn.zip(...)
+ local nargs = {...}
+ local ntbl = table.Copy(nargs[1])
+ for k,v in pairs(ntbl) do
+ local ttbl = {}
+ for i,j in pairs(nargs) do
+ ttbl[#ttbl + 1] = v[i]
+ end
+ ntbl[k] = ttbl
+ end
+ return ntbl
+end
+
+--Creates a table filled with <times> number of arg
+function fn.fill(arg,times)
+ local ret = {}
+ for i = 1,times do
+ ret[i] = arg
+ end
+ return ret
+end
+
+--Calls all functions passed in order, and returns all results for all functions called.S
+function fn.amalg(...)
+ local nargs = {...}
+ return function(...)
+ local nret = {}
+ for k,v in pairs(nargs) do
+ local tret = {v(unpack({...}))}
+ for i,j in pairs(tret) do
+ nret[#nret + 1] = j
+ end
+ end
+ return unpack(nret)
+ end
+end
+
+--[[
+Cycles a table infinitely
+ Ex:
+ local sometbl = {1,2,3}
+ fn.cycle(sometbl)
+ for i = 1, 100 do
+ print(sometbl[i])
+ end
+ Outputs:
+ 1
+ 2
+ 3
+ 1
+ 2
+ :
+ :
+ :
+]]
+function fn.cycle(tbl)
+ local ntbl = table.Copy(tbl)
+ local tbllen = #tbl
+ local mt = {
+ __index = function(self, ind)
+ local id = (ind % tbllen) + 1
+ return tbl[id]
+ end
+ }
+ setmetatable(ntbl,mt)
+ return ntbl
+end
+
+--[[
+ Iterates over a table applying a function to each item
+ Ex:
+ local sometbl = {1,4,5,6,7,10}
+ local add = function(a,b) return a + b end
+ local sum = fn.fold(sometbl)(add)
+ print(sum)
+ Output:
+ 33
+]]
+function fn.fold(tbl)
+ return function(func)
+ local running = tbl[1]
+ for k = 2, #tbl do
+ running = func(running,tbl[k])
+ end
+ return running
+ end
+end
+
+--[[
+ Returns an array-type table
+]]
+function fn.flatten(tbl)
+ local ret = {}
+ for k,v in pairs(tbl) do
+ ret[#ret + 1] = v
+ end
+ return ret
+end
+return fn
diff --git a/gamemode/shared/fuzzel.lua b/gamemode/utility/fuzzel.lua
index 6aad45f..6aad45f 100644
--- a/gamemode/shared/fuzzel.lua
+++ b/gamemode/utility/fuzzel.lua
diff --git a/gamemode/utility/stream.lua b/gamemode/utility/stream.lua
new file mode 100644
index 0000000..cdf3933
--- /dev/null
+++ b/gamemode/utility/stream.lua
@@ -0,0 +1,85 @@
+--[[
+ A stream object, has the methods:
+ stream:WriteString(string) :: nil
+ stream:WriteInt(num,bytes) :: nil
+
+ stream:ReadString() :: string
+ stream:ReadInt(bytes) :: number
+
+ stream:ToString() :: string
+]]
+
+local ss = {}
+
+local function WriteString(self,string)
+ local buflen = #self.buf
+ for i=1,#string do
+ self.buf[buflen+i] = string.byte(string,i)
+ end
+ self.buf[#self.buf + 1] = 0
+end
+
+local function WriteInt(self,num,bytes)
+ local buflen = #self.buf
+ local byte = 255
+ for i = 1,bytes do
+ --[[
+ pack[i] = (num & byte) >> (i-1)*8
+ byte = 255 << i*8
+ ]]
+ self.buf[buflen + i] = bit.rshift(bit.band(num,byte),(i-1)*8)
+ byte = bit.lshift(255,i*8)
+ end
+end
+
+local function ReadInt(self,len)
+ local tbl = {}
+ for i = 1, len do
+ tbl[i] = self.buf[i]
+ end
+ for i = 1, #self.buf do
+ self.buf[i] = self.buf[i+len]
+ end
+ local byte = 1
+ local num = 0
+ for i = 1, #tbl do
+ num = num + (tbl[i] * byte)
+ byte = 2 ^ (i*8)
+ end
+ return num
+end
+
+local function ReadString(self)
+ local str = {}
+ local strlen = 1
+ while self.buf[strlen] ~= 0 do
+ str[#str + 1] = string.char(self.buf[strlen])
+ strlen = strlen + 1
+ end
+ for i = 1,strlen do
+ self.buf[i] = self.buf[i+strlen]
+ end
+ return table.concat(str)
+end
+
+local function ToString(self)
+ return table.concat(self.buf)
+end
+
+function ss.CreateStream(str)
+ local ns = {}
+ ns.buf = {}
+ if str ~= nil then
+ for i = 1, #str do
+ ns[i] = str[i]
+ end
+ end
+ ns.ReadString = ReadString
+ ns.ReadInt = ReadInt
+ ns.WriteString = WriteString
+ ns.WriteInt = WriteInt
+ ns.ToString = ToString
+ return ns
+end
+
+return ss