QUOTE(HylianGlaceon @ Mar 8 2011, 12:19 AM)
symbiote01: What exactly does the tiered script do? lucas92 made the whole custom bomb thing in the other topic. Right now the only downside I have is that the properties of the bomb is pre-set (like if I wanted to change the speed or frames of the bomb), but it's still very usable for me. There's also an Item Script attached to the global script I didn't post for it to work in the other topic.
The differences between Gleeok's and my versions are essentially unimportant. He turned your two global scripts (global script ActionScript and global script slot_2) into two functions (doThing1 and doThing2), then created a third script (global script globalScriptSlot2) and called his two functions. The advantage to his method is that if you ever needed the script to run either of those two functions somewhere else, you'd just have to call the function. In function doThing1() this makes sense, as it deals with one thing- checking the custom bomb (that you have an item script for, I'm sure) to see if it blew up on a specific tile flag. In function doThing2(), however, it makes less sense, as it handles a bunch of other items mostly with other function calls (Bombchu(),BombArrow(), and PegasusBoots()), and one integer (StoreHP).
My method just shuffled the two scripts together, though I did take some time to organize and annotate it a little. The only thing my 'tiered script' (which should replace the section in the other script annotated '//Custom bomb check for secrets') does is keep Allegro.log happy when there are no lweapons on the screen. In the original version, whenever the for(i = 1; i <= Screen->NumLWeapons(); i++) loop is called and there are no lweapons on the screen, it would produce an error in Allegro.log. What that for() loop is actually saying is, "some number 'i' starts at one; 'i' is less than or equal to the number of lweapons on the screen; 'i' increments up by one every time this loop repeats." As long as all of that is true, it continues to run the loop.
The error happens because the value of 'i' in the loop (Screen->LoadLWeapon(
i)) would be zero if there were no lweapons on the screen, which breaks the loop, which assumes that there is always at least one lweapon present (i = 1).
My fix is to only run the function if there is actually an lweapon on the screen, thus preventing the error. It also keeps the script from running when it doesn't need to- in frames where there are no lweapons on the screen, it skips the check.
The other way to fix it is to start the for() loop with 'i = 0', which would always be true (there are always zero or more lweapons on the screen). The downsides of this method: one more repeat of the loop (to account for i=0) every time it runs, and the fact that it now has to run every frame of the game. It's a tiny, miniscule, insignificant burden, but if you put enough tiny burdens on the system, starts to add up.
Edited by symbiote01, 08 March 2011 - 10:27 AM.