Will this script work as intended?

Post » Tue Jun 07, 2016 9:45 pm

Will this script compare the two possibilities separately?



if (( PlayerRef.getItemCount(ltraHelmet)==1 )) || (( PlayerRef.getItemCount(Helmet1)==1 && PlayerRef.getItemCount(Helmet2)==1 && PlayerRef.getItemCount(Helmet3)==1))
;Do Something
endif

Or do you have to do something like this?



if PlayerRef.getItemCount(Helmet1)==1 && PlayerRef.getItemCount(Helmet2)==1 && PlayerRef.getItemCount(Helmet3)==1
Maskcount = True
else
Maskcount = False
endif
if PlayerRef.getItemCount(UltraHelmet)==1 || Maskcount == True
;Do Something
endif

User avatar
Bitter End
 
Posts: 3418
Joined: Fri Sep 08, 2006 11:40 am

Post » Wed Jun 08, 2016 2:33 am

The first should work, but I'd suggest using "> 0" rather than "== 1", just in case a glitch provides two of what is supposed to be a unique item.

Incidentally, the ")) || ((" should probably just be ") || (", so the outer set enclose the entire condition.

"Maskcount = True" in the second example would need to be "Maskcount == True", and you have too many endif's.
User avatar
Erin S
 
Posts: 3416
Joined: Sat Jul 29, 2006 2:06 pm

Post » Wed Jun 08, 2016 2:47 am



Yes the Maskcount was just a placeholder so I could compile the script. The endifs are needed in the script as it is in the Kit. However I have fixed that for people who are new to scripting.






Thanks. How about != 0?






I have seen scripts done like this.



(( PlayerRef.getItemCount(ArmorDragonPriestMaskUltraHelmet)==1 )) || (( PlayerRef.getItemCount(ArmorDragonPriestMaskBronzeHelmet)==1 && PlayerRef.getItemCount(ArmorDragonPriestMaskCorondrumHelmet)==1 ))



And like this.



( PlayerRef.getItemCount(ArmorDragonPriestMaskUltraHelmet)==1 ) || ( PlayerRef.getItemCount(ArmorDragonPriestMaskBronzeHelmet)==1 && PlayerRef.getItemCount(ArmorDragonPriestMaskCorondrumHelmet)==1 )

Is there an actual functional difference? Both Compile.



Thanks Agian

User avatar
Ashley Campos
 
Posts: 3415
Joined: Fri Sep 22, 2006 9:03 pm

Post » Tue Jun 07, 2016 6:23 pm

One of the traditional annoyances of programming is matching up parentheses, brackets, braces, etc. So using (( and )) when ( and ) would work just seems like a really odd thing to do for experienced programmers.



I would have actually written that without the first set of parentheses to highlight that the second set is a group and the first is just a single item. But I like a minimal number of parens.



if PlayerRef.GetItemCount(ltraHelmet) > 0 || ( PlayerRef.GetItemCount(Helmet1) > 0 && PlayerRef.GetItemCount(Helmet2) > 0 && PlayerRef.GetItemCount(Helmet3) > 0 )
;Do Something
endif
User avatar
katie TWAVA
 
Posts: 3452
Joined: Tue Jul 04, 2006 3:32 am

Post » Tue Jun 07, 2016 8:04 pm


You could also do "if PlayerRef.GetItemCount(helmet)" with no numeric comparison as well (the number zero converts to False, everything else is True). It's mostly just a stylistic thing, with most likely an insignificant performance impact. Do what looks best to you.

User avatar
Shae Munro
 
Posts: 3443
Joined: Fri Feb 23, 2007 11:32 am

Post » Tue Jun 07, 2016 7:26 pm

Thanks for the help!



if PlayerRef.GetItemCount(ltraHelmet) || ( PlayerRef.GetItemCount(Helmet1) && PlayerRef.GetItemCount(Helmet2) && PlayerRef.GetItemCount(Helmet3) )
;Do Something
endif
User avatar
Eduardo Rosas
 
Posts: 3381
Joined: Thu Oct 18, 2007 3:15 pm


Return to V - Skyrim