Data Realms Fan Forums http://45.55.195.193/ |
|
force reload http://45.55.195.193/viewtopic.php?f=73&t=25474 |
Page 1 of 1 |
Author: | salt_1219 [ Sat Sep 10, 2011 11:06 am ] |
Post subject: | force reload |
how would i force a gun to reload? I'm editing the duel fire mode template to be triggered by a key, not the pie menu & to force the gun to reload when it switches between modes. Also i plan to make it play a sound (probably to device switch noise from base files) to let you know you changed modes. I know how to set it to be triggered by a key, the reloading part has me stumped. -thanks |
Author: | CaveCricket48 [ Sat Sep 10, 2011 3:41 pm ] |
Post subject: | Re: force reload |
Code: HDFirearm:Reload(); |
Author: | salt_1219 [ Sat Sep 10, 2011 8:26 pm ] |
Post subject: | Re: force reload |
thank you I seem to have missed something when making it switch by pressing F I'm not sure what i did wrong. also I'm thinking that adding AEmitter to play a sound at switch would be redundant due to the reload sound would already play. ... Just ignore the AEmitter I'm going to edit it out. Mode1 code Code: -- this edit is a work in progress function Create(self) self.switchToWeapon = "Spiderbot Grenade Launcher Alt-Fire"; -- PresetName of gun to switch to self.switchToClass = "HDFirearm"; end function Update(self) local actor = MovableMan:GetMOFromID(self.RootID); if MovableMan:IsActor(actor) then local actor = ToAHuman(actor); if UInputMan:KeyHeld(6) then -- press f to switch modes HDFirearm:Reload(); -- force reload as soon as weapon switches -- ?????? = CreateAEmitter("SwitchSound", "X-9.rte"); -- play sound... might not need this due to it reloading if self.switchToClass == "HDFirearm" then local switchGun = actor:AddInventoryItem(CreateHDFirearm(self.switchToWeapon)); elseif self.switchToClass == "TDExplosive" then local switchGun = actor:AddInventoryItem(CreateTDExplosive(self.switchToWeapon)); elseif self.switchToClass == "HeldDevice" then local switchGun = actor:AddInventoryItem(CreateHeldDevice(self.switchToWeapon)); end actor:GetController():SetState(Controller.WEAPON_DROP,true); self.ToDelete = true; end end end |
Author: | CaveCricket48 [ Sat Sep 10, 2011 8:57 pm ] |
Post subject: | Re: force reload |
Could you put some code tags around that? Kinda hard to read. Edit: When I said "HDFirearm:Reload()," you're supposed to replace 'HDFirearm' with the pointer to an HDFirearm. |
Author: | salt_1219 [ Sat Sep 10, 2011 9:12 pm ] |
Post subject: | Re: force reload |
Ok thanks, sorry im typing on my cell. I will add code blocks & add the pointer. Okay stupid question here, the pointer in this case would be the guns name? self.wepname = "Grenade Launcher"; or gun.PresetName == "Grenade Launche"; -- no, that would be for a if statement, and would mean equal to. ("Grenade Launcher"):Reload(); I really need to look at more scripts, I clearly have trouble even doing a simple edit. |
Author: | Asklar [ Sun Sep 11, 2011 6:10 am ] |
Post subject: | Re: force reload |
Well, if the script is attached to the weapon, then the weapon is "self" pointer. And if you want to reload the weapon then you do self:Reload(). |
Page 1 of 1 | All times are UTC [ DST ] |
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |