Inventory networking & added item config stuff

master
AlmTech Software 5 years ago
parent da067dedfe
commit 8d56602a80
  1. 9
      gamemode/cl_init.lua
  2. 2
      gamemode/engine/core/sh_player_binds.lua
  3. 18
      gamemode/engine/derma/menus/menu_charinfo.lua
  4. 4
      gamemode/engine/lib/server/sv_character.lua
  5. 16
      gamemode/engine/lib/server/sv_inventory.lua
  6. 12
      gamemode/engine/lib/sh_items.lua
  7. 8
      gamemode/init.lua
  8. 14
      gamemode/settings/sh_items.lua
  9. 11
      gamemode/settings/sh_settings.lua

@ -7,7 +7,6 @@
if CLIENT then
include( "shared.lua" )
--local gmfolder = GAMEMODE.FolderName || GM.FolderName
Quantum.Client = {}
Quantum.Client.Cache = {}
Quantum.Client.ResolutionScale = ScrH() / 1080
@ -47,6 +46,10 @@ if CLIENT then
include( fol .. "cl_menu.lua" )
end
local function loadAllItems()
include( "settings/sh_items.lua" )
end
function Quantum.Client.Load()
local fol = GM.FolderName .. "/gamemode/engine/core/"
@ -55,6 +58,10 @@ if CLIENT then
loadAllDermaMenus()
Quantum.Debug( "Loaded all files." )
-- add all of the items
loadAllItems()
Quantum.Debug( "Loaded all items." )
end
Quantum.Client.Load()

@ -18,7 +18,7 @@ if SERVER then
name = Quantum.Server.Char.getBasicCharInfo( Quantum.Server.Char.GetCurrentCharacter( pl ) ).name,
money = Quantum.Server.Char.getBasicCharInfo( Quantum.Server.Char.GetCurrentCharacter( pl ) ).money
}, items = {} } )
}, items = { [1] = {"test", 1} } })
end
}

@ -19,7 +19,7 @@ local errorMdl = "models/player.mdl"
function menu.open( dt )
local items = dt.cont.items
PrintTable(dt)
if( !f ) then
Quantum.Client.IsInMenu = true
@ -111,6 +111,10 @@ function menu.open( dt )
if( ii != 1 ) then count = count + 1 end
itempanels[ii] = vgui.Create( "DPanel", itemframe )
itempanels[ii].index = ii -- set the vars
if( items[ii] ) then itempanels[ii].item = Quantum.Item.Get( items[ii][1] ) end -- get the items info through its id
itempanels[ii]:SetSize( itemWidth, itemHeight )
if( count >= maxW ) then
ypos = ypos + yintervall
@ -127,9 +131,19 @@ function menu.open( dt )
itempanels[ii]:SetPos( xpos, ypos )
itempanels[ii].x, itempanels[ii].y = itempanels[ii]:GetPos()
if( itempanels[ii].item == nil ) then -- get the items rarity color
itempanels[ii].itemcolor = Quantum.Rarity.None.color
print( ii, "is nil", itemcolor )
else
itempanels[ii].itemcolor = itempanels[ii].item.rarity.color
print( ii, "is an item", itemcolor )
end
itempanels[ii].Paint = function( self )
theme.itempanel( self, Quantum.Rarity.Rare.color )
theme.itempanel( self, self.itemcolor )
end
end
-- get the width and height of all of the items

@ -112,4 +112,8 @@ function Quantum.Server.Char.GetPlayerChars_cl( pl )
chars[count] = Quantum.Server.Char.getBasicCharInfo( char )
end
return chars
end
function Quantum.Server.Char.GetInventory( char )
return char.inventory
end

