View unanswered posts | View active topics It is currently Fri Apr 26, 2024 7:04 pm



Reply to topic  [ 20 posts ]  Go to page Previous  1, 2
 Randomized Weapon upon Buying 
Author Message
User avatar

Joined: Tue Feb 08, 2011 4:14 am
Posts: 59
Reply with quote
Post Re: Randomized Weapon upon Buying
Bad Boy wrote:
Foa wrote:
Also, double slashes are for ini comments, double hyphens are for lua comments.
Oh wow, embarrassing, my mind is all filled with java at the moment.

And sorry about that Xavier (also, sorry for the sloppiness of this, I made way too many errors for something so simple), change the line that says MovableMan:AddInventoryItem(self.pistol) to MovableMan:AddInventoryItem(CreateHDFirearm(self.pistol));


You mean self.parent.AddInventoryItem(self.pistol)? If so, it doesn't work.

I'm trying something now, so hold on for a moment.

EDIT: I just replaced the self.parent.AddInventoryItem line with MovableMan:AddInventoryItem and it doesn't work. It spits out a 'no match for function call '' with the parameters (HDFirearm).'


Wed Apr 24, 2013 6:33 am
Profile

Joined: Fri Sep 10, 2010 1:48 am
Posts: 666
Location: Halifax, Canada
Reply with quote
Post Re: Randomized Weapon upon Buying
Wow, I really cocked this up, jeez. Try this:

If this doesn't work, can you upload the rte? That way I can look at it properly and give you a working solution.


Wed Apr 24, 2013 3:20 pm
Profile
User avatar

Joined: Tue Feb 08, 2011 4:14 am
Posts: 59
Reply with quote
Post Re: Randomized Weapon upon Buying
Bad Boy wrote:
If this doesn't work, can you upload the rte? That way I can look at it properly and give you a working solution.


It gave me another error involving 'Actor:AddInventoryItem' not matching the HDFirearm argument.


Last edited by XavierStudios on Thu Apr 25, 2013 2:51 am, edited 1 time in total.



Wed Apr 24, 2013 6:47 pm
Profile

Joined: Fri Sep 10, 2010 1:48 am
Posts: 666
Location: Halifax, Canada
Reply with quote
Post Re: Randomized Weapon upon Buying
Alright, all fixed. Sorry it took so many attempts on here, I made so many little mistakes due to rustiness:
Code:
function Create(self)
   --This part finds the parent actor if there is one
   self.parent = nil;
   self.parentpickingdone = false;
   local actor = MovableMan:GetMOFromID(self.RootID);
   if MovableMan:IsActor(actor) then
      self.parent = ToActor(actor);
      self.parentpickingdone = true;
   end

   --This part makes the weapon list and picks the weapon
   self.randPistol = {"Ballester-Molina","Ballester-Molina","Ballester-Molina"} -- Pistol preset names here
   self.pistol = self.randPistol[math.random(#self.randPistol)]
end
function Update(self)
   --Check again for parents due to CC's weirdness when dropping troops in or spawning them in edit mode. May not be necessary for this, I'm not sure
   if self.parentpickingdone == false then
      if self.parent == nil then
         local actor = MovableMan:GetMOFromID(self.RootID);

         if MovableMan:IsActor(actor) then
            self.parent = ToActor(actor);
            self.parentpickingdone = true;
         end
      end
   end
   if self.parent ~= nil then --If we have a parent then add the gun to his inventory
      print (self.pistol)
      self.parent:AddInventoryItem(CreateHDFirearm(self.pistol, "UMA.rte"));
      self.ToDelete = true
      self.parent:GetController():SetControlState(Controller.WEAPON_CHANGE_NEXT , true);
   else
      if self.Age > 1000 then --Otherwise, after a second delay to double check if we have a parent, just add the pistol to the map.
         local pistol = CreateHDFirearm(self.pistol, "UMA.rte")
         pistol.Pos = self.Pos
         MovableMan:AddParticle(pistol)
         self.ToDelete = true
      end
   end
end

One thing to note, you can only use guns from this rte so right now they're all the same gun. While it's not necessary to add the rte to run from, not doing this can cause the wrong weapon to spawn when two mods have identically named weapons.
Also, you have some dependencies on Unitec. Don't forget to remove them before releasing the mod.


Thu Apr 25, 2013 2:05 am
Profile
User avatar

Joined: Tue Feb 08, 2011 4:14 am
Posts: 59
Reply with quote
Post Re: Randomized Weapon upon Buying
Bad Boy wrote:
Also, you have some dependencies on Unitec. Don't forget to remove them before releasing the mod.


Thank you kindly. This is perfect for what I have in store, so all of my thanks go to you.

On the UniTec dependency, this mod is literally just getting started, so that won't be a problem in the future. I just needed a proper platform to start from and UniTec is reliable on that front.


Thu Apr 25, 2013 2:39 am
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 20 posts ]  Go to page Previous  1, 2

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.374s | 15 Queries | GZIP : Off ]