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



Reply to topic  [ 5 posts ] 
 Deleting an item in inventory? [SOLVED] 
Author Message
User avatar

Joined: Sat Jan 17, 2009 8:53 am
Posts: 79
Location: Philippines
Reply with quote
Post Deleting an item in inventory? [SOLVED]
How do you delete an item in the inventory of an actor?
I've figured out how to delete the current item being held, but not how to delete it when it's in their inventory.

Or maybe even cycling through the inventory until you reach the item, then delete it?


Last edited by ramonimbao on Sun Feb 13, 2011 1:04 am, edited 1 time in total.



Sat Feb 12, 2011 2:33 am
Profile YIM WWW
User avatar

Joined: Wed Feb 17, 2010 12:07 am
Posts: 1545
Location: That small peaceful place called Hell.
Reply with quote
Post Re: Deleting an item in inventory?
I think something like this should work:

Code:
for actor in MovableMan.Actors do
  self.weap = <Weapon Name Here>
  if actor:HasObject(self.weap) then
    self.weap.ToDelete = true
  end
end


I'm not entirely sure if that would work though, haven't tested this.


Sat Feb 12, 2011 3:06 am
Profile
User avatar

Joined: Sat Jan 17, 2009 8:53 am
Posts: 79
Location: Philippines
Reply with quote
Post Re: Deleting an item in inventory?
I think for your code, self.weap should be pointing to an MO, so I don't think this'll actually work.

This has been my code so far:
Code:
for actor in MovableMan.Actors do
   if actor:IsPlayerControlled() == true then
      for i = 1, MovableMan:GetMOIDCount()-1 do
         gun=MovableMan:GetMOFromID(i);
         if gun.PresetName == "M16" and gun.RootID == actor.ID then
            gun.ToDelete = true
         end
      end
   end
end


It deletes the weapon you're currently holding if it's an M16, but does not delete ones in the inventory.


Sat Feb 12, 2011 3:15 am
Profile YIM WWW

Joined: Fri Dec 18, 2009 11:00 pm
Posts: 167
Reply with quote
Post Re: Deleting an item in inventory?
Anything to do with CC inventory is buggy as hell and very likely to screw up your game.

but anyway

Code:
for actor in MovableMan.Actors do
     if actor:IsPlayerContolled() then
          local weap = actor:Inventory();
          if weap.PresetName == "weapon name" then
               self:SwapNextInventory(nil,  false);
          else
               self:SwapNextInventory(weap, false);
          end
     end
end


Sat Feb 12, 2011 5:41 pm
Profile
User avatar

Joined: Sat Jan 17, 2009 8:53 am
Posts: 79
Location: Philippines
Reply with quote
Post Re: Deleting an item in inventory?
Awesome! Exactly what I needed! Thanks! :D


Sun Feb 13, 2011 1:03 am
Profile YIM WWW
Display posts from previous:  Sort by  
Reply to topic   [ 5 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.080s | 13 Queries | GZIP : Off ]