Re: An Explanation Of Triggers
I am now the owner of the main post, and I've updated it with a bunch of cool new information, like Static variables and hidden trigger functions.
AwesomeJRFD wrote:
JSlayerXero in 'Designer Tips and Tricks' (Page 10) wrote:So, I figured out a way to retain global variables after death. To copy it straight out of my Mini-LLLDC entry:
- Code: Select all
llitem:6:achv2mem;4203;348;64;64;0;1;branch,5,4,g_achvt,1:set,a,1:set,g_achv2t,1:exit:branch,5,7,g_achv2t,1:set,g_achv2t,1:add,g_achv,g_achv,a:set,g_achvt,0|46;4210;280;branch,5,6,achv,1:add,g_achv,g_achv,1:set,achv,1:activate,achv2mem:subtitle,1,%3Cb%3EAchievement%20Unlocked%3A%20%7B%24g_achv%7D/4%3C/b%3E%0DThe%20Ghost%27s%20Heart,75:sleep,60:subtitle_off|6;4288;256;64;64;0;1;set,g_achvt,1:activate,achv2mem
To explain this is layman's terms, basically what happens is that the Large Heart has the code to make my achievements. These are only built to activate once, and will end prematurely if you've ever gotten them before. These then activate a "memory" trigger, in this case the "achv2mem" trigger. The blank hitbox trigger I should've renamed something like "memrecall" since that is its function. It sets a "test" variable and activates the memory trigger. The test variable makes it so that the actually memory function doesn't activate prematurely. When the achievement trigger activates the memory, it also sets a global variable to let the memory know that you got that particular achievement in this life. This prevents you from getting the achievement again when you activate the recall trigger. However, since it is global, it is also used to detect if you have the achievement, but died afterwards. There are probably better ways to word this, but I've explained the basic functions.
Keep this in mind when placing these: The achievement, and to my knowledge, the memory can be anywhere in the level, but the recall has to be placed in such a way that it must be activated before going through a mandatory transition.
Keep in mind that this system is custom-built to work with my level. Modifications may be necessary to make this compatible with other levels.
llitem:194;535;1395;1;1;130;;0|195;559;1416;1;1;125;;0|193;573;1411;1;1;40;;0|193;587;1387;1;1;-140;;0|196;586;1388;1;1;55;;0|189;528;1362;1;1;15;;0|192;549;1318;1;1;-95;;0|193;557;1302;1;1;-110;;0|190;543;1299;1;1;-130;;0|195;570;1310;1;1;-10;;0|194;571;1341;1;1;0;;0|196;571;1339;1;1;-170;;0