Two Globals with the same script code?

Post » Mon Aug 10, 2009 4:36 pm

This is more of a question regarding a concept than an actual scripting question. Which do you think is more efficient: Two Globals that for part of the time do the same thing, or two globals that both call upon a third global do the part of script that would be similar between the two in the former instance.

For instance: Say I had two scripts that did two separate things, but both required the player to be Levitating. In the former example, both scripts would separately check if the player was levitating, while the latter example would have a global that does this check separately. This is a simple example, but what if the script had to check a BUNCH of things rather than just if the player is levitating? :twirl:

I don't know if there is any comprehensive answer to this, but it would be nice to see what the general consensus is. :foodndrink:
User avatar
Tracey Duncan
 
Posts: 3299
Joined: Wed Apr 18, 2007 9:32 am

Post » Mon Aug 10, 2009 2:27 pm

If there are no functionality/readability problems, I'd use 2 longer scripts instead of 3 medium scripts.
User avatar
Siobhan Thompson
 
Posts: 3443
Joined: Sun Nov 12, 2006 10:40 am

Post » Mon Aug 10, 2009 11:45 am

It's easier to write smaller scripts than longer scripts so it depends on the experience of the person. It really doesn't matter. The longer you make a script and the more complex it becomes with checking multiple things for multiple conditions the more chance for error. Plus if there is something wrong with a script for trouble shooting purposes it's harder to figure out what exactly is wrong(at least for an in experienced person). Making a bunch of globals for checking certain things is a lot easier for certain situations too. I don't know if it's good practice but if you want something semi complicated to be done the more globals the easier it is

Here i thought i post this for fun. I have a script that pretty simple but does something semi complicated. It checks to see if you have 15 ebony weapons of any combination.

