Wow, this is alot better than all those "Simple RP Inventory Script WIP". I hope it gets finished soon.
[QUOTE=neo_kira;22550470][code]
addons\items\lua\entities\itemforge_item\shared.lua:79: Attempt to compare number with nil
[/code]
any help ?
Addons PHX svn;Wire svn ;Wire extras svn;Wire modelpacks svn;ItemsForge v19 svn
Edit :
oh forgot it happens when i try to spawn entites from itemforge debug[/QUOTE]
Update the file.
[quote]ItemsForge v19 svn[/quote]
Now v20
The buttons look like a reference to stranded from Unreal Software am i right?
[QUOTE=Jazz84;22695243]The buttons look like a reference to stranded from Unreal Software am i right?[/QUOTE]
Yep. The system was originally designed with Stranded in mind, I just haven't got around to replacing them yet.
Beta SVN updated (twice).
[b]Potential Script Breakers:[/b]
For melee weapons, the OnHit event has been changed.
First, OnHit's arguments have changed from
[lua]function ITEM:OnHit(pOwner,hitent,hitpos,traceRes)[/lua]
to
[lua]function ITEM:OnHit(vShootPos,vAim,traceRes,bIndirectHit)[/lua]
So make sure to go through and change the arguments, and fix up references to them in your code as necessary:
* Instead of pOwner use self:GetWOwner()
* Instead of hitent use traceRes.Entity
* Instead of hitpos use traceRes.HitPos
Second, Instead of having OnHit handle special hits, now it handles all hits.
If your melee weapon uses OnHit, then anywhere your code returns false, i.e.:
[lua]return false;[/lua]
It should do this instead:
[lua]
self:InheritedEvent("OnHit","base_melee",vShootPos,vAim,traceRes,bIndirectHit)[/lua]
While this is a little more complicated it lets you be a lot more versatile with your weapons.
[b]New stuff:[/b]
[b]The combat knife cuts ropes[/b]. What's even cooler is, if you have a loose rope (not attached to props/world) you can pick them up as items, and use them somewhere else!
There's one restriction when it comes to cutting the ropes: They have to be taut (No slack in the rope! [b]Pull the two ends as far apart as you can[/b]).
I really wish I could do better than this but the fact is I have no way of knowing where the rope segments are at, EXCEPT when the rope is tight because then it's more or less a straight line. If ropes aren't cutting it's usually because it's not tight enough. This should be pretty good for most things though - cutting ropes things are hanging from, cutting ropes that are holding back traps, etc. I plan to expand on this rope-cutting functionality later and make the sawblade cut ropes when you throw them
Melee weapons now have an OnMiss event that handles what happens on a miss.
Melee weapons now have an IsValidHit event that you can return false in to force a miss to occur (i.e. you could make it so if the player swings at another player, then it's an automatic miss).
You can set the type of inventory players have now with IF.PlayerInv:SetType(strType). If strType is nil it just uses the base inventory like it does now.
All world items and held items are recorded in a table now, so you can look up all items in the world and all held items by doing IF.Items:GetWorld() and IF.Items:GetHeld().
You can set the properties of the rope created by an item_rope by doing rope:SetRopeProperties(iLength,fDiameter,strMaterial,fStrength,bRigid). Or you can set the width (diameter) of the rope by itself by doing rope:SetWidth(fDiamter). Setting the width of the rope either way changes the item size and item weight of the rope automatically.
[b]Other Changes:[/b]
IF.Version is 0.21 now
You can now specify "metal", "wood", or "glass" for ITEM.GibEffect.
The latern breaks with glass gibs, the footlocker and axe break with wood gibs, and the item magnet, trashcan, colt python (.357 revolver), pulse rifle (ar2), combine sniper, crossbow, crowbar, flechette gun, combat knife, sawblade, rock-it, RPG, shotgun, smg, and stunstick break with metal gibs.
MetalGibs effect was renamed to BasicGibs effect and now handles wood, glass, and metal. The effect now plays a random sound appropriate for each type of gib. Gibs won't intersect the world as often since I wrote some code that improves their placement.
The gib code uses a lookup table now so it's faster than before.
The code that creates network vars uses a lookup table now too.
The rope's dynamic description now gives the correct length of the rope in meters/centimeters (I was using an incorrect unit conversion before). It's also nicer to look at because the lengths are only accurate to the lowest centimeter now. Besides that, it's grammatically correct in the case it's only 1 meter long. Likewise the rope's weight is now set realistically based off of it's density (from my web research).
Gear Attachments are now hidden until shown.
item:SetWeight and item:SetSize were updated so that they fail with an error message if you try to set an item's weight/size to a negative value.
NOTE: It's worth mentioning that I plan to allow negative weights for items so things like Stranded II's butterflies are possible (which actually decrease the total weight in an inventory).
A bug was fixed where you couldn't insert a zero-weight object into an inventory that was already at it's weight limit (yes, zero weight objects are possible).
A bug with item:Hold was fixed where if the player was already holding an item, he could be told to hold it again (which would make him lose the weapon and gain it again).
A bug where stuff in the .svn folder would be included in client downloads was fixed.
Ammo finding is now more efficient thanks to IF.Item:GetWorld
Minor code changes to base ranged weapon's code to make it more organized.. although I think I may have reintroduced an old bug here, which I'll look into later.
Base ranged weapon's Load and GetWaterLevel functions were made slightly more efficient.
A couple of unnecessary debug printouts were removed from the footlocker.
An unnecessary debug printout was removed from the inventory code.
MegaDeath409 added to impromptu credits.
Other miscellaneous commenting updates to files.
[b]Status Update:[/b]
The debug module was modified. Get rid of your old one and replace it with the new one.
Beta SVN updated.
This update makes Itemforge faster by caching Item Types, provides support for calling events in the nearest base class (with :BaseEvent(), similar to how people do self.BaseClass.Event(self,arg,arg)), and most importantly provides support for reloading item types (which is sort of rough at the moment, but I've tested it with itemtypes in garrysmod/lua/itemforge/items/ and it works fine).
[b]Notes about bugs[/b]:
* Due to a bug in garrysmod file.FindInLua doesn't work on files in a gamemode's content/lua/ folder. This is effectively stopping Itemforge from recognizing items in the gamemode folder. I've asked garry to take care of this in [url=http://www.facepunch.com/showpost.php?p=23813796&postcount=327]this thread[/url], but if he doesn't fix it I can probably hack around this in a later update.
* Another bug, Item Type Reloads don't work if your items are in addons/. I've also reported this bug [url=http://www.facepunch.com/showthread.php?p=23743728#post23743728]here[/url].
[b]Potential Script Breakers[/b]:
* You should use self:BaseEvent("NameOfEvent") and self:InheritedEvent("NameOfEvent","NameOfBaseClass") to call an event on a base class.
* You should use self:Event("NameOfEvent") to call a custom event you make.
* Base Melee Weapon:
* HitSound(traceRes) - > HitSound(vShootPos,vAim,traceRes,bIndirectHit)
* MissSound(traceRes) - > MissSound(vShootPos,vAim,traceRes)
[b]New Things[/b]:
* Footlocker has an OnDetachLock(lock item) event
* Base melee weapon has new HitAnim(vShootPos,vAim,traceRes) and MissAnim(vShootPos,vAim,traceRes) events
* You can call item:PlayerSendToInventory(LocalPlayer(),inv,slot) clientside now to make the local player put the item into an inventory (slot is optional)
* There's a new clientside function called item:PoseUprightRotate(eEntity,speed) that can be called inside of :OnPose3D to pose an entity rotating upright (model's z axis facing upward) at the given speed
* Locks can be detached from items now, and they can't be detached if the lock is engaged
* New Util module for doing things like checking arguments, converting between units of weight and distance, and transferring files from server to client (for the item type reloading). Contains a task queue class (TaskQueue) so doing several delayed operations in a row (like transferring several files) is possible.
* Sawblade's primary and secondary are delayed after throwing in either mode now (wasn't when throwing secondary)
[b]Changes[/b]:
* Itemforge is version 0.22 now
* Cached ItemTypes for faster startups and lookups (thanks MegaDeath409)
* Rope ends don't collide with players/NPCs now (thanks CapsAdmin)
* Locks don't stop doors from opening any more (thanks CapsAdmin)
* Footlockers can be opened and closed without a lock. Locks stop the footlocker from being opened/closed (so you can lock a footlocker open or lock it closed).
* Footlockers now weigh 15.5 kg (used to be 1 kg)
* Footlocker has a slightly different description
* Footlockers are posed correctly in item slots now
* Container's "Check Inventory" menu option changed to "Check Contents"
* Rope now reports it's length correctly
* If you use the crowbar while you have it out (by right clicking it's icon and choosing Use) it swings it, just like a normal attack.
* Rock-It Launcher was broke, should be good now
* Rock-It Launcher has it's own inventory class now along with max weight, max size, etc
* Doing tostring() on an item no longer tells you how many items there are in the stack (this was causing problems when errors were generated)
* OnEnterWorld debug message removed
* OnHold "out when held" debug message removed
* More compact module loader (itemforge/shared.lua)
* Lots of miscellaneous changes to items to conform with new way of calling events
* A lot of hash tables added for speedier lookups
* Impromptu credits updated
Next up, networking update. As always tell me if you find any bugs.
Edit:
I'm fairly sure nobody is developing with the beta so in future updates I'll try to skip the drawn out update logs
I'm interested in messing with this.
Want to add me? I may have questions.
The SVN Checkout stops downloading after a while... It wont download.
EDIT1:Frozen in Materials/jaanus x:
[editline]04:42PM[/editline]
How does this work? Doesn't have entities or anything... Nor tools.... HELP? ):
[QUOTE=santiainen;24085509]The SVN Checkout stops downloading after a while... It wont download.
EDIT1:Frozen in Materials/jaanus x:
[editline]04:42PM[/editline]
How does this work? Doesn't have entities or anything... Nor tools.... HELP? ):[/QUOTE]
This is kind of a developer release, if you dont understand how to open it you shouldent download stuff from the Lua section, look in releases, most there is non-developer stuff
Nice post...Thank you very much!!......
I find myself drooling more and more over the possibilities this mod holds, but I feel sad because I can't do a thing with it, damned shitty Lua skills.
Any templates people could work off of?
Sorry I haven't posted for a while. I figured I should at least make a post so the thread doesn't get archived.
Hopefully I can get some more work done on this over the summer. School, as always, has been very time consuming... I also have a game engine that I am working on, which has been taking up some of my time. I've learned a lot from both experiences, however, and with any luck these skills should transfer over to Itemforge.
I still feels like there isn't much that needs to be done. Classes/inheritence are optimized about as much as I can optimize them in Lua at this point, items are based in the class system, I have bases for melee weapons and different varieties of ranged weapons, etc. I understand this can all be kind of confusing, though, so one of the things I need to work on is making Itemforge easier for developers to work with (whether that's with templates like Killer_Steel recommended, or with documentation, better debugging tools, etc)
One of the biggest things that is bugging me at the moment is the large amount of legacy code in Itemforge. This is code that has been around since the project was conceived several years ago, but now in hindsight I realize was poorly designed and is now causing issues.
Namely, the inventories have been a point of soreness for a long time now; they're always breaking and have been neglected for a while now. Networking and prediction have also been irritating, due mostly to the nature of usermessages, which Itemforge's networking system uses to sync the properties of items. I'll try to tackle those as best I can.
Whenever I get those two out of the way, I'll try get the saving of items/inventories working - this is something that has been requested for a long time, but I just have not got around to (with good reason - the underlying systems, namely networking and the class system, needed to be stable so I could design an appropriate format and save/load routines for them).
After that, I'll be working on the combination system, so you can make recipes for the items; after that, I think I'll make the final release.
When I first found this yesterday, I downloaded it and started up singleplayer and was immediately lost. Today, I've finished reading through the entire thread, and now I'm about ready to figure out how to use it.
This basically is what I was ready to try and make myself for my gamemode. I am brand new to Lua, though, so I wouldn't have gotten anywhere near as far as you have.
What you have here provides a framework that I think I can learn and work with. Pretty interesting that you come back and post months later just as I find it and decide to use it.
I do look forward to the saving system, and the final release, but for now I'm going to play with it and see what I can do/learn. Thanks!
EDIT: I'd like to know how to actually integrate this into a gamemode. Like, for example, how do I set up the files and such so that I could hand someone a .zip file with everything they need to test the gamemode, without installing addons and such that they don't want/need in Sandbox? And is it possible to place the entities from Itemforge into a map in Hammer and have them work correctly? Anyone with experience in these matters, I'd appreciate the help.
[QUOTE=Rayne Mercury;29407317]
EDIT: I'd like to know how to actually integrate this into a gamemode. Like, for example, how do I set up the files and such so that I could hand someone a .zip file with everything they need to test the gamemode, without installing addons and such that they don't want/need in Sandbox? And is it possible to place the entities from Itemforge into a map in Hammer and have them work correctly? Anyone with experience in these matters, I'd appreciate the help.[/QUOTE]
Currently the only way is with a separate addon. I have thought about this issue before, though.
I think what I'll end up doing is making two seperate packages - one meant for integration into a gamemode, and another meant as a standalone addon. If two versions of Itemforge are present (e.g. a client with the Itemforge addon installed, playing on a server using a gamemode with Itemforge), then I'll make the gamemode's version of Itemforge take precedence, even if the gamemode is using an older version.
Until then, if memory serves Itemforge itself is almost entirely contained within the lua/ folder. You could try just dropping it in your gamemode's lua/ folder first and see if that works; I've never tried it before.
Well, Itemforge also has materials, models, and sounds folders. Maybe if I just merge the whole thing? I tried playing my gamemode with Itemforge installed as an addon, I could open the inventory and debug menus, but anything I spawned would just disappear on pickup.
New EDIT: I got rid of all my crappy code and started fresh with Itemforge. So far, so good. Now I have a few questions.
How can I check all inventories connected to a player, as well as things nearby, in the same way that weapons reload? I want to have the game check that the player has a hammer and a nail before they can use the weld tool, for example, and then remove one of the nails once the action is complete. I know how to interrupt usage of the tool.
I have a feeling I can figure this out by looking at how weapons reload, but I'm currently not at home and don't have access to the code. If no one has answered this by the time I get home in five hours, I'll experiment with it.
More as I think of more questions...
The item:FindAmmo(fCallback) function does exactly that. It returns a nearby item approved by fCallback.
It's defined for base_ranged weapons (since up until now only ranged weapons have required that kind of functionality).
I was considering making it more general so it could locate anything nearby. But right now, it's stored in base_ranged.
What does "nearby" mean?
By default:
Items in the same inventory as this item (e.g. if you have a gun and ammo in the same crate, and you reload the gun while it's in the crate, it reloads with ammo from the crate)
If the weapon is being held, "nearby" items are items in the player's weapon menu, or items in the player's inventory, an item dropped in the world that the player is looking directly at, or an item physically close (at most 64 units away from) the player
If the weapon is dropped in the world, then items in the world that are physically close (at most 64 units away from) the weapon.
Basically, the way FindAmmo works is by running the given "callback" function on every nearby item it can find.
This callback function should either approve (by returning true) or disapprove (by returning false) the item, based on whether or not you want to use that ammo.
The callback function should have two params. The first, self, is the item that we're trying to find ammo for (this would be the hammer in your case),
and "ammo", which can be any nearby item.
For example, this function will return true if the ammo is an item of type "nails"
[lua]
local function callback(self,ammo)
return ammo:GetType() == "nails";
end
[/lua]
Then, to find any nearby nails you can do
[lua]
local nailItem = item:FindAmmo(fCallback)
[/lua]
And if nailItem is nil, that means that FindAmmo couldn't find any nearby items that passed fCallback.
Any changes needed in order for it to be used in another way? Sorry, I'm on my way home now, then I'll be more useful.
Yeah, if your hammer isn't based off of a ranged weapon, you'll have to copy/paste a little bit of code from the base_ranged/findammo.lua into your item type.
Later, I'll make it so any item can use this function without having to copy/paste a copy into your items.
In a shared file in your hammer's item type (e.g. shared.lua) just make sure you have
[lua]
ITEM.AmmoMaxRange = 64;
function ITEM:FindAmmo(fCallback)
local l=list.Get("Itemforge_BaseRanged_FindAmmo");
for k,v in pairs(l) do
local s,r=pcall(v,self,fCallback);
if !s then self:Error("While finding ammo, A function in the \"Itemforge_BaseRanged_FindAmmo\" list encountered a problem: "..r);
elseif r then return r end
end
return nil;
end
[/lua]
That should be all you need.
Okay, now, the way I would go about this is, in the hook that allows/disallows the weld tool, have it search all the items held as weapons,
looking for a hammer held by that player. If it doesn't find a hammer, don't allow the weld.
If it finds a hammer, have it do hammer:FindAmmo(callback), where callback is looking for nails. This will locate nails nearby the hammer.
If it finds the nails, subtract the # of nails by 1 and allow the weld to take place.
[lua]
local hammer;
for k,v in pairs( IF.Items:GetHeld() ) do
if v:GetType() == "hammer" && v:IsHeld( pl ) then
hammer = v;
break;
end
end
if hammer = nil then
return false --don't allow weld
end
local function callback(self,ammo)
return ammo:GetType() == "nails";
end
local nails = hammer:FindAmmo(callback);
if nails = nil then
return false --don't allow weld
end
--found hammer, found nails, lets subtract 1.
nails:SubAmount(1);
return true
[/lua]
Thanks! Trying to think of something else I wanted to ask... I'm about to get on the computer and get to work.
EDIT: Ooh! Ooh! New question! Is it possible with Itemforge to limit the amount of items a player can "hold" (that is, items in the traditional HL2 weapon slots, not the player's IF inventory)? Like, my old system restricted the player to one melee weapon, one large gun, and one small gun. I additionally planned to add more slots, but with Itemforge it seems I can almost do a full RPG-like equipment setup with slots around the body that can equip various items. I remember reading about this in the thread. Is it possible/easy to do this now? Also, what is the whole "gear" deal with items sticking to the player's model, does it work, and how can I implement it?
EDIT2: Would you rather I just make a new post instead of editing my latest? It seems rude to double-post, but it also seems annoying for me to continue doing this...
Anyway, with that stuff you showed me about using the hammer, I guess it'd be pretty simple to make the hammer's durability fall with each use, until it breaks? I'm about to poke through the code and figure out how to do this myself. It's possible, right, to do it without having it equipped or even held (HL2 slot)?
In the past I had "IF.Items:SetMaxHeld" to set the maximum number of items that could be held in the weapon menu, but to fix the weapon prediction issues, I had to change how that worked (before, I had 1 SWEP that could load any item, and had several copies of that SWEP to allow multiple items to be held as weapons. now the system creates a single SWEP for each itemtype). At the moment you can hold only 1 item of each type (e.g. you can hold a crowbar, a knife, a sawblade, but not two crowbars for instance), but there's no restriction on how many items can be in your menu.
Because of technicalities of the fix I mentioned earlier, I haven't bothered putting the "max # of items that can be held" thing back in, but I can do this later.
The "gear" stuff is a little glitchy (sometimes it disappears or stops moving), but basically what it does is allow you to attach models to things clientside. I use this on almost every item, allowing you to move the world model of the item you're holding to any location on the player's body. The lantern, for instance, is in your hand while you have it out, but moves to your hip when you have a different weapon out.
Most items have a single piece of gear associated with them (the world model), but it's possible to have more gear (e.g. a backpack and the gun for a flamethrower).
Gear can be used outside of items as well. The stuff pertaining to gear is in it's own module (IF.Gear if I recall, itemforge/client/gear.lua).
EDIT:
Yeah, you can give the hammer a max health, and then every time it gets used, take off a little bit of health with item:Hurt(amt). The item automatically breaks when all of it's health is depleted.
Ah. That's stuff for later, then, I suppose. Right now I'm having issues getting the gamemode to load and use Itemforge. I merged the folders as best I could, and removed the addon to make sure the gamemode was doing it, and nothing loads, Itemforge isn't recognized at all. I'm poking around trying to figure out where things are supposed to go, but I really don't know.
EDIT: Maybe... Maybe Itemforge's init, cl_init, and shared need to be combined with the gamemode's same files? Er, copied out of their files and placed into the gamemode's somewhere?
The autorun probably isn't activating, for whatever reason.
Try including itemforge's init.lua in your gamemode's init.lua, and itemforge's cl_init.lua in your gamemode's cl_init.lua.
Hmm, looking at one of my gamemode folders, it looks like:
"entities" folder goes in gamemodes/NAME_OF_YOUR_GAMEMODE/entities/
"weapons" folder goes in gamemodes/NAME_OF_YOUR_GAMEMODE/entities/
"effects" folder goes in gamemodes/NAME_OF_YOUR_GAMEMODE/entities/
everything else in the lua/ folder goes in gamemodes/NAME_OF_YOUR_GAMEMODE/content/lua/
Tried it to the best of my knowledge. Got these:
Couldn't include file 'itemforge\shared.lua' (File not found)
(@gamemodes\survivors\gamemode\itemforge\cl_init.lua (line 7))
[gamemodes\survivors\gamemode\itemforge\cl_init.lua:10] attempt to index global 'IF' (a nil value)
Is the itemforge folder in the wrong place?
EDIT: There is not a space in cl_init.lua. It doesn't show up in edit mode, only the post itself.
EDIT2: Also got the same error with itemforge\init.lua on another line in the console.
[QUOTE=Rayne Mercury;29431185]Tried it to the best of my knowledge. Got these:
Couldn't include file 'itemforge\shared.lua' (File not found)
(@gamemodes\survivors\gamemode\itemforge\cl_init.lua (line 7))
[gamemodes\survivors\gamemode\itemforge\cl_init.lua:10] attempt to index global 'IF' (a nil value)
Is the itemforge folder in the wrong place?
EDIT: There is not a space in cl_init.lua. It doesn't show up in edit mode, only the post itself.
EDIT2: Also got the same error with itemforge\init.lua on another line in the console.[/QUOTE]
my guess is, instead of being in the gamemode/ folder, it needs to be in the content/lua/ folder
That makes sense, even though I wouldn't have considered it because I've never seen a lua folder in any gamemode's content folder. I'll try it.
[editline]25th April 2011[/editline]
No worky. Can I just wait until you've figured out how to integrate it into a gamemode? I can just use it as an addon until then. Any idea how well it'll work if I just have it installed on a server as an addon, and someone joins who doesn't have it?
Er, I guess this is a basic server settings question, but still, I don't know the answer... Never run a sandbox server.
Nice to see this thread again. I remember testing this with you almost 2 years ago.
As long as Itemforge is an addon on your server, your clients shouldn't have to install anything. I will try to figure out what needs to be done to port it to a gamemode later though.
Will u stop trying make MMORPG in gmod??!
[QUOTE=Russian;29441676]Will u stop trying make MMORPG in gmod??![/QUOTE]
Why not, what's wrong with that? Don't join his server then... no ones forcing you.
I explained this to someone last night, you must have been there to bring this up, Russian. It's just more like an MMORPG than a round-based zombie DM gamemode.
theJ89, when I get home today, I'm going to finish up the basics of the gamemode, and maybe get my server up. It'll be quite barebones and pointless, but if you dropped in to check it out, that'd be cool.
Sorry, you need to Log In to post a reply to this thread.