Jump to content

Photo

Problem with Scripts

Scripts NPCs

  • Please log in to reply
15 replies to this topic

#16 Moosh

Moosh

    Tiny Little Questmaker

  • ZC Developers

Posted 10 July 2020 - 05:41 PM

Alright, looks like in this case you have the entirely of the SimpleShop script twice in this file. Delete all of this from the bottom of the file:

//D0: ID of the item
//D1: Price of the item
//D2: Message that plays when the item is bought
//D3: Message that plays when you don't have enough rupees
//D4: Input type 0=A 1=B 2=L 3=R
ffc script SimpleShop{
    void run(int itemID, int price, int m, int n, int input){
        int loc = ComboAt(this->X,this->Y);
        while(true){
            while(!AgainstComboBase(loc) || !SelectPressInput(input)) Waitframe();
            SetInput(input,false);
                if(Game->Counter[CR_RUPEES] >= price){
                Game->DCounter[CR_RUPEES] -= price;
                item shpitm = CreateItemAt(itemID, Link->X, Link->Y);
                shpitm->Pickup = IP_HOLDUP;
                Screen->Message(m);
                }
                else{
                Screen->Message(n);
                }              
            Waitframe();
        }
    }
    bool AgainstComboBase(int loc){
        return Link->Z == 0 && (Link->Dir == DIR_UP && Link->Y == ComboY(loc)+8 && Abs(Link->X-ComboX(loc)) < 8);
    }
}
 
//If you are already using the signpost script remove the code below
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;
}

Should compile then.

 

It might be helpful to make a table of contents for your scripts at the top of the file. Any line with // at the start is a comment. These are ignored on compilation but help with script readability. In this case you could have a list of scripts at the top of your file like so:

// FFC Scripts:
//   Real NPC V2
//   Simple Shop
//   Permanent Tiered Secrets

Then above every script you can put a label.

//=================================
//       Real NPC Script
//=================================

This is all completely optional, I don't do it myself, but some find it helpful for keeping track of which scripts are in the file before compiling. 


  • Lightwulf likes this



Also tagged with one or more of these keywords: Scripts, NPCs

1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users