Jump to content

Photo

Help with combine scritp


  • Please log in to reply
3 replies to this topic

#1 LTTP

LTTP

    LTTP

  • Members
  • Real Name:LTTP
  • Location:A Place Far Far Away

Posted 26 May 2013 - 10:13 AM

Alright! So far I had 2 scripts working:
For exp:

 

import "std.zh"

ffc script RealNPC{
    void run(int m, int sfx, int defdir, int d, int ffcnumber, int input){
        ffc NPC = this;
        if(ffcnumber != 0) Screen->LoadFFC(ffcnumber);
        NPC->Misc[0] = NPC->Data;
        if(d == 0) d = 40;
        
        while(true){
            SetGraphic(NPC,defdir,d);
            if(CanTalk(NPC,input)){
                SetInput(input,false);
                if(sfx != 0) Game->PlaySound(sfx);
                Screen->Message(m);
            }
            Waitframe();
        }
    }
    bool CanTalk(ffc NPC,int input){
        return (SelectPressInput(input) && Abs(NPC->X-Link->X) < 24 && Abs(NPC->Y-Link->Y) < 24 && Link->Z == 0);
    }
    void SetGraphic(ffc NPC, int defdir, int d){
        int dx = NPC->X-Link->X; int ax = Abs(dx);
        int dy = NPC->Y-Link->Y; int ay = Abs(dy);
        if(defdir != 0){
            if(ax < d && ay < d){
                if(ax <= ay){
                    if(dy >= 0) NPC->Data = NPC->Misc[0]+DIR_UP;
                    else NPC->Data = NPC->Misc[0]+DIR_DOWN;
                }else{
                    if(dx >= 0) NPC->Data = NPC->Misc[0]+DIR_LEFT;
                    else NPC->Data = NPC->Misc[0]+DIR_RIGHT;
                }
            }else NPC->Data = NPC->Misc[0]+(defdir-1);
        }
    }
}

//Only include these two functions once in your script file
bool SelectPressInput(int input){
    if(input == 0) return Link->PressA;
    else if(input == 1) return Link->PressB;
    else if(input == 2) return Link->PressL;
    else if(input == 3) return Link->PressR;
}
void SetInput(int input, bool state){
    if(input == 0) Link->InputA = state;
    else if(input == 1) Link->InputB = state;
    else if(input == 2) Link->InputL = state;
    else if(input == 3) Link->InputR = state;
}

//**************************************************************************************//
//**************************************************************************************//

ffc script stepWithItem{
    void run(int triggerItem1){
        while(!Screen->State[ST_SECRET]){
            if ( Link->Item[triggerItem1] && DistanceFromLink(this->X+8, this->Y+8) <= 8 ){
                Screen->TriggerSecrets();
                Screen->State[ST_SECRET] = true;
                Game->PlaySound(27);
            }
        Waitframe();
        }
    }
}

//Returns distance to Link's center
int DistanceFromLink ( int x, int y )
 {
    return Distance ( Link->X+8, Link->Y+8, x, y );
 }

Now I go to add: 
http://www.purezc.ne...showtopic=53411

this scrip, and combine it as normal, I get an error.
First error was on line I think 16 ""){""

I removed that and it seems to have solved that issue.
Now I am getting error on this line

			else splashTimer = splashFreq;

Here is a bastebin link to how I how the script set up: http://pastebin.com/3wDwhQMg


Edited by LTTP, 26 May 2013 - 10:14 AM.


#2 Hoff123

Hoff123

    The Hoff :)

  • Members
  • Location:Sweden

Posted 26 May 2013 - 10:52 AM

Oh... I'm so sorry. I guess you read that post I made in that thread huh? Do NOT remove both the ")" and "{". Only remove the "(".

 

Like this: 

{
    if( splashTimer >= splashFreq ){
    Game->PlaySound(SFX_SPLASH);
    splashTimer = 0;
    }
    splashTimer++;
}

I'm so sorry... Hope that helps.


Edited by Hoff123, 26 May 2013 - 10:53 AM.


#3 LTTP

LTTP

    LTTP

  • Members
  • Real Name:LTTP
  • Location:A Place Far Far Away

Posted 26 May 2013 - 11:08 AM

ahaha ya thanks works now
BUT!
While I am here!
I never did a global script, and it seems different to add.
How would I go about doing so in the assign menu?



#4 Hoff123

Hoff123

    The Hoff :)

  • Members
  • Location:Sweden

Posted 26 May 2013 - 11:12 AM

There is a pinned thread about it here: http://www.purezc.ne...showtopic=38773

 

But basically, ZC(or ZQuest) only allows 1 single Global script(well, 2...sort of... just visit the link), and you need to combine different scripts into one single script. It's easier if you know (even just a little) about programming, but still, that link should help :).


  • LTTP likes this


1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users