Global Scripts are not good for me. I mean, I'm unable to combine global scripts even I've readen the tutorial about it many times. It just confuses me more and more. But the compiling was sucessful with some minor errors.
Pass 1: Parsing
Pass 2: Preprocessing
conveyor.zh, line 21: lexical error ''.
conveyor.zh, line 29: lexical error ''.
conveyor.zh, line 37: lexical error ''.
conveyor.zh, line 45: lexical error ''.
conveyor.zh, line 73: lexical error ''.
conveyor.zh, line 89: lexical error ''.
conveyor.zh, line 97: lexical error ''.
Pass 3: Building symbol tables
Pass 4: Type-checking/Completing function symbol tables/Constant folding
Pass 5: Generating object code
Pass 6: Assembling
Success!
Please let me know if this still has the lexical errors. Whatever they are, they are invisible.
/////////////////////////////
/// Faster Conveyor Belts ///
/// v0.1 ///
/// 12-Nov-2016 ///
/// By: ZoriaRPG ///
/////////////////////////////////////////////////////////////////////////////////
/// Purpose: This allows creating conveyor belts that move *Link* faster than ///
/// the stock ZC conveyors. ///
/// ///
/// Future versions may support bombs, items, somaria blocks, and npcs. ///
/// I have *no plans* to add, or support creating *slower* conveyors with ///
/// this header. ///
/////////////////////////////////////////////////////////////////////////////////
//FFC Version
ffc script FasterConveyors{
void run(int speed, int step){
int timer = speed;
while(true){
if ( Screen->ComboT[ ComboAt(Link->X, Link->Y) ] == CT_CVLEFT ) {
if ( !timer ) timer = speed;
if ( timer > 1 ) timer--;
if ( timer == 1 && CanWalk(Link->X, Link->Y, DIR_LEFT, step, false) ) {
Link->X--;
timer = speed;
}
}
else if ( Screen->ComboT[ ComboAt(Link->X, Link->Y) ] == CT_CVRIGHT ) {
if ( !timer ) timer = speed;
if ( timer > 1 ) timer--;
if ( timer == 1 && CanWalk(Link->X, Link->Y, DIR_RIGHT, step, false) ) {
Link->X++;
timer = speed;
}
}
else if ( Screen->ComboT[ ComboAt(Link->X, Link->Y) ] == CT_CVUP ) {
if ( !timer ) timer = speed;
if ( timer > 1 ) timer--;
if ( timer == 1 && CanWalk(Link->X, Link->Y, DIR_UP, step, false) ) {
Link->Y--;
timer = speed;
}
}
else if ( Screen->ComboT[ ComboAt(Link->X, Link->Y) ] == CT_CVDOWN ) {
if ( !timer ) timer = speed;
if ( timer > 1 ) timer--;
if ( timer == 1 && CanWalk(Link->X, Link->Y, DIR_DOWN, step, false) ) {
Link->Y++;
timer = speed;
}
}
else timer = speed;
Waitframe();
}
}
}
//Global Version
int ____GRAM[214747];
const int CONVEYOR_TIMER = 10020; //Index of ____GRAM.
const int FAST_CONVEY_SPEED = 30;
const int FAST_CONVEY_STEP = 1;
const int CMB_FAST_CONVEY_RT = 1000; //Set to combo ID of Fast Conveyor (Right)
const int CMB_FAST_CONVEY_LF = 1000; //Set to combo ID of Fast Conveyor (Left)
const int CMB_FAST_CONVEY_UP = 1000; //Set to combo ID of Fast Conveyor (Up)
const int CMB_FAST_CONVEY_DN = 1000; //Set to combo ID of Fast Conveyor (Down)
//Call as FasterConveyors(FAST_CONVEY_SPEED, FAST_CONVEY_STEP, ____GRAM, CONVEYOR_TIMER);
void FasterConveyors(int speed, int step, int arr, int index){
if ( Screen->ComboD[ ComboAt(Link->X, Link->Y) ] == CMB_FAST_CONVEY_LF ) {
if ( !arr[index] ) arr[index] = speed;
if ( arr[index] > 1 ) arr[index]--;
if ( arr[index] == 1 && CanWalk(Link->X, Link->Y, DIR_LEFT, step, false) ) {
Link->X--;
arr[index] = speed;
}
}
else if ( Screen->ComboD[ ComboAt(Link->X, Link->Y) ] == CMB_FAST_CONVEY_RT ) {
if ( !arr[index] ) arr[index] = speed;
if ( arr[index] > 1 ) arr[index]--;
if ( arr[index] == 1 && CanWalk(Link->X, Link->Y, DIR_RIGHT, step, false) ) {
Link->X++;
arr[index] = speed;
}
}
else if ( Screen->ComboD[ ComboAt(Link->X, Link->Y) ] == CMB_FAST_CONVEY_UP ) {
if ( !arr[index] ) arr[index] = speed;
if ( arr[index] > 1 ) arr[index]--;
if ( arr[index] == 1 && CanWalk(Link->X, Link->Y, DIR_UP, step, false) ) {
Link->Y--;
arr[index] = speed;
}
}
else if ( Screen->ComboD[ ComboAt(Link->X, Link->Y) ] == CMB_FAST_CONVEY_DN ) {
if ( !arr[index] ) arr[index] = speed;
if ( arr[index] > 1 ) arr[index]--;
if ( arr[index] == 1 && CanWalk(Link->X, Link->Y, DIR_DOWN, step, false) ) {
Link->Y++;
arr[index] = speed;
}
}
else arr[index] = speed;
}
global script convey{
void run(){
while(true){
FasterConveyors(FAST_CONVEY_SPEED, FAST_CONVEY_STEP, ____GRAM, CONVEYOR_TIMER);
Waitdraw();
Waitframe();
}
}
}
Other than those, does it work?
Implementing it as a global script means that once you assign the four combos that it uses, all you need ever do to add fast conveyors to a screen, is place the combos, rather than adding the ffc to every screen with them.
Edited by ZoriaRPG, 12 November 2016 - 10:10 AM.