Cycle memory slots

GPC2 script programming for Titan Two. Code examples, questions, requests.

Cycle memory slots

Postby Mad » Fri Dec 06, 2019 11:54 pm

This needs to be placed at the very bottom of all the scripts you want to cycle.

Code: Select all
#include <xb1.gph>
 
#define SLOTS_IN_USE 4 // How many memory slots are in use
 
main {
  // Hold L2-LT and press Dpad UP/DOWN to cycle slots
  if(is_active(XB1_LT)) {
    if(event_active(XB1_DOWN)) {
      if(mslot_get() == SLOTS_IN_USE) mslot_load(1);
      else mslot_load(mslot_get()+1);
    }
    if(event_active(XB1_UP)) {
      if(mslot_get() == 1) mslot_load(SLOTS_IN_USE);
      else mslot_load(mslot_get()-1);
    }
  }
}
ConsoleTuner Support Team || ConsoleTuner Discord || InputSense Discord
Mad
Major General
Major General
 
Posts: 4536
Joined: Wed May 22, 2019 5:39 am

Re: Cycle memory slots

Postby Derivates » Mon Sep 28, 2020 10:12 pm

What about adding this as an included file on every script you would like to cycle? perhaps the approach is easier, would the multiple mains conflict? (asking because of "This needs to be placed at the very bottom of all the scripts you want to cycle.")

This is my approach if it's worth sharing by the way:
Code: Select all
 
#define SLOTS_IN_USE 4 /* Set how many memory slots are in use */
 
main {
    /* Hold L2/LT and press D-Pad UP/DOWN to cycle slots */
    /* Cycle UP */
    if(is_active(7)) {
        if(event_active(10)) {
            mslot_load((mslot_get() == SLOTS_IN_USE) ? 1 : mslot_get() + 1);
        }
        /* Cycle DOWN */
        if(event_active(9)) {
            mslot_load((mslot_get() == 1) ? SLOTS_IN_USE : mslot_get() - 1);
        }
    }
}
 
User avatar
Derivates
Sergeant Major
Sergeant Major
 
Posts: 75
Joined: Sat Jan 19, 2019 6:15 pm


Return to GPC2 Script Programming

Who is online

Users browsing this forum: Google [Bot] and 49 guests