Spoiler
Begin EbonyArmorScript     set ebony to 0set ebony2 to 0set ebony3 to 0set ebony4 to 0set ebony5 to 0set ebony6 to 0set ebony7 to 0set ebony27 to 0         if ( player->getitemcount, "Ebony war axe" == 1 )        Set ebony to ebony + 1		set ebony27 to ebony27 + 1    endif         If ( player->getitemcount, "ebony war axe" == 2 )        set ebony to ebony + 2set ebony27 to ebony27 + 2    endif         If ( player->getitemcount, "ebony war axe" == 3 )        set ebony to ebony + 3set ebony27 to ebony27 + 3    endif	 If ( player->getitemcount, "ebony war axe" == 4 )        set ebony to ebony + 4set ebony27 to ebony27 + 4    endif	 If ( player->getitemcount, "ebony war axe" == 5 )        set ebony to ebony + 5set ebony27 to ebony27 + 5    endif	 If ( player->getitemcount, "ebony war axe" == 6 )        set ebony to ebony + 6set ebony27 to ebony27 + 6    endif	 If ( player->getitemcount, "ebony war axe" == 7 )        set ebony to ebony + 7set ebony27 to ebony27 + 7    endif	 If ( player->getitemcount, "ebony war axe" == 8 )        set ebony to ebony + 8set ebony27 to ebony27 + 8    endif	 If ( player->getitemcount, "ebony war axe" == 9 )        set ebony to ebony + 9set ebony27 to ebony27 + 9    endif	 If ( player->getitemcount, "ebony war axe" == 10 )        set ebony to ebony + 10set ebony27 to ebony27 + 10    endif	 If ( player->getitemcount, "ebony war axe" == 11 )        set ebony to ebony + 11set ebony27 to ebony27 + 11    endif	 If ( player->getitemcount, "ebony war axe" == 12 )        set ebony to ebony + 12set ebony27 to ebony27 + 12    endif	 If ( player->getitemcount, "ebony war axe" == 13 )        set ebony to ebony + 13set ebony27 to ebony27 + 13    endif	 If ( player->getitemcount, "ebony war axe" == 14 )        set ebony to ebony + 14set ebony27 to ebony27 + 14    endif	 If ( player->getitemcount, "ebony war axe" >= 15 )        set ebony to ebony + 15set ebony27 to ebony27 + 15    endif       if ( player->getitemcount, "Ebony mace" == 1 )        Set ebony2 to ebony2 + 1	set ebony27 to ebony27 + 1    endif         If ( player->getitemcount, "ebony mace" == 2 )        set ebony2 to ebony2 + 2set ebony27 to ebony27 + 2    endif         If ( player->getitemcount, "ebony mace" == 3 )        set ebony2 to ebony2 + 3set ebony27 to ebony27 + 3    endif	 If ( player->getitemcount, "ebony mace" == 4 )        set ebony2 to ebony2 + 4set ebony27 to ebony27 + 4    endif	 If ( player->getitemcount, "ebony mace" == 5 )        set ebony2 to ebony2 + 5set ebony27 to ebony27 + 5    endif	 If ( player->getitemcount, "ebony mace" == 6 )        set ebony2 to ebony2 + 6set ebony27 to ebony27 + 6    endif	 If ( player->getitemcount, "ebony mace" == 7 )        set ebony2 to ebony2 + 7set ebony27 to ebony27 + 7    endif	 If ( player->getitemcount, "ebony mace" == 8 )        set ebony2 to ebony2 + 8set ebony27 to ebony27 + 8    endif	 If ( player->getitemcount, "ebony mace" == 9 )        set ebony2 to ebony2 + 9set ebony27 to ebony27 + 9    endif	 If ( player->getitemcount, "ebony mace" == 10 )        set ebony2 to ebony2 + 10set ebony27 to ebony27 + 10    endif	 If ( player->getitemcount, "ebony mace" == 11 )        set ebony2 to ebony2 + 11set ebony27 to ebony27 + 11    endif	 If ( player->getitemcount, "ebony mace" == 12 )        set ebony2 to ebony2 + 12set ebony27 to ebony27 + 12    endif	 If ( player->getitemcount, "ebony mace" == 13 )        set ebony2 to ebony2 + 13set ebony27 to ebony27 + 13    endif	 If ( player->getitemcount, "ebony mace" == 14 )        set ebony2 to ebony2 + 14set ebony27 to ebony27 + 14    endif	 If ( player->getitemcount, "ebony mace" >= 15 )        set ebony2 to ebony2 + 15set ebony27 to ebony27 + 15endif      if ( player->getitemcount, "Ebony staff" == 1 )        Set ebony3 to ebony3 + 1		set ebony27 to ebony27 + 1    endif         If ( player->getitemcount, "ebony staff" == 2 )        set ebony3 to ebony3 + 2set ebony27 to ebony27 + 2    endif         If ( player->getitemcount, "ebony staff" == 3 )        set ebony3 to ebony3 + 3set ebony27 to ebony27 + 3    endif	 If ( player->getitemcount, "ebony staff" == 4 )        set ebony3 to ebony3 + 4set ebony27 to ebony27 + 4    endif	 If ( player->getitemcount, "ebony staff" == 5 )        set ebony3 to ebony3 + 5set ebony27 to ebony27 + 5    endif	 If ( player->getitemcount, "ebony staff" == 6 )        set ebony3 to ebony3 + 6set ebony27 to ebony27 + 6    endif	 If ( player->getitemcount, "ebony staff" == 7 )        set ebony3 to ebony3 + 7set ebony27 to ebony27 + 7    endif	 If ( player->getitemcount, "ebony staff" == 8 )        set ebony3 to ebony3 + 8set ebony27 to ebony27 + 8    endif	 If ( player->getitemcount, "ebony staff" == 9 )        set ebony3 to ebony3 + 9set ebony27 to ebony27 + 9    endif	 If ( player->getitemcount, "ebony staff" == 10 )        set ebony3 to ebony3 + 10set ebony27 to ebony27 + 10    endif	 If ( player->getitemcount, "ebony staff" == 11 )        set ebony3 to ebony3 + 11set ebony27 to ebony27 + 11    endif	 If ( player->getitemcount, "ebony staff" == 12 )        set ebony3 to ebony3 + 12set ebony27 to ebony27 + 12    endif	 If ( player->getitemcount, "ebony staff" == 13 )        set ebony3 to ebony3 + 13set ebony27 to ebony27 + 13    endif	 If ( player->getitemcount, "ebony staff" == 14 )        set ebony3 to ebony3 + 14set ebony27 to ebony27 + 14    endif	 If ( player->getitemcount, "ebony staff" >= 15 )        set ebony3 to ebony3 + 15set ebony27 to ebony27 + 15    endif    if ( player->getitemcount, "Ebony broadsword" == 1 )        Set ebony4 to ebony4 + 1		set ebony27 to ebony27 + 1    endif         If ( player->getitemcount, "ebony broadsword" == 2 )        set ebony4 to ebony4 + 2set ebony27 to ebony27 + 2    endif         If ( player->getitemcount, "ebony broadsword" == 3 )        set ebony4 to ebony4 + 3set ebony27 to ebony27 + 3    endif	 If ( player->getitemcount, "ebony broadsword" == 4 )        set ebony4 to ebony4 + 4set ebony27 to ebony27 + 4    endif	 If ( player->getitemcount, "ebony broadsword" == 5 )        set ebony4 to ebony4 + 5set ebony27 to ebony27 + 5    endif	 If ( player->getitemcount, "ebony broadsword" == 6 )        set ebony4 to ebony4 + 6set ebony27 to ebony27 + 6    endif	 If ( player->getitemcount, "ebony broadsword" == 7 )        set ebony4 to ebony4 + 7set ebony27 to ebony27 + 7    endif	 If ( player->getitemcount, "ebony broadsword" == 8 )        set ebony4 to ebony4 + 8set ebony27 to ebony27 + 8    endif	 If ( player->getitemcount, "ebony broadsword" == 9 )        set ebony4 to ebony4 + 9set ebony27 to ebony27 + 9    endif	 If ( player->getitemcount, "ebony broadsword" == 10 )        set ebony4 to ebony4 + 10set ebony27 to ebony27 + 10    endif	 If ( player->getitemcount, "ebony broadsword" == 11 )        set ebony4 to ebony4 + 11set ebony27 to ebony27 + 11    endif	 If ( player->getitemcount, "ebony broadsword" == 12 )        set ebony4 to ebony4 + 12set ebony27 to ebony27 + 12    endif	 If ( player->getitemcount, "ebony broadsword" == 13 )        set ebony4 to ebony4 + 13set ebony27 to ebony27 + 13    endif	 If ( player->getitemcount, "ebony broadsword" == 14 )        set ebony4 to ebony4 + 14set ebony27 to ebony27 + 14    endif	 If ( player->getitemcount, "ebony broadsword" >= 15 )        set ebony4 to ebony4 + 15set ebony27 to ebony27 + 15    endif    if ( player->getitemcount, "Ebony shortsword" == 1 )        Set ebony5 to ebony5 + 1		set ebony27 to ebony27 + 1    endif         If ( player->getitemcount, "ebony shortsword" == 2 )        set ebony5 to ebony5 + 2set ebony27 to ebony27 + 2    endif         If ( player->getitemcount, "ebony shortsword" == 3 )        set ebony5 to ebony5 + 3set ebony27 to ebony27 + 3    endif	 If ( player->getitemcount, "ebony shortsword" == 4 )        set ebony5 to ebony5 + 4set ebony27 to ebony27 + 4    endif	 If ( player->getitemcount, "ebony shortsword" == 5 )        set ebony5 to ebony5 + 5set ebony27 to ebony27 + 5    endif	 If ( player->getitemcount, "ebony shortsword" == 6 )        set ebony5 to ebony5 + 6set ebony27 to ebony27 + 6    endif	 If ( player->getitemcount, "ebony shortsword" == 7 )        set ebony5 to ebony5 + 7set ebony27 to ebony27 + 7    endif	 If ( player->getitemcount, "ebony shortsword" == 8 )        set ebony5 to ebony5 + 8set ebony27 to ebony27 + 8    endif	 If ( player->getitemcount, "ebony shortsword" == 9 )        set ebony5 to ebony5 + 9set ebony27 to ebony27 + 9    endif	 If ( player->getitemcount, "ebony shortsword" == 10 )        set ebony5 to ebony5 + 10set ebony27 to ebony27 + 10    endif	 If ( player->getitemcount, "ebony shortsword" == 11 )        set ebony5 to ebony5 + 11set ebony27 to ebony27 + 11    endif	 If ( player->getitemcount, "ebony shortsword" == 12 )        set ebony5 to ebony5 + 12set ebony27 to ebony27 + 12    endif	 If ( player->getitemcount, "ebony shortsword" == 13 )        set ebony5 to ebony5 + 13set ebony27 to ebony27 + 13    endif	 If ( player->getitemcount, "ebony shortsword" == 14 )        set ebony5 to ebony5 + 14set ebony27 to ebony27 + 14    endif	 If ( player->getitemcount, "ebony shortsword" >= 15 )        set ebony5 to ebony5 + 15set ebony27 to ebony27 + 15    endif    if ( player->getitemcount, "Ebony longsword" == 1 )        Set ebony6 to ebony6 + 1		set ebony27 to ebony27 + 1    endif         If ( player->getitemcount, "ebony longsword" == 2 )        set ebony6 to ebony6 + 2set ebony27 to ebony27 + 2    endif         If ( player->getitemcount, "ebony longsword" == 3 )        set ebony6 to ebony6 + 3set ebony27 to ebony27 + 3    endif	 If ( player->getitemcount, "ebony longsword" == 4 )        set ebony6 to ebony6 + 4set ebony27 to ebony27 + 4    endif	 If ( player->getitemcount, "ebony longsword" == 5 )        set ebony6 to ebony6 + 5set ebony27 to ebony27 + 5    endif	 If ( player->getitemcount, "ebony longsword" == 6 )        set ebony6 to ebony6 + 6set ebony27 to ebony27 + 6    endif	 If ( player->getitemcount, "ebony longsword" == 7 )        set ebony6 to ebony6 + 7set ebony27 to ebony27 + 7    endif	 If ( player->getitemcount, "ebony longsword" == 8 )        set ebony6 to ebony6 + 8set ebony27 to ebony27 + 8    endif	 If ( player->getitemcount, "ebony longsword" == 9 )        set ebony6 to ebony6 + 9set ebony27 to ebony27 + 9    endif	 If ( player->getitemcount, "ebony longsword" == 10 )        set ebony6 to ebony6 + 10set ebony27 to ebony27 + 10    endif	 If ( player->getitemcount, "ebony longsword" == 11 )        set ebony6 to ebony6 + 11set ebony27 to ebony27 + 11    endif	 If ( player->getitemcount, "ebony longsword" == 12 )        set ebony6 to ebony6 + 12set ebony27 to ebony27 + 12    endif	 If ( player->getitemcount, "ebony longsword" == 13 )        set ebony6 to ebony6 + 13set ebony27 to ebony27 + 13    endif	 If ( player->getitemcount, "ebony longsword" == 14 )        set ebony6 to ebony6 + 14set ebony27 to ebony27 + 14    endif	 If ( player->getitemcount, "ebony longsword" >= 15 )        set ebony6 to ebony6 + 15set ebony27 to ebony27 + 15    endif   if ( player->getitemcount, "Ebony spear" == 1 )        Set ebony7 to ebony7 + 1		set ebony27 to ebony27 + 1    endif         If ( player->getitemcount, "ebony spear" == 2 )        set ebony7 to ebony7 + 2set ebony27 to ebony27 + 2    endif         If ( player->getitemcount, "ebony spear" == 3 )        set ebony7 to ebony7 + 3set ebony27 to ebony27 + 3    endif	 If ( player->getitemcount, "ebony spear" == 4 )        set ebony7 to ebony7 + 4set ebony27 to ebony27 + 4    endif	 If ( player->getitemcount, "ebony spear" == 5 )        set ebony7 to ebony7 + 5set ebony27 to ebony27 + 5    endif	 If ( player->getitemcount, "ebony spear" == 6 )        set ebony7 to ebony7 + 6set ebony27 to ebony27 + 6    endif	 If ( player->getitemcount, "ebony spear" == 7 )        set ebony7 to ebony7 + 7set ebony27 to ebony27 + 7    endif	 If ( player->getitemcount, "ebony spear" == 8 )        set ebony7 to ebony7 + 8set ebony27 to ebony27 + 8    endif	 If ( player->getitemcount, "ebony spear" == 9 )        set ebony7 to ebony7 + 9set ebony27 to ebony27 + 9    endif	 If ( player->getitemcount, "ebony spear" == 10 )        set ebony7 to ebony7 + 10set ebony27 to ebony27 + 10    endif	 If ( player->getitemcount, "ebony spear" == 11 )        set ebony7 to ebony7 + 11set ebony27 to ebony27 + 11    endif	 If ( player->getitemcount, "ebony spear" == 12 )        set ebony7 to ebony7 + 12set ebony27 to ebony27 + 12    endif	 If ( player->getitemcount, "ebony spear" == 13 )        set ebony7 to ebony7 + 13set ebony27 to ebony27 + 13    endif	 If ( player->getitemcount, "ebony spear" == 14 )        set ebony7 to ebony7 + 14set ebony27 to ebony27 + 14    endif	 If ( player->getitemcount, "ebony spear" >= 15 )        set ebony7 to ebony7 + 15set ebony27 to ebony27 + 15    endif If ( ebony27 >= 0 )stopscript, ebonyarmorscriptendif    end	


