Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Where did you put them in your script file?
- They should be either at the file scope, or inside the scrito scope and outside of the run() function.
- [code]
- import "std.zh"
- //This is the File Scope
- //Functions placed at this scope are available globally by calling their identifier:
- // if ( IsLinkFacingSolid() )
- //Returns true if Link is facing a solid, on-screen combo.
- bool IsLinkFacingSolid(){
- int a; int dir = Link->Dir; int cmb = ComboAt(Link->X, Link->Y);
- int combooffsets[13]={-0x10, 0x10, -1, 1, -0x11, -0x0F, 0x0F, 0x11};
- if ( cmb % 16 == 0 ) combooffsets[9] = 1;
- if ( (cmb & 15) == 1 ) combooffsets[10] = 1;
- if ( cmb < 0x10 ) combooffsets[11] = 1; //if it's the top row
- if ( cmb > 0x9F ) combooffsets[12] = 1; //if it's on the bottom row
- if ( combooffsets[9] && ( dir == CMB_LEFT || dir == CMB_UPLEFT || dir == CMB_DOWNLEFT || dir == CMB_LEFTUP ) ) return false; //if the left columb
- if ( combooffsets[10] && ( dir == CMB_RIGHT || dir == CMB_UPRIGHT || dir == CMB_DOWNRIGHT ) ) return false; //if the right column
- if ( combooffsets[11] && ( dir == CMB_UP || dir == CMB_UPRIGHT || dir == CMB_UPLEFT || dir == CMB_LEFTUP ) ) return false; //if the top row
- if ( combooffsets[12] && ( dir == CMB_DOWN || dir == CMB_DOWNRIGHT || dir == CMB_DOWNLEFT ) ) return false; //if the bottom row
- if ( cmb >= 0 && cmb <= 176 ) a = cmb + combooffsets[dir];
- else a = -1;
- if ( a != -1 ) {
- return ( Screen->isSolid(ComboX(a), ComboY(a)));
- }
- return false;
- }
- //Returns true if Link is facing a solid, on-screen combo, but allows specifying a default return.
- bool IsLinkFacingSolid(bool default_return){
- int a; int dir = Link->Dir; int cmb = ComboAt(Link->X, Link->Y);
- int combooffsets[13]={-0x10, 0x10, -1, 1, -0x11, -0x0F, 0x0F, 0x11};
- if ( cmb % 16 == 0 ) combooffsets[9] = 1;
- if ( (cmb & 15) == 1 ) combooffsets[10] = 1;
- if ( cmb < 0x10 ) combooffsets[11] = 1; //if it's the top row
- if ( cmb > 0x9F ) combooffsets[12] = 1; //if it's on the bottom row
- if ( combooffsets[9] && ( dir == CMB_LEFT || dir == CMB_UPLEFT || dir == CMB_DOWNLEFT || dir == CMB_LEFTUP ) ) return default_return; //if the left columb
- if ( combooffsets[10] && ( dir == CMB_RIGHT || dir == CMB_UPRIGHT || dir == CMB_DOWNRIGHT ) ) return default_return; //if the right column
- if ( combooffsets[11] && ( dir == CMB_UP || dir == CMB_UPRIGHT || dir == CMB_UPLEFT || dir == CMB_LEFTUP ) ) return default_return; //if the top row
- if ( combooffsets[12] && ( dir == CMB_DOWN || dir == CMB_DOWNRIGHT || dir == CMB_DOWNLEFT ) ) return default_return; //if the bottom row
- if ( cmb >= 0 && cmb <= 176 ) a = cmb + combooffsets[dir];
- else a = -1;
- if ( a != -1 ) {
- return ( Screen->isSolid(ComboX(a), ComboY(a)) );
- }
- return default_return;
- }
- ///////////////////////////////////////////////////
- /// Example of Script-pScope Function Placement ///
- ///////////////////////////////////////////////////
- //If you place the functions at a script scope, they are available to that sacript by calling their identifier,
- //or externally by calling the script name then a dot, then the identifier.
- ffc script foo{
- void run(){
- while ( IsLinkFacingSolid() ) { Waitframe() };
- }
- //script scope
- //Returns true if Link is facing a solid, on-screen combo.
- bool IsLinkFacingSolid(){
- int a; int dir = Link->Dir; int cmb = ComboAt(Link->X, Link->Y);
- int combooffsets[13]={-0x10, 0x10, -1, 1, -0x11, -0x0F, 0x0F, 0x11};
- if ( cmb % 16 == 0 ) combooffsets[9] = 1;
- if ( (cmb & 15) == 1 ) combooffsets[10] = 1;
- if ( cmb < 0x10 ) combooffsets[11] = 1; //if it's the top row
- if ( cmb > 0x9F ) combooffsets[12] = 1; //if it's on the bottom row
- if ( combooffsets[9] && ( dir == CMB_LEFT || dir == CMB_UPLEFT || dir == CMB_DOWNLEFT || dir == CMB_LEFTUP ) ) return false; //if the left columb
- if ( combooffsets[10] && ( dir == CMB_RIGHT || dir == CMB_UPRIGHT || dir == CMB_DOWNRIGHT ) ) return false; //if the right column
- if ( combooffsets[11] && ( dir == CMB_UP || dir == CMB_UPRIGHT || dir == CMB_UPLEFT || dir == CMB_LEFTUP ) ) return false; //if the top row
- if ( combooffsets[12] && ( dir == CMB_DOWN || dir == CMB_DOWNRIGHT || dir == CMB_DOWNLEFT ) ) return false; //if the bottom row
- if ( cmb >= 0 && cmb <= 176 ) a = cmb + combooffsets[dir];
- else a = -1;
- if ( a != -1 ) {
- return ( Screen->isSolid(ComboX(a), ComboY(a)));
- }
- return false;
- }
- //Returns true if Link is facing a solid, on-screen combo, but allows specifying a default return.
- bool IsLinkFacingSolid(bool default_return){
- int a; int dir = Link->Dir; int cmb = ComboAt(Link->X, Link->Y);
- int combooffsets[13]={-0x10, 0x10, -1, 1, -0x11, -0x0F, 0x0F, 0x11};
- if ( cmb % 16 == 0 ) combooffsets[9] = 1;
- if ( (cmb & 15) == 1 ) combooffsets[10] = 1;
- if ( cmb < 0x10 ) combooffsets[11] = 1; //if it's the top row
- if ( cmb > 0x9F ) combooffsets[12] = 1; //if it's on the bottom row
- if ( combooffsets[9] && ( dir == CMB_LEFT || dir == CMB_UPLEFT || dir == CMB_DOWNLEFT || dir == CMB_LEFTUP ) ) return default_return; //if the left columb
- if ( combooffsets[10] && ( dir == CMB_RIGHT || dir == CMB_UPRIGHT || dir == CMB_DOWNRIGHT ) ) return default_return; //if the right column
- if ( combooffsets[11] && ( dir == CMB_UP || dir == CMB_UPRIGHT || dir == CMB_UPLEFT || dir == CMB_LEFTUP ) ) return default_return; //if the top row
- if ( combooffsets[12] && ( dir == CMB_DOWN || dir == CMB_DOWNRIGHT || dir == CMB_DOWNLEFT ) ) return default_return; //if the bottom row
- if ( cmb >= 0 && cmb <= 176 ) a = cmb + combooffsets[dir];
- else a = -1;
- if ( a != -1 ) {
- return ( Screen->isSolid(ComboX(a), ComboY(a)) );
- }
- return default_return;
- }
- }
- //This is how you call a function of a script.
- ffc script bar{
- void run(){
- while ( foo.IsLinkFacingSolid() ) {
- //script name ( dot ) function_identifier()
- Waitframe();
- }
- }
- }
- //YOu cannot have identically named global (file scope) and local (script scope) functions, but you /can/ have
- //identically named SCRiPT-scope functions, so..
- ffc script fum{
- void run(){
- while ( IsLinkFacingSolid() ) { Waitframe(); }
- }
- bool IsLinkFacingSolid(){
- int a; int dir = Link->Dir; int cmb = ComboAt(Link->X, Link->Y);
- int combooffsets[13]={-0x10, 0x10, -1, 1, -0x11, -0x0F, 0x0F, 0x11};
- if ( cmb % 16 == 0 ) combooffsets[9] = 1;
- if ( (cmb & 15) == 1 ) combooffsets[10] = 1;
- if ( cmb < 0x10 ) combooffsets[11] = 1; //if it's the top row
- if ( cmb > 0x9F ) combooffsets[12] = 1; //if it's on the bottom row
- if ( combooffsets[9] && ( dir == CMB_LEFT || dir == CMB_UPLEFT || dir == CMB_DOWNLEFT || dir == CMB_LEFTUP ) ) return false; //if the left columb
- if ( combooffsets[10] && ( dir == CMB_RIGHT || dir == CMB_UPRIGHT || dir == CMB_DOWNRIGHT ) ) return false; //if the right column
- if ( combooffsets[11] && ( dir == CMB_UP || dir == CMB_UPRIGHT || dir == CMB_UPLEFT || dir == CMB_LEFTUP ) ) return false; //if the top row
- if ( combooffsets[12] && ( dir == CMB_DOWN || dir == CMB_DOWNRIGHT || dir == CMB_DOWNLEFT ) ) return false; //if the bottom row
- if ( cmb >= 0 && cmb <= 176 ) a = cmb + combooffsets[dir];
- else a = -1;
- if ( a != -1 ) {
- return ( Screen->isSolid(ComboX(a), ComboY(a)));
- }
- return false;
- }
- }
- //This script will compile with scripts foo and bar, if and only if you do not declare IsLinkFacingSolid()
- //at a file (global) scope.
- //It is up to you to decide which format you want to follow. If you feel that you may need minor variations
- //of a function using the same identifier, such as GetValue() per script, then you put them at the script scope.
- //If the function isn;t likely to change, placing it at a global scope is the best option.
- //Script cope Perks
- //Here is a small workshop on script scope functions
- ffc script data_one{
- void run(){
- }
- int Get(int index){
- int arr[10] = {20, 21, 22, 23, 24, 25, 26, 27, 28, 29};
- return arr[index];
- }
- }
- ffc script data_two{
- void run(){
- }
- int Get(int index){
- int arr[10] = {99, 98, 97, 96, 95, 94, 93, 93, 91, 90};
- return arr[index];
- }
- }
- ffc script get_data{
- void run(int dataset){
- int dat[10];
- if ( dataset == 1 ) {
- for ( int q = 0; q < 10; q++ ) {
- dat[q] = data_one.Get(q); //populate the array with the values in the Get function
- //of script data_one.
- }
- }
- if ( dataset == 2 ) {
- for ( int q = 0; q < 10; q++ ) {
- dat[q] = data_two.Get(q);//populate the array with the values in the Get function
- //of script data_two.
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement