View unanswered posts | View active topics It is currently Thu May 09, 2024 1:18 am



Reply to topic  [ 6 posts ] 
 Add inventory to craft 
Author Message
User avatar

Joined: Mon Jul 16, 2007 9:50 am
Posts: 1512
Location: Tallahassee, FL
Reply with quote
Post Add inventory to craft
Completely redid this post since I have a better showing of whats going on:
Code:
function Create(self)
   self.returner = CreateACDropShip("D82Yatagarasu Returner");
   self.returner.Team = self.Team
   self.returner.Pos = Vector(self.Pos.X, -90);
   MovableMan:AddActor(self.returner);
end

function Update(self)
   self.returner.Pos = Vector(self.Pos.X, -90);

   if not(self:IsInventoryEmpty()) then
      local item = self:SwapPrevInventory(nil);
      
      self.returner:AddInventoryItem(item);
   end
end

function Destroy(self)
   self.returner.Pos = Vector(self.Pos.X, -110);
end

Basically, this is all of my script for a dropship. The idea is that when this one is created, it creates another invisible dropship somewhere. Then whenever anything gets loaded onto this dropship, it immediately gets transferred to the invisible dropship. Once this dropship is destroyed for any reason, the invisible dropship is moved up far enough to where it gets sent away for refunds.

Problem is, I get this error in regards to the self.returner:AddInventoryItem(item); line:
Code:
ERROR: no overload of  'ACDropShip:AddInventoryItem' matched the arguments (ACDropShip, MovableObject)
candidates are:
ACDropShip:AddInventoryItem(MovableObject*)

Seems like whatever SwapPrevInventory() gives you, AddInventoryItem() doesn't like.

Now, I've done some fiddling around in order to gather some possibly useful info, and I've discovered that if you create a new object (like with CreateAHuman() or something) and then immediately use it as an argument for AddInventoryItem(), it works. But if you use an Add function (like AddActor()) first and THEN pass it to AddInventoryItem(), you get the above error. So AddInventoryItem() doesn't work if the thing already exists in the Actor or Item lists? This seems like a logical conclusion, except for the fact that when something enters a craft, it gets pulled from its respective list. So I just don't know what to think.

I thought AddInventoryItem() and SwapPrev/NextInventory() could be used in conjunction to swap around existing items, but this doesn't seem to be the case. Now, is it supposed to be this way? Or is there something wrong here?


Fri May 29, 2009 7:27 pm
Profile YIM
User avatar

Joined: Mon Jul 16, 2007 9:50 am
Posts: 1512
Location: Tallahassee, FL
Reply with quote
Post Re: Add inventory to craft
Bump for more informative first post.


Sun May 31, 2009 7:46 am
Profile YIM
REAL AMERICAN HERO
User avatar

Joined: Sat Jan 27, 2007 10:25 pm
Posts: 5655
Reply with quote
Post Re: Add inventory to craft
I think it has to do with inventory access being ♥♥♥♥.


Sun May 31, 2009 7:56 am
Profile
User avatar

Joined: Mon Jul 16, 2007 9:50 am
Posts: 1512
Location: Tallahassee, FL
Reply with quote
Post Re: Add inventory to craft
Grif wrote:
I think it has to do with inventory access being ♥♥♥♥.

Probably. There's another idea that's gonna get put on the backburner until further notice...


Sun May 31, 2009 8:03 am
Profile YIM
User avatar

Joined: Mon Jun 30, 2008 9:13 pm
Posts: 499
Location: Finland
Reply with quote
Post Re: Add inventory to craft
Try replacing
Code:
      local item = self:SwapPrevInventory(nil);
      self.returner:AddInventoryItem(item);

with
Code:
local item = self:SwapPrevInventory(nil);
      local item2 = CreateHDFirearm(item.PresetName)
      self.returner:AddInventoryItem(item2)
Then do some classname checking to make it not crash with other types than HDFirearms.


Sun May 31, 2009 11:21 am
Profile
User avatar

Joined: Mon Jul 16, 2007 9:50 am
Posts: 1512
Location: Tallahassee, FL
Reply with quote
Post Re: Add inventory to craft
piipu wrote:
Try replacing
Code:
      local item = self:SwapPrevInventory(nil);
      self.returner:AddInventoryItem(item);

with
Code:
local item = self:SwapPrevInventory(nil);
      local item2 = CreateHDFirearm(item.PresetName)
      self.returner:AddInventoryItem(item2)
Then do some classname checking to make it not crash with other types than HDFirearms.

I'd thought about this, but I just realized I hadn't thought about it hard enough. I thought "well, if it was an actor with its own devices in inventory, I'd end up with the same issue of inventory swapping." But I could just as easily run through the actor's inventory, create new versions of all of its stuff, and add them to the new actor's inventory in the same way. I could maybe even do some gold value checking in order to adjust return value for damage in the original actor.

Alright, I think I'm getting somewhere.


Sun May 31, 2009 5:12 pm
Profile YIM
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:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by STSoftware for PTF.
[ Time : 0.034s | 13 Queries | GZIP : Off ]