Then if the global ebony27 is greater than 15 it will start the remove script.

Spoiler
Begin EbonyRemove2Script                if ( SGV >= 15 )        stopscript, ebonyremove2script    endif                if ( Ebony2 == 1 )        player->removeitem, "ebony mace", 1                set SGV to SGV + 1        stopscript, ebonyremove2script    endif    if ( Ebony2 == 2 )        if ( SGV <= 13 )            player->removeitem, "ebony mace", 2                        set SGV to SGV + 2            stopscript, ebonyremove2script        elseIF ( SGV == 14 )            player->removeitem, "ebony mace", 1                        set SGV to SGV + 1            stopscript, ebonyremove2script        endif    endif    if ( Ebony2 == 3 )        if ( SGV <= 12 )            player->removeitem, "ebony mace", 3                        set SGV to SGV + 3            stopscript, ebonyremove2script        elseif ( SGV == 13 )            player->removeitem, "ebony mace", 2                        set SGV to SGV + 2            stopscript, ebonyremove2script        elseif ( SGV == 14 )            player->removeitem, "ebony mace", 1                        set SGV to SGV + 1            stopscript, ebonyremove2script        endif    endif    if ( Ebony2 == 4 )        if ( SGV <= 11 )            player->removeitem, "ebony mace", 4                        set SGV to SGV + 4            stopscript, ebonyremove2script        elseif ( SGV == 12 )            player->removeitem, "ebony mace", 3                        set SGV to SGV + 3            stopscript, ebonyremove2script        elseif ( SGV == 13 )            player->removeitem, "ebony mace", 2                        set SGV to SGV + 2            stopscript, ebonyremove2script        elseif ( SGV == 14 )            player->removeitem, "ebony mace", 1                        set SGV to SGV + 1            stopscript, ebonyremove2script        endif    endif    if ( Ebony2 == 5 )        if ( SGV <= 10 )            player->removeitem, "ebony mace", 5                        set SGV to SGV + 5            stopscript, ebonyremove2script        elseif ( SGV == 11 )            player->removeitem, "ebony mace", 4                        set SGV to SGV + 4            stopscript, ebonyremove2script        elseif ( SGV == 12 )            player->removeitem, "ebony mace", 3                        set SGV to SGV + 3            stopscript, ebonyremove2script        elseif ( SGV == 13 )            player->removeitem, "ebony mace", 2                        set SGV to SGV + 2            stopscript, ebonyremove2script        elseif ( SGV == 14 )            player->removeitem, "ebony mace", 1                        set SGV to SGV + 1            stopscript, ebonyremove2script        endif    endif    if ( Ebony2 == 6 )        if ( SGV <= 9 )            player->removeitem, "ebony mace", 6                        set SGV to SGV + 6            stopscript, ebonyremove2script        elseif ( SGV == 10 )            player->removeitem, "ebony mace", 5                        set SGV to SGV + 5            stopscript, ebonyremove2script        elseif ( SGV == 11 )            player->removeitem, "ebony mace", 4                        set SGV to SGV + 4            stopscript, ebonyremove2script        elseif ( SGV == 12 )            player->removeitem, "ebony mace", 3                        set SGV to SGV + 3            stopscript, ebonyremove2script        elseif ( SGV == 13 )            player->removeitem, "ebony mace", 2                        set SGV to SGV + 2            stopscript, ebonyremove2script        elseif ( SGV == 14 )            player->removeitem, "ebony mace", 1                        set SGV to SGV + 1            stopscript, ebonyremove2script        endif    endif    if ( Ebony2 == 7 )        if ( SGV <= 8 )            player->removeitem, "ebony mace", 7                        set SGV to SGV + 7            stopscript, ebonyremove2script        elseif ( SGV == 9 )            player->removeitem, "ebony mace", 6                        set SGV to SGV + 6            stopscript, ebonyremove2script        elseif ( SGV == 10 )            player->removeitem, "ebony mace", 5                        set SGV to SGV + 5            stopscript, ebonyremove2script        elseif ( SGV == 11 )            player->removeitem, "ebony mace", 4                        set SGV to SGV + 4            stopscript, ebonyremove2script        elseif ( SGV== 12 )            player->removeitem, "ebony mace", 3                        set SGV to SGV + 3            stopscript, ebonyremove2script        elseif ( SGV == 13 )            player->removeitem, "ebony mace", 2                        set SGV to SGV + 2            stopscript, ebonyremove2script        elseif ( SGV == 14 )            player->removeitem, "ebony mace", 1                        set SGV to SGV + 1            stopscript, ebonyremove2script        endif    endif    if ( Ebony2 == 8 )        if ( SGV <= 7 )            player->removeitem, "ebony mace", 8                        set SGV to SGV + 8            stopscript, ebonyremove2script        elseif ( SGV == 8 )            player->removeitem, "ebony mace", 7                        set SGV to SGV + 7            stopscript, ebonyremove2script        elseif ( SGV == 9 )            player->removeitem, "ebony mace", 6                        set SGV to SGV + 6            stopscript, ebonyremove2script        elseif ( SGV == 10 )            player->removeitem, "ebony mace", 5                        set SGV to SGV + 5            stopscript, ebonyremove2script        elseif ( SGV == 11 )            player->removeitem, "ebony mace", 4                        set SGV to SGV + 4            stopscript, ebonyremove2script         elseif ( SGV == 12 )            player->removeitem, "ebony mace", 3                        set SGV to SGV + 3            stopscript, ebonyremove2script        elseif ( SGV == 13 )            player->removeitem, "ebony mace", 2                        set SGV to SGV + 2            stopscript, ebonyremove2script        elseif ( SGV == 14 )            player->removeitem, "ebony mace", 1                        set SGV to SGV + 1            stopscript, ebonyremove2script        endif    endif    if ( Ebony2 == 9 )        if ( SGV <= 6 )            player->removeitem, "ebony mace", 9                        set SGV to SGV + 9            stopscript, ebonyremove2script        elseif ( SGV == 7 )            player->removeitem, "ebony mace", 8                        set SGV to SGV + 8            stopscript, ebonyremove2script        elseif ( SGV == 8 )            player->removeitem, "ebony mace", 7                        set SGV to SGV + 7            stopscript, ebonyremove2script        elseif ( SGV == 9 )            player->removeitem, "ebony mace", 6                        set SGV to SGV + 6            stopscript, ebonyremove2script        elseif ( SGV == 10 )            player->removeitem, "ebony mace", 5                        set SGV to SGV + 5            stopscript, ebonyremove2script        elseif ( SGV == 11 )            player->removeitem, "ebony mace", 4                        set SGV to SGV + 4            stopscript, ebonyremove2script        elseif ( SGV == 12 )            player->removeitem, "ebony mace", 3                        set SGV to SGV + 3            stopscript, ebonyremove2script        elseif ( SGV == 13 )            player->removeitem, "ebony mace", 2                        set SGV to SGV + 2            stopscript, ebonyremove2script        elseif ( SGV == 14 )            player->removeitem, "ebony mace", 1                        set SGV to SGV + 1            stopscript, ebonyremove2script        endif    endif    if ( Ebony2 == 10 )        if ( SGV <= 5 )            player->removeitem, "ebony mace", 10                        set SGV to SGV + 10            stopscript, ebonyremove2script        elseif ( SGV == 6 )            player->removeitem, "ebony mace", 9                        set SGV to SGV + 9            stopscript, ebonyremove2script        elseif ( SGV == 7 )            player->removeitem, "ebony mace", 8                        set SGV to SGV + 8            stopscript, ebonyremove2script        elseif ( SGV == 8 )            player->removeitem, "ebony mace", 7                        set SGV to SGV + 7            stopscript, ebonyremove2script        elseif ( SGV == 9 )            player->removeitem, "ebony mace", 6                        set SGV to SGV + 6            stopscript, ebonyremove2script        elseif ( SGV == 10 )            player->removeitem, "ebony mace", 5                        set SGV to SGV + 5            stopscript, ebonyremove2script        elseif ( SGV == 11 )            player->removeitem, "ebony mace", 4                        set SGV to SGV + 4            stopscript, ebonyremove2script        elseif ( SGV == 12 )            player->removeitem, "ebony mace", 3                        set SGV to SGV + 3            stopscript, ebonyremove2script        elseif ( SGV == 13 )            player->removeitem, "ebony mace", 2                        set SGV to SGV + 2            stopscript, ebonyremove2script        elseif ( SGV == 14 )            player->removeitem, "ebony mace", 1                        set SGV to SGV + 1            stopscript, ebonyremove2script        endif    endif    if ( Ebony2 == 11 )        if ( SGV <= 4 )            player->removeitem, "ebony mace", 11                        set SGV to SGV + 11            stopscript, ebonyremove2script        elseif ( SGV == 5 )            player->removeitem, "ebony mace", 10                        set SGV to SGV + 10            stopscript, ebonyremove2script        elseif ( SGV == 6 )            player->removeitem, "ebony mace", 9                        set SGV to SGV + 9            stopscript, ebonyremove2script        elseif ( SGV == 7 )            player->removeitem, "ebony mace", 8                        set SGV to SGV + 8            stopscript, ebonyremove2script        elseif ( SGV == 8 )            player->removeitem, "ebony mace", 7                        set SGV to SGV + 7            stopscript, ebonyremove2script        elseif ( SGV == 9 )            player->removeitem, "ebony mace", 6                        set SGV to SGV + 6            stopscript, ebonyremove2script        elseif ( SGV == 10 )            player->removeitem, "ebony mace", 5                        set SGV to SGV + 5            stopscript, ebonyremove2script        elseif ( SGV == 11 )            player->removeitem, "ebony mace", 4                        set SGV to SGV + 4            stopscript, ebonyremove2script        elseif ( SGV == 12 )            player->removeitem, "ebony mace", 3                        set SGV to SGV + 3            stopscript, ebonyremove2script        elseif ( SGV == 13 )            player->removeitem, "ebony mace", 2                        set SGV to SGV + 2            stopscript, ebonyremove2script        elseif ( SGV == 14 )            player->removeitem, "ebony mace", 1                        set SGV to SGV + 1            stopscript, ebonyremove2script        endif    endif    if ( Ebony2 == 12 )        if ( SGV <= 3 )            player->removeitem, "ebony mace", 12                        set SGV to SGV + 12            stopscript, ebonyremove2script        elseif ( SGV == 4 )            player->removeitem, "ebony mace", 11                        set SGV to SGV + 11            stopscript, ebonyremove2script        elseif ( SGV == 5 )            player->removeitem, "ebony mace", 10                        set SGV to SGV + 10            stopscript, ebonyremove2script        elseif ( SGV == 6 )            player->removeitem, "ebony mace", 9                        set SGV to SGV + 9            stopscript, ebonyremove2script        elseif ( SGV == 7 )            player->removeitem, "ebony mace", 8                        set SGV to SGV + 8            stopscript, ebonyremove2script        elseif ( SGV == 8 )            player->removeitem, "ebony mace", 7                        set SGV to SGV + 7            stopscript, ebonyremove2script        elseif ( SGV == 9 )            player->removeitem, "ebony mace", 6                        set SGV to SGV + 6            stopscript, ebonyremove2script        elseif ( SGV == 10 )            player->removeitem, "ebony mace", 5                        set SGV to SGV + 5            stopscript, ebonyremove2script        elseif ( SGV == 11 )            player->removeitem, "ebony mace", 4                        set SGV to SGV + 4            stopscript, ebonyremove2script        elseif ( SGV == 12 )            player->removeitem, "ebony mace", 3                        set SGV to SGV + 3            stopscript, ebonyremove2script        elseif ( SGV == 13 )            player->removeitem, "ebony mace", 2                        set SGV to SGV + 2            stopscript, ebonyremove2script        elseif ( SGV == 14 )            player->removeitem, "ebony mace", 1                        set SGV to SGV + 1            stopscript, ebonyremove2script        endif    endif    if ( Ebony2 == 13 )        if ( SGV <= 2 )            player->removeitem, "ebony mace", 13                        set SGV to SGV + 13            stopscript, ebonyremove2script        elseif ( SGV == 3 )            player->removeitem, "ebony mace", 12                        set SGV to SGV + 12            stopscript, ebonyremove2script        elseif ( SGV == 4 )            player->removeitem, "ebony mace", 11                        set SGV to SGV + 11            stopscript, ebonyremove2script        elseif ( SGV == 5 )            player->removeitem, "ebony mace", 10                        set SGV to SGV + 10            stopscript, ebonyremove2script        elseif ( SGV == 6 )            player->removeitem, "ebony mace", 9                        set SGV to SGV + 9            stopscript, ebonyremove2script        elseif ( SGV == 7 )            player->removeitem, "ebony mace", 8                        set SGV to SGV + 8            stopscript, ebonyremove2script        elseif ( SGV == 8 )            player->removeitem, "ebony mace", 7                        set SGV to SGV + 7            stopscript, ebonyremove2script        elseif ( SGV == 9 )            player->removeitem, "ebony mace", 6                        set SGV to SGV + 6            stopscript, ebonyremove2script        elseif ( SGV == 10 )            player->removeitem, "ebony mace", 5                        set SGV to SGV + 5            stopscript, ebonyremove2script        elseif ( SGV == 11 )            player->removeitem, "ebony mace", 4                        set SGV to SGV + 4            stopscript, ebonyremove2script        elseif ( SGV == 12 )            player->removeitem, "ebony mace", 3                        set SGV to SGV + 3            stopscript, ebonyremove2script        elseif ( SGV == 13 )            player->removeitem, "ebony mace", 2                        set SGV to SGV + 2            stopscript, ebonyremove2script        elseif ( SGV == 14 )            player->removeitem, "ebony mace", 1                        set SGV to SGV + 1            stopscript, ebonyremove2script        endif    endif    if ( Ebony2 == 14 )        if ( SGV <= 1 )            player->removeitem, "ebony mace", 14                        set SGV to SGV + 14            stopscript, ebonyremove2script        elseif ( SGV == 2 )            player->removeitem, "ebony mace", 13                        set SGV to SGV + 13            stopscript, ebonyremove2script        elseif ( SGV == 3 )            player->removeitem, "ebony mace", 12                        set SGV to SGV + 12            stopscript, ebonyremove2script        elseif ( SGV == 4 )            player->removeitem, "ebony mace", 11                        set SGV to SGV + 11            stopscript, ebonyremove2script        elseif ( SGV == 5 )            player->removeitem, "ebony mace", 10                        set SGV to SGV + 10            stopscript, ebonyremove2script        elseif ( SGV == 6 )            player->removeitem, "ebony mace", 9                        set SGV to SGV + 9            stopscript, ebonyremove2script        elseif ( SGV == 7 )            player->removeitem, "ebony mace", 8                        set SGV to SGV + 8            stopscript, ebonyremove2script        elseif ( SGV == 8 )            player->removeitem, "ebony mace", 7                        set SGV to SGV + 7            stopscript, ebonyremove2script        elseif ( SGV == 9 )            player->removeitem, "ebony mace", 6                        set SGV to SGV + 6            stopscript, ebonyremove2script        elseif ( SGV == 10 )            player->removeitem, "ebony mace", 5                        set SGV to SGV + 5            stopscript, ebonyremove2script        elseif ( SGV == 11 )            player->removeitem, "ebony mace", 4                        set SGV to SGV + 4            stopscript, ebonyremove2script        elseif ( SGV == 12 )            player->removeitem, "ebony mace", 3                        set SGV to SGV + 3            stopscript, ebonyremove2script        elseif ( SGV == 13 )            player->removeitem, "ebony mace", 2                        set SGV to SGV + 2            stopscript, ebonyremove2script        elseif ( SGV == 14 )            player->removeitem, "ebony mace", 1                        set SGV to SGV + 1            stopscript, ebonyremove2script        endif    endif    if ( Ebony2 == 15 )        if ( SGV == 0 )            player->removeitem, "ebony mace", 15                        set SGV to SGV + 15            stopscript, ebonyremove2script        elseif ( SGV == 1 )            player->removeitem, "ebony mace", 14                        set SGV to SGV + 14            stopscript, ebonyremove2script        elseif ( SGV == 2 )            player->removeitem, "ebony mace", 13                        set SGV to SGV + 13            stopscript, ebonyremove2script        elseif ( SGV == 3 )            player->removeitem, "ebony mace", 12                        set SGV to SGV + 12            stopscript, ebonyremove2script        elseif ( SGV == 4 )            player->removeitem, "ebony mace", 11                        set SGV to SGV + 11            stopscript, ebonyremove2script        elseif ( SGV == 5 )            player->removeitem, "ebony mace", 10                        set SGV to SGV + 10            stopscript, ebonyremove2script        elseif ( SGV == 6 )            player->removeitem, "ebony mace", 9                        set SGV to SGV + 9            stopscript, ebonyremove2script        elseif ( SGV == 7 )            player->removeitem, "ebony mace", 8                        set SGV to SGV + 8            stopscript, ebonyremove2script        elseif ( SGV == 8 )            player->removeitem, "ebony mace", 7                        set SGV to SGV + 7            stopscript, ebonyremove2script        elseif ( SGV == 9 )            player->removeitem, "ebony mace", 6                        set SGV to SGV + 6            stopscript, ebonyremove2script        elseif ( SGV == 10 )            player->removeitem, "ebony mace", 5                        set SGV to SGV + 5            stopscript, ebonyremove2script        elseif ( SGV == 11 )            player->removeitem, "ebony mace", 4                        set SGV to SGV + 4            stopscript, ebonyremove2script        elseif ( SGV == 12 )            player->removeitem, "ebony mace", 3                        set SGV to SGV + 3            stopscript, ebonyremove2script        elseif ( SGV == 13 )            player->removeitem, "ebony mace", 2                        set SGV to SGV + 2            stopscript, ebonyremove2script        elseif ( SGV == 14 )            player->removeitem, "ebony mace", 1                        set SGV to SGV + 1            stopscript, ebonyremove2script        endif    endif            end	


