View unanswered posts | View active topics It is currently Thu Dec 26, 2024 5:02 pm



Reply to topic  [ 6 posts ] 
 Working with actor inventories 
Author Message
User avatar

Joined: Fri Jun 19, 2009 5:57 pm
Posts: 84
Reply with quote
Post Working with actor inventories
Hello there.

I recently found a Lua function that seems to have gone unnoticed, Actor:Inventory(), or maybe MovableObject:Inventory(), I'm not sure which.

So far, it seems it only returns the next item in the actor's inventory, as a pointer. I haven't found a way to make it return a list or array or anything.

Its use is that in conjunction with SwapNextInventory, like this:
Code:
self:SwapNextInventory(self:Inventory(),true);

you can quickly cycle through the entire inventory of an actor, without cycling through MOs/attachables and the like. Makes searching for pointers to specific carried items rather easy. The only real problem with this is that SwapNextInventory doesn't touch whatever is currently being held. Can any of the local Lua gurus point me to a good way to instantly cycle the actor's currently held item?

And if it so happens that this was already known (though the wiki and my search results hint at the contrary), what else can you suggest for quickly skimming through the actor's inventory to find an instance of a specific weapon/item?


Mon Jul 13, 2009 11:22 pm
Profile
User avatar

Joined: Tue Nov 06, 2007 6:58 am
Posts: 2054
Reply with quote
Post Re: Working with actor inventories
HasObject. Nice find.

Also, just spawn killer particles at the pos of the weapon that is being held.


Tue Jul 14, 2009 12:45 am
Profile
DRL Developer
DRL Developer
User avatar

Joined: Wed Dec 13, 2006 5:27 am
Posts: 3138
Location: A little south and a lot west of Moscow
Reply with quote
Post Re: Working with actor inventories
You can also Detach the weapon, set its Lifetime to 1 or set ToDelete to true, can't you?


Tue Jul 14, 2009 12:46 am
Profile WWW
User avatar

Joined: Fri Jun 19, 2009 5:57 pm
Posts: 84
Reply with quote
Post Re: Working with actor inventories
Heh, no, that's not what I'm looking for. HasObject returns a boolean for whether or no you have the item (not the pointer to it), and deleting or detaching the held item requires that you obtain the pointer to it first. I need either a way to see what's in the hands (preferably a way that doesn't involve scanning all MOs on the scene), or a way to make the actor put its held item into the inventory.

Basically, it's for my SWAT Kats mod, I wanted to have any Glovatrix be usable by any SWAT Kat, but this means I have to get a pointer to a Glovatrix that is carried. Using SwapNextInventory cycles works as long as it's not held, but without so much as a way to just know it's held, I can't prevent a while loop from locking up CC. I also don't know how to see the amount of items in inventory - then I could just cycle through the inventory once, and if the item is not there (but HasObject on it returns true), I can postpone the check.

Btw, I found the function by scanning the executable contents (as in, renaming EXE to TXT and looking through). There were some other things I haven't seen mentioned in the Wiki, like Box functions HasNoArea, IsInside, GetBoxInside, RemoveBoxInside. I don't know what they do yet. There's also an odd INI property WoundLimit, I don't know what it's supposed to do either. Maybe I'll find something useful eventually.. :)

edit: oops, on closer inspection the functions refer to the Area class, not the Box class. Which is still interesting, because the Area class isn't on the Wiki...


Tue Jul 14, 2009 6:20 am
Profile
REAL AMERICAN HERO
User avatar

Joined: Sat Jan 27, 2007 10:25 pm
Posts: 5655
Reply with quote
Post Re: Working with actor inventories
http://www.datarealms.com/wiki/index.ph ... #Functions

Areas are defined within scenes.

Also boxes are pretty well documented, and if you find a function through that that isn't in official documentation then it's probably either A: not working or B: not there for a reason (or of course C: not picked up by data's source crawler)


Tue Jul 14, 2009 6:47 am
Profile
User avatar

Joined: Fri Jun 19, 2009 5:57 pm
Posts: 84
Reply with quote
Post Re: Working with actor inventories
Well, if it's not working or not there for a reason, that's just more incentive to go and find it, right? ;) Because I haven't seen a listing of functions and properties for an Area or a Player, though they are used in scene scripting.


Tue Jul 14, 2009 6:56 am
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 6 posts ] 

Who is online

Users browsing this forum: No registered users


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by STSoftware for PTF.
[ Time : 0.054s | 13 Queries | GZIP : Off ]