Miscellaneous Functions

 
Miscellaneous Functions
 
In this section are the commands which do not fit elsewhere.
 
Function
Description
Returns the elapsed time in milliseconds between main iterations
Returns the active slot number
Loads a specified slot
Returns the identifier of the controller button
Sets the vm timeout for the next iteration
 
1
get_rtime
 
get_rtime returns the elapsed time between the current and previous iteration of the main function.  The value returned is in milliseconds.
 
You can see this function in action by using this counter script;
 
int days;
int hours;
int minutes;
int seconds;
int milliseconds;
 
main {
 
    milliseconds = milliseconds + get_rtime();
 
    if(milliseconds >= 1000) {
        milliseconds = milliseconds - 1000
        seconds = seconds + 1;
        if(seconds == 60) {
            seconds = 0;
            minutes = minutes + 1;
            if(minutes == 60) {
                minutes = 0;
                hours = hours + 1;
                if(hours == 24) {
                    hours = 0;
                    days = days + 1;
                }
            }
        }
    }
    set_val(TRACE_1, days);
    set_val(TRACE_2, hours);
    set_val(TRACE_3, minutes);
    set_val(TRACE_4, seconds);
    set_val(TRACE_5, milliseconds / 10);
 
}
 

Syntax

 
get_rtime (  );
 

Parameters

 
None
 
 

Returns

 
The elapsed time, in milliseconds, between main iterations
2
get_slot
 
get_slot returns an int which represents the number of the currently active slot.
 
Example of usage:
 
int _currentSlot;
 
init {
 
    _currentSlot = get_slot();
 
}
 
main {
 
}
 

Syntax

 
get_slot (  );
 

Parameters

 
None
 
 
 

Returns

 
The number of the currently active slot
3
load_slot
 
load_slot will attempt to load the slot number specified within its parameter.  If there is no script current stored in the specified slot, then it will unload the current slot and load slot 0.
 
Example of usage:
 
main {
 
    if(event_press(XB1_RB))     // if RB / R2 is pressed...
        load_slot(5);           // Load slot 5
   
    if(event_press(XB1_LB))     // if LB / L2 is pressed...
        load_slot(0);           // Unload current slot and load slot 0
 
}
 

Syntax

 
load_slot ( <slot_number> );
 

Parameters

 
<slot_number> :
A value while represents a slot number to load, range 0~9
4
get_ctrlbutton
 
get_ctrlbutton returns the current control button. 
 
The control button is set in the Device tab within Cronus PRO's Options window.  The enable remote control of slow switch on device dictates which button it is set to
 
 
If enable remote control is disabled, then the control button is 0 (The Xbox / Guide / PS button)
 
If enable remote control is enabled and G8 Alternate is disabled, then the control button is 1 (Back / View / Select / Share)
 
If both remote control and G8 Alternate are enabled, then the control button is 8 (LS / L3)
 

Syntax

 
get_ctrlbutton (  );
 

Parameters

 
None
 
 

Returns

 
0, 1 or 8 depending on the Remote slot settings in device options
5
vm_tctrl
 
vm_tctrl sets the virtual machine timeout for the next iteration.  By default, the virtual machine runs the main loop every 10 milliseconds as it aids stability. You can however adjust how often each main iteration is run.  Just be aware than changing this setting may cause instability within your script.
 
Example of usage:
 
main {
 
    vm_tctrl(-5); // Run the VM every 5ms
 
}
 

Syntax

 
vm_tctrl ( <Value> );
 

Parameters

 
<Value> :
Numeric value to add to the VM base time. Range -9 ~ 10