There is a script for each weapon to remove it. Now i'm a newbie so this is very tedious but it works. I'm sure there is a way to combine all the scripts somehow but I'd rather not waste the time trying to figure that out when i don't have to.
User avatar
Julie Ann
 
Posts: 3383
Joined: Thu Aug 23, 2007 5:17 am

Post » Mon Aug 10, 2009 7:58 am

Having one controller script set a global that your functional scripts test is an effecient way of scripting. As Gforcebond mentions it does make it easier to diagnose if there is a problem in your logic for setting the global if you only do the testing in the one script. Some script functions are notoriously laggy such as getDistance. For this reason many if not most companions will test the distance from the player to the companion ever few seconds only and store the distance in a global. Dialog and teleport scripting can then check this variable for functions that are dependant on the companion being present and within a certain distance. For my WiP (for those who may wonder, yes I am still working on Carrie Irriettie) companion I classify her location for safe, dangerous, underwater & in the rain in a long series of if/elseif/else/endif querries. the result is then used in a series of scripts that dress the companion in an appropriate outfit.

@gforcebond: you can greatly simply your testing by inverting the order of the tests, eliminating extraneous tests & putting them in a while loop. Each pass through the loop would count/process 15 items.

begin heresHow

short howMany

set howMany to getItemCount "this item"