@ -10,16 +10,6 @@ Quantum.Server.Inventory = {}
function Quantum.Server.Inventory.Create( char )
char.inventory = {}
for i = 1, Quantum.Inventory.Width do
char.inventory[i] = {}
end
for h, v in pairs( char.inventory ) do
for w = 1, Quantum.Inventory.Height do
char.inventory[h][w] = 0
end
end
return char.inventory
end
@ -27,13 +17,13 @@ local function isEquippable( item )
return item.equipable || false
end
function Quantum.Server.Inventory.SetSlotItem( char, x, y, item, amount )
function Quantum.Server.Inventory.SetSlotItem( char, pos, item, amount )
if( isEquippable( item ) ) then
amount = 1
char.inventory[x][y] = { item }
char.inventory[pos] = { item }
else
amount = amount || 1
char.inventory[x][y] = { item, amount }
char.inventory[pos] = { item, amount }
end
Quantum.Debug( "Gave " .. char.name .. " " .. amount .. " [" .. item.name .. "]" )
return

@ -12,12 +12,18 @@ function Quantum.Item.Create( id, args )
local item = {
name = args.name || "ERROR", -- items name
desc = args.desc || "ERROR: Some idiot forgot to give this item a description.", -- items description
icon = args.icon, -- items icon
model = args.model || "models/props_phx/gears/bevel12.mdl", -- items model
stack = args.stack || false, -- items max stack size
soulbound = args.soulbound || true, -- if item could be dropped/traded to other players
equipable = args.equipable || false, -- equipable or not
rarity = args.rarity || Quantum.Rarity.Trash, -- rarity of the item
usefunction = args.usefunction, -- use function
consumefunction = args.consumefunction, --consume function
equipfunction = args.equipfunction -- equip function
consumefunction = args.consumefunction --consume function
}
Quantum.Items[id] = item
return item
end
function Quantum.Item.Get( id )
return Quantum.Items[id]
end

@ -8,6 +8,7 @@
if SERVER then
AddCSLuaFile( "engine/sh_debug.lua" )
AddCSLuaFile( "settings/sh_settings.lua" )
AddCSLuaFile( "settings/sh_items.lua" )
AddCSLuaFile( "cl_init.lua" )
AddCSLuaFile( "shared.lua" )
@ -99,12 +100,19 @@ if SERVER then
end
end
local function loadAllItems()
include( "settings/sh_items.lua" )
end
function Quantum.Server.Load()
-- Add all of the base files
loadCoreFiles()
loadLibFiles()
addAllDermaMenus()
-- Creation of stuff
loadAllItems() -- load the items
end
Quantum.Server.Load()

@ -3,4 +3,16 @@
-- / / / \ | |_ __ ___ | | ___ ___| |__ \ \
-- < < / /\ \ | | '_ ` _ \| |/ _ \/ __| '_ \ > >
-- \ \ / ____ \| | | | | | | | __/ (__| | | | / /
-- \_\ /_/ \_\_|_| |_| |_|_|\___|\___|_| |_| /_/
-- \_\ /_/ \_\_|_| |_| |_|_|\___|\___|_| |_| /_/
Quantum.Item.Create( "test", {
name = "Test Item",
desc = "This is a test item!",
model = "models/props_phx/gears/bevel12.mdl",
stack = false,
soulbound = true,
equipable = false,
rarity = Quantum.Rarity.Legendary,
usefunction = function() print( "Test!" ) end,
consumefunction = function() print( "Test 2!" ) end,
} )

@ -23,11 +23,12 @@ Quantum.Money = {
}
Quantum.Rarity = {
Trash = { txt = "Trash", color = Color( 100, 100, 100, 100 ) },
Common = { txt = "Common", color = Color( 250, 250, 250, 100 ) },
Rare = { txt = "Rare", color = Color( 48, 163, 230, 100 ) },
Epic = { txt = "Epic", color = Color( 220, 90, 90, 100 ) },
Legendary = { txt = "Legendary", color = Color( 235, 125, 52, 100 ) }
None = { txt = "gnomerd the mvp", color = Color( 0, 0, 0, 120 ) },
Trash = { txt = "Trash", color = Color( 100, 100, 100, 40 ) },
Common = { txt = "Common", color = Color( 250, 250, 250, 40 ) },
Rare = { txt = "Rare", color = Color( 48, 163, 230, 40 ) },
Epic = { txt = "Epic", color = Color( 220, 90, 90, 40 ) },
Legendary = { txt = "Legendary", color = Color( 235, 125, 52, 40 ) }
}
Quantum.Models = {

Loading…
Cancel
Save