I havn't cogged in quite awhile (heh, so long I had to look at the datamaster to remember the structure of a cog) and I'm trying to make a shield recharge console, like the ones in JO. So far I have this:
And everytime I activate the console it raises the shield up by one, but it does it regardless of the inventory of the shield bin and max. If you take out the setpulse(0); in the pulse message, it's keep adding shields even after it reaches the bin's max. Any ideas?
------------------
*Takes out his blaster and fires shots at the wall, the blastmarks leave the words "S-TROOPER WUZ 'ERE!!!"
[This message has been edited by Stormtrooper (edited December 31, 2003).]
Code:
# Jedi Knight Cog Script # # CON_SHIELD.COG # # Class cog for a shield recharger. # v 0.1 # [ST] # Not LEC supported flags=0x240 symbols message activated message pulse message deactivated thing console local thing player local sound beep=helthpu1.wav local sound outsound=Activate01.wav local int bin=60 local flex max=100 local end # ======================================================================================== code activated: player = GetSourceRef(); console = GetSenderRef(); if (bin < GetInvMax(player, bin)) { if (max <= 100) { setpulse(0.1); } else { return; } } Return; # ........................................................................................ pulse: player = GetSourceRef(); console = GetSenderRef(); Print("pulsing"); if (bin < GetInvMax(player, bin)) { if(max <= 100) { PlaySoundThing(beep, console, 1.0, -1, -1, 0); ChangeInv(player, bin, 1.0); //set the player's shield up by one max = max-1; // set the amount of shields for this recharger down one point SetPulse(0); //pulse off for debugging purposes } else { PlaySoundThing(outsound, console, 1.0, -1, -1, 0); SetPulse(0); } } else { SetPulse(0); } Return; # ........................................................................................ deactivated: SetPulse(0); Return; # ........................................................................................ end
And everytime I activate the console it raises the shield up by one, but it does it regardless of the inventory of the shield bin and max. If you take out the setpulse(0); in the pulse message, it's keep adding shields even after it reaches the bin's max. Any ideas?
------------------
*Takes out his blaster and fires shots at the wall, the blastmarks leave the words "S-TROOPER WUZ 'ERE!!!"
[This message has been edited by Stormtrooper (edited December 31, 2003).]