while ( howMany > 0 )

if ( howMany > 8 )
set amountOfIt to amountOfIt + 8
set howMany to howMany - 8
endIf

if ( howMany > 4 )
set amountOfIt to amountOfIt + 4
set howMany to howMany - 4
endIf

if ( howMany > 2 )
set amountOfIt to amountOfIt + 2
set howMany to howMany - 2
endIf

if ( howMany > 1 )
set amountOfIt to amountOfIt + 1
set howMany to howMany - 1
endIf

endWhile
endIf
User avatar
Tasha Clifford
 
Posts: 3295
Joined: Fri Jul 21, 2006 7:08 am

Post » Mon Aug 10, 2009 10:56 am

And also, why the first script is more preferable than simply writing:
	set ebony to player->getitemcount, "Ebony war axe" 	if ( ebony > 15 )		Set ebony to ebony + 1	endif	set ebony27 to ebony27 + ebony	set ebony2 to player->getitemcount, Ebony mace" 	if ( ebony2 > 15 )		Set ebony2 to 15	endif	set ebony27 to ebony27 + ebony2	set ebony3 to player->getitemcount, "Ebony staff" 	if ( ebony3 > 15 )		Set ebony3 to 15	endif	set ebony27 to ebony27 + ebony3	set ebony4 to player->getitemcount, "Ebony broadsword" 	if ( ebony4 > 15 )		Set ebony4 to 15	endif	set ebony27 to ebony27 + ebony4	set ebony5 to player->getitemcount, "Ebony shortsword" 	if ( ebony5 > 15 )		Set ebony5 to 15	endif	set ebony27 to ebony27 + ebony5	set ebony6 to player->getitemcount, "Ebony longsword" 	if ( ebony6 > 15 )		Set ebony6 to 15	endif	set ebony27 to ebony27 + ebony6	set ebony7 to player->getitemcount, "Ebony spear" 	if ( ebony7 > 15 )		Set ebony7 to 15	endif	set ebony27 to ebony27 + ebony7
, is beyond me. Simple scripts are your friends.
User avatar
Mizz.Jayy
 
Posts: 3483
Joined: Sat Mar 03, 2007 5:56 pm

Post » Mon Aug 10, 2009 8:06 pm

Well in this instance could you just do this for the first part?

Begin OneTestshort ebonyCountshort largestNum; If more than 20 you could easily split this up into two lines. Or more if readability is a concern.set ebony1 to GetItemCount, "Ebony spear" set ebony2 to GetItemCount, "Ebony longsword"set ebony3 to GetItemCount, "Ebony mace" set ebony4 to GetItemCount, "Ebony staff" set ebony5 to GetItemCount, "Ebony shortsword"set ebony6 to GetItemCount, "Ebony war axe"set ebony7 to GetItemCount, "Ebony broadsword"set ebonyCount to ebony1 + ebony2 + ebony3 + ebony4 + ebony5 + ebony6 + ebony7if ( ebonyCount > 15 )	; Stop this script and do Removal Stuff?endifEnd

User avatar
Hayley O'Gara
 
Posts: 3465
Joined: Wed Nov 22, 2006 2:53 am


Return to III - Morrowind