doonce command

Post » Tue Dec 29, 2009 2:15 pm

a little while ago I requested help with getting 2 items from one item for a mod. Well I basically need similar help, except that last script removed the initial item that gave you the two others. So this time I need it so that it gives you the item, and you keep the initial item, but every time you use that item again, you will not recieve the item over and over again.

currently this is the script:

scn CSEquipHintScroll

Begin onEquip

player.additem CSHintscroll1

end

(actually I am too lazy to open up my CS right now, so I just rewrote it, that mighyt not be the script exactly)
If you could tell me what I need to add to only let it add the CSHintscroll1 once on equip it would be greatly appreciated :)
User avatar
Wayne W
 
Posts: 3482
Joined: Sun Jun 17, 2007 5:49 am

Post » Tue Dec 29, 2009 1:59 pm

scn CSEquipHintScrollshort DoOnceBegin onEquipIf DoOnce == 0        player.additem CSHintscroll1       Set DoOnce to 1endifend


Enjoy!
Simply declare DoOnce as a variable (Short DoOnce)
Then put it as a condition

When the player equip the item and that DoOnce is False (0), then it adds the item and declares it True (1)
Endif is for ending the condition you just set.
User avatar
Rach B
 
Posts: 3419
Joined: Thu Mar 08, 2007 11:30 am

Post » Tue Dec 29, 2009 11:59 am

thank you good sir :)
User avatar
Chris Ellis
 
Posts: 3447
Joined: Thu Jul 26, 2007 10:00 am

Post » Tue Dec 29, 2009 5:39 am

Can I add my usual plea for the variable to be given a meaningful name? Like "ScrollGiven" in this case. Once you have half a dozen of these in a single script, it gets hard to read if you don't.

Bethesda's programmers set a very bad example calling it doonce (not even DoOnce, which is easier to understand) and every new player has copied it as if it were holy writ. I've even noticed some coders believing it wouldn't work if they changed the name!
User avatar
M!KkI
 
Posts: 3401
Joined: Sun Jul 16, 2006 7:50 am

Post » Tue Dec 29, 2009 5:24 pm

Can I add my usual plea for the variable to be given a meaningful name? Like "ScrollGiven" in this case. Once you have half a dozen of these in a single script, it gets hard to read if you don't.

Bethesda's programmers set a very bad example calling it doonce (not even DoOnce, which is easier to understand) and every new player has copied it as if it were holy writ. I've even noticed some coders believing it wouldn't work if they changed the name!

Well said, I would like to join your protest against this practise!
User avatar
Michelle Chau
 
Posts: 3308
Joined: Sat Aug 26, 2006 4:24 am


Return to IV - Oblivion