Data Realms Fan Forums http://45.55.195.193/ |
|
Add inventory to craft http://45.55.195.193/viewtopic.php?f=73&t=15056 |
Page 1 of 1 |
Author: | Darlos9D [ Fri May 29, 2009 7:27 pm ] |
Post subject: | 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? |
Author: | Darlos9D [ Sun May 31, 2009 7:46 am ] |
Post subject: | Re: Add inventory to craft |
Bump for more informative first post. |
Author: | Grif [ Sun May 31, 2009 7:56 am ] |
Post subject: | Re: Add inventory to craft |
I think it has to do with inventory access being ♥♥♥♥. |
Author: | Darlos9D [ Sun May 31, 2009 8:03 am ] |
Post subject: | 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... |
Author: | piipu [ Sun May 31, 2009 11:21 am ] |
Post subject: | 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) |
Author: | Darlos9D [ Sun May 31, 2009 5:12 pm ] |
Post subject: | 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) 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. |
Page 1 of 1 | All times are UTC [ DST ] |
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |