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



Reply to topic  [ 19 posts ]  Go to page 1, 2  Next
 Inventory things 
Author Message
Data Realms Elite
Data Realms Elite
User avatar

Joined: Fri Jan 07, 2011 8:01 am
Posts: 6211
Location: In your office, earning your salary.
Reply with quote
Post Inventory things
I've got an ACRocket, and I want to know how to access it's inventory.

You know, checking which actor it has inside and deleting it.
The only functions I know for inventory are the ones for adding items, check if it has a certain item, changing to the next one and dropping it, but nothing else.


Mon Nov 28, 2011 3:12 am
Profile
User avatar

Joined: Wed Feb 17, 2010 12:07 am
Posts: 1545
Location: That small peaceful place called Hell.
Reply with quote
Post Re: Inventory things
You could try going through all Actors and Items to see the ship has them.

I don't know if that's very efficient though.


Mon Nov 28, 2011 5:03 am
Profile
Data Realms Elite
Data Realms Elite
User avatar

Joined: Fri Jan 07, 2011 8:01 am
Posts: 6211
Location: In your office, earning your salary.
Reply with quote
Post Re: Inventory things
You mean checking every actor in the game and see if it is in the ship's inventory?

I'd run that chunk only in the create function, so I don't think it would lag much, but would it work properly?
And how would that look in a code?


Mon Nov 28, 2011 5:21 am
Profile
User avatar

Joined: Wed Feb 17, 2010 12:07 am
Posts: 1545
Location: That small peaceful place called Hell.
Reply with quote
Post Re: Inventory things
Well you'd only have to check it once for every passenger and add him to a list, and if he leaves the ship then remove him from the list.

I'm not sure if I'm right, But the RootID of the passenger would be the ship's ID. I don't know if that's true or not but if it is then it would make things easier.

I'd show an example, but I haven't touched lua for a while now.


Mon Nov 28, 2011 6:04 am
Profile
User avatar

Joined: Tue Jun 12, 2007 11:52 pm
Posts: 13144
Location: Here
Reply with quote
Post Re: Inventory things
MOs need to exist in the "real world" at least once before they actually get an ID, so trying to run an ID check on inventory items usually don't work.

There's a function that returns the current object in an actor's inventory (not including the currently held item), and another that switches through inventory items, so you can use that to check all of the items in an actor's inventory.

The method is prone to bugs though, since you can't tell how many times to switch through items since you don't know how many items are in the inventory, but I believe I managed to get around that by adding an item with a unique PresetName (like "Inventory switcher rock") before switching through items, and when I land on the added item, stop switching and remove it.

I don't remember what the names of the functions were, but I'll look for them later and post back if no one else beats me to it.


Mon Nov 28, 2011 3:51 pm
Profile
Data Realms Elite
Data Realms Elite
User avatar

Joined: Fri Jan 07, 2011 8:01 am
Posts: 6211
Location: In your office, earning your salary.
Reply with quote
Post Re: Inventory things
Oh great, thanks CC.

EDIT:

Wait, I should explain more what I want to do.

I've got a craft, an ACRocket, that doesn't have doors. What I want to do is that when I buy it with an actor inside, I want to get the actor out with everything I bought without needing the doors at all.


Mon Nov 28, 2011 7:19 pm
Profile
Data Realms Elite
Data Realms Elite
User avatar

Joined: Tue May 25, 2010 8:27 pm
Posts: 4521
Location: Constant motion
Reply with quote
Post Re: Inventory things
I had a look at the old Coming of God mod by TLB I found lying around, and the way he did it was by instagibbing the craft, then with the particle he created subsequently found the closest actor and storing it.

I appreciate you don't want to be spawning craft on top of your cargo, but if you used a filler particle between the original craft and the actual craft you could work from there.


Mon Nov 28, 2011 8:28 pm
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: Inventory things
Admittedly, that's a pretty terrible and slapdash way of doing it, so I wouldn't suggest it. It only works well for one actor, and has a tendency to lose their weapons.


Mon Nov 28, 2011 8:39 pm
Profile WWW
Data Realms Elite
Data Realms Elite
User avatar

Joined: Fri Jan 07, 2011 8:01 am
Posts: 6211
Location: In your office, earning your salary.
Reply with quote
Post Re: Inventory things
Roast, we are in B26, there must be a simpler way to do it.

If not, I might do that.


Mon Nov 28, 2011 8:41 pm
Profile
Data Realms Elite
Data Realms Elite
User avatar

Joined: Tue May 25, 2010 8:27 pm
Posts: 4521
Location: Constant motion
Reply with quote
Post Re: Inventory things
TheLastBanana wrote:
has a tendency to lose their weapons

To be fair you were just storing the actor's name and then recreating it later. If you found a way to keep it (outside the map?) instead of deleting it, then it'd retain everything.


Mon Nov 28, 2011 8:45 pm
Profile
User avatar

Joined: Sat Jan 17, 2009 8:53 am
Posts: 79
Location: Philippines
Reply with quote
Post Re: Inventory things
Code:
local thing = actor:Inventory();
if thing.PresetName == "actor" then
   self:SwapNextInventory(nil,  false);
else
   self:SwapNextInventory(thing, false);
end


This could probably work for you. From here.
Untested though.


Tue Nov 29, 2011 4:44 pm
Profile YIM WWW
Data Realms Elite
Data Realms Elite
User avatar

Joined: Fri Jan 07, 2011 8:01 am
Posts: 6211
Location: In your office, earning your salary.
Reply with quote
Post Re: Inventory things
actor:Inventory()?

What's that for?


Tue Nov 29, 2011 7:35 pm
Profile
User avatar

Joined: Sat Jan 17, 2009 8:53 am
Posts: 79
Location: Philippines
Reply with quote
Post Re: Inventory things
Oh, that should be self:Inventory(). Sorry.


Wed Nov 30, 2011 7:13 am
Profile YIM WWW
Data Realms Elite
Data Realms Elite
User avatar

Joined: Fri Jan 07, 2011 8:01 am
Posts: 6211
Location: In your office, earning your salary.
Reply with quote
Post Re: Inventory things
No I mean, what does that code do?


Wed Nov 30, 2011 7:28 pm
Profile
User avatar

Joined: Sat Jan 17, 2009 8:53 am
Posts: 79
Location: Philippines
Reply with quote
Post Re: Inventory things
It appears to return the next item in the inventory.


Fri Dec 02, 2011 6:17 pm
Profile YIM WWW
Display posts from previous:  Sort by  
Reply to topic   [ 19 posts ]  Go to page 1, 2  Next

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.057s | 14 Queries | GZIP : Off ]