Hey folks, I'm finally back to work on a project for Garry's Mod!
Since January of 2008, I've been working on and off on an items and inventory system for Garry's Mod.
Originally started as an inventory system for a competing Stranded gamemode, I found myself working more on the inventory than on anything else!
So I figured I would ditch the Stranded gamemode and make this an all-purpose inventory system for everybody to use.
I did not intend for this system to be used just for RP - it can be used for any gamemode! I could imagine this system being used for batteries that power things or air tanks in Spacebuild, I could imagine money, guns, and trash disposal in RP, food and resources like rock and wood in Stranded, armor, components in things like cars, who knows!
Since then, the project has gone through many radical changes, both code-wise and in appearance.
Features:
[list]
[*] I have gone to great lengths to ensure this system does not lag. This system is extremely well optimized network wise and will not lag your game.
[*] Items:
[list]
[*] Exist both serverside AND clientside!
[*] Can be placed into the world like a SENT
[*] Can be held like an SWEP
[*] Can be placed into an inventory (which considerably cuts down on lag, by the way)
[*] Can be placed in the "void", which basically means it exists but is no-where
[*] Can be "stacked" (like money, for example). Split and Merge exist so you can split or merge piles of items. Additionally you can choose when splits/merges are allowed (merges can occur when two stacks of items touch in the world, or when one stack enters an inventory containing another stack of the same type of items for example)
[*] Right click menus! If you right click an item in the world (by holding c to bring up the cursor) or by right clicking an item slot, you can take a look at the item's menu. You get to decide what shows up in this menu with clientside events.
[*] Items have health, and can be damaged, repaired, destroyed, etc
[*] Have properties like size and weight built in that are useful with inventories
[*] Wiremod support! You [b]don't[/b] have to have Wiremod, but if you do, items can set up inputs and outputs like regular wiremod stuff.
[*] Support inheritance - You can easily create items based off of other items
[*] Can be extended - you can create extensions that add onto existing items (such as adding "cost" to all items) without messing with the item itself!
[*] Have a Networked Vars system similar to entities
[*] Have Networked Commands that let the client and server send instructions back and forth
[*] Item can be dragged on screen to other slots or to world
[*] There are several drag-drop hooks such as: OnDragToInventory, OnDragDropToWorld, OnDragDropHere, OnDragDropToItem
[*] Events/hooks for SENTs, SWEPs, and items all under one roof.
[*] You can do your own drawing if you want; Hooks like OnDraw3D and OnDraw2D let your items decide what shows up when you're looking at them in an inventory
[/list]
[*] Inventories:
[list]
[*] Like the items, they exist both serverside and clientside.
[*] Weight caps (optional): so a paper bag can or can't hold 500000kg of rocks for example
[*] Size limits (optional): so a cargo container can or can't be put into a shoebox
[*] Max number of slots (optional): so you can or can't have 2000 items in a single inventory
[*] A single item or entity can contain several inventories
[*] An inventory can be shared between more than one item (so you could have two bags that share an inventory)
[*] 'Private' inventories: Since items exist serverside and clientside, private inventories can be used to hide items from everybody except the owner of a private inventory (so one player can't see what another player has in his inventory, for example).
[*] Events/hooks that let you do things like decide what you let into (or out of) that inventory
[/list]
[*]Debug module for developers
[list]
[*] Adds a debug menu to Itemforge
[*] Lets you watch network chatter related to Itemforge in your console
[*] You can compare information on the server and your client to find possible problems
[*] You can look at all loaded item-types serverside and clientside
[*] You can look at all created items and inventories serverside & clientside
[/list]
[/list]
Video:
Locking a footlocker with a password lock:
[media]http://www.youtube.com/watch?v=zWkgHtxN7-I[/media]
Here are some screenshots of my work so far:
Older screenshot. Some items inside of a box, and the console showing Itemforge's network chatter:
[img]http://img165.imageshack.us/img165/140/rpcscdesert0010mn6.jpg[/img]
Holding a base_ranged item. Notice the slot in the upper-left, the icon can be dragged somewhere or right clicked while holding the [b]c[/b] key.
[img]http://img88.imageshack.us/img88/6696/rpcscdesert0012sd1.jpg[/img]
Attaching a password lock to a door:
[img]http://img259.imageshack.us/img259/6428/rptbcity45v02n0000mi5.jpg[/img]
Taking a look at it's right click menu:
[img]http://img259.imageshack.us/img259/9809/rptbcity45v02n0001hl6.jpg[/img]
Entering a password into the password lock:
[img]http://img88.imageshack.us/img88/7978/lockscreenhi7.png[/img]
Drag-Dropping an item magnet to a different slot (note: you can also dragdrop from one slot to another like shown here, or drag the item to the screen to drop it somewhere in the world):
[img]http://img128.imageshack.us/img128/9091/dragdropph8.png[/img]
Showing several things here: Inventory has a size limit (shown by the watermelon icon; "this inventory can take things the size of a watermelon or smaller"), a weight cap, and a set number of slots (notice only 8 slots are open). Additionally, it shows that items can be stacked, like the money was:
[IMG]http://img403.imageshack.us/img403/2552/invextendrn7.png[/IMG]
This screenshot is a bit older. This is the debug menu, showing a list of all items. It's noticed a few problems (shown in green). [s]erver values are different from some values on my [c]lient. There are also some items that only exist on my client (shown in yellow), and an item that exists on the server but not on my client (because it's in a Bot's private inventory):
[img]http://img162.imageshack.us/img162/8716/rpc170310020tq8.jpg[/img]
The debug menu, item-types listed here. Everything is red, meaning it's shared and in-sync (good thing).
[img]http://img118.imageshack.us/img118/6279/rptbcity45v020002hk5.jpg[/img]
To demonstrate how far this system has come, here's how it looked like when it was in the Stranded gamemode:
[img]http://img514.imageshack.us/img514/9779/gmflatgrass0035qi2.jpg[/img]
[img]http://img516.imageshack.us/img516/6205/gmflatgrass0033yy2.jpg[/img]
Here's what a sample item looks like:
[lua]
--[[
weapon_crowbar
SHARED
Bashes people. Opens doors.
]]--
if SERVER then AddCSLuaFile("shared.lua") end
ITEM.Name="Crowbar";
ITEM.Description="A long, fairly heavy iron rod with teeth.\nGood for prying open doors or pulverising skulls.";
ITEM.Base="base_melee";
ITEM.Spawnable=true;
ITEM.AdminSpawnable=true;
--Overridden Base Weapon stuff
ITEM.PrimaryDelay=.4;
--Overridden Base Melee stuff
ITEM.HitRange=75;
ITEM.HitForce=5;
ITEM.HitDamage=25;
ITEM.ViewKickMin=Angle(1.0,-2.0,0);
ITEM.ViewKickMax=Angle(2.0,-1.0,0);
--Crowbar
ITEM.ForceOpenSound=Sound("doors/vent_open2.wav");
ITEM.ImpactSounds={
Sound("weapons/crowbar/crowbar_impact1.wav"),
Sound("weapons/crowbar/crowbar_impact2.wav"),
};
function ITEM:OnUse(pl)
if self["base_melee"].OnUse(self,pl) then return true end
--We'll try to find a door to open
local tr={};
tr.start=pl:GetShootPos();
tr.endpos=tr.start+(pl:GetAimVector()*self:GetHitRange());
tr.filter=pl;
tr.mask=MASK_SHOT;
local traceRes=util.TraceLine(tr);
return self:OpenDoor(traceRes.Entity);
end
function ITEM:OnHit(pOwner,hitent,hitpos,traceRes)
return self:OpenDoor(hitent);
end
function ITEM:OpenDoor(door)
if !door || !door:IsValid() || door:GetClass()!="prop_door_rotating" then return false end
--Clientside we can't actually open doors, so we jus
Sweet! Thanks for letting me test this with you!
cheers m8
And I was there! :D
Holy analsex. Is this mainly for RP or is it general use?
He said general use.
Wow, this looks very nice
Nice work. Nice inventory VGUI skin.
Sexy
Jawsome.
Can we make handheld wire devices now?
Wow that is truly amazing. Great work.
[QUOTE=DieHardDeus;13304533]Jawsome.
Can we make handheld wire devices now?[/QUOTE]
Currently wire only works while items are in the world, but I could try to work that in for you.
[QUOTE=theJ89;13305329]Currently wire only works while items are in the world, but I could try to work that in for you.[/QUOTE]
I just had a brain orgasm.
So could I build a Game Boy and carry it with me? Or a cellphone?
Sextacular.
[QUOTE=DieHardDeus;13305912]I just had a brain orgasm.
So could I build a Game Boy and carry it with me? Or a cellphone?
Sextacular.[/QUOTE]
The best way for this to be done is for somebody to script items that do this outside of the game (a gameboy item and a cellphone item).
But if I'm understanding you correctly, you're talking about wiring together a contraption and putting it in an inventory or something. I hadn't planned for contraptions to be in inventories as a single item, but that's an interesting idea; I bet you how that could be done is by doing something similar to what the Stargate's Mod's wraith harvester does, except creating an item to represent it, and then putting it back when it enters the world. I could probably rig it up so a contraption could be carried around like an item, but I can't make it so you could wire together something like a laser pistol and then hold it like a weapon. It's beyond my ability.
When I say items have wire support, I mean that they can have wire inputs and outputs on them (think about the different wire stuff like monitors, lights, pod controllers, etc). If you really wanted to you could turn all of those different entities into items that could be picked up (so if you wanted to make a gamemode where you had to make or find these parts that could be done).
As far as wired stuff, an example of what I could do would be... lets say you have a button item wired up to an explosive. You could grab the button item, then whenever you "attack" with it, it presses the button and causes the explosives to go off.
The input/output stuff with wire is easy enough, but the pain in the ass to do are the effects like the visible wires.
[QUOTE=theJ89;13306520]The best way for this to be done is for somebody to script items that do this outside of the game (a gameboy item and a cellphone item).[/QUOTE]
I think he is asking if he could hold something like a GPU from wiremod. It has all of it's coding internally and has a screen, you'd just have to make sure that when it is being held it has the screen facing towards the player and it could work.
[QUOTE=ZeikJT;13306566]I think he is asking if he could hold something like a GPU from wiremod. It has all of it's coding internally and has a screen, you'd just have to make sure that when it is being held it has the screen facing towards the player and it could work.[/QUOTE]
I've never used a wiremod GPU, but this sounds possible from your description.
This is really quite awesome. Can't wait for release. Keep up the great work!
So...awesome!
Waffles from the wafflegun should have an entry in this when it comes out... then we can collect waffles and box em up and sell em.
This looks awesome, nice job.
Very nice, wanted to do this myself at some point but you have done a better job than I ever will.
This sure sounds amazing. Can't wait to test it someday! :D
Would this also make Spacebuild systems in boxes a reality? I mean, could you put generators and storage in and make them autolink?
Totaly awsome :O
Been thinking about something similar for a while but never got around to do it as I suck at LUA :P
Good work.
Fuck yeah awesomeness !
Damn thats hawt.
I WANT IT NOW! Make this already :P
[QUOTE=LimEJET;13312538]Would this also make Spacebuild systems in boxes a reality? I mean, could you put generators and storage in and make them autolink?[/QUOTE]
That's a possibility. Somebody would have to code the generators/storage tanks and do the code to make them autolink, and then make the container they're in offer resources (for example if you had three air tank items inside of a box, then the box offers all of the air the air tanks have), but that's very possible.
I don't think i completely understand it, but it looks freakin awesome!
I popped by your server when you were testing this, but you were AFK. It's nice.
Sorry, you need to Log In to post a reply to this thread.