Jump to content

Photo

Anything wrong with these scripts?


  • Please log in to reply
21 replies to this topic

#1 Majora

Majora

    Unironic Marxist-Leninist

  • Members

Posted 30 October 2007 - 09:11 PM

This script is for the 3 Feather items in my quest (Roc's Feather, Roc's Silver Feather, Roc's Golden Feather). What it's supposed to do is when you acquire either the Silver (Level 2 item, uses some magic per use) or Golden (Level 3, uses more magic per use), the script kicks in. When you lack the sufficient Magic to use one of the feathers, it reverts to the previous level feather.

CODE

//Global varible
int FEATHER_LEVEL = 0 //you will need to chance this varible when you aquire a new feather

//just add this simple code to you item pickup for each feather
item script feather1{
void run() {
FEATHER_LEVEL = 1;
}
}

item script feather2{
void run() {
FEATHER_LEVEL = 2;
}
}

item script feather3{
void run() {
FEATHER_LEVEL = 3;
}
}
//NOTE you will need to replace ***1 with the ID for feather 1, ***2 w/2 and ***3 w/3

global script main_script {
void run() {
if (FEATHER_LEVEL >= 2 && Link->MP < 32) {
Link->Item[252] = false;
Link->Item[253] = true;
}
if (FEATHER_LEVEL >= 1 && Link->MP < 16) {
Link->Item[253] = false;
Link->Item[91] = true;
}
if (FEATHER_LEVEL == 2 && Link->MP >= 16) {
Link->Item[253] = true;
}
if (FEATHER_LEVEL == 3 && Link->MP >= 32) {
Link->Item[252] = true;
}
}
}




#2 Joe123

Joe123

    Retired

  • Members

Posted 31 October 2007 - 03:03 AM

This looks as though it should work, have you set it up properly?
You know that the first integer in the script is declared outside of all scripts, and that you can only have one global script, right? So if you're using the global script for other things also, you'll have to compile them all into one.

Also, if you tell me the numbers of each level of feather (I'm asuming 91 is level 1, but I'm not sure of the two others) then I might be able to have a better look at it.

#3 Gleeok

Gleeok

    It's dangerous to dough alone, bake this.

  • Members
  • Real Name:Pillsbury
  • Location:Magical Land of Dough

Posted 31 October 2007 - 06:53 AM

Well that won't do at all.


CODE

int FEATHER_LEVEL = 0

global script main_script {

    void run() {

        while(true){

            if(FEATHER_LEVEL == 2){
                if(Link->MP <16){
                    Link->Item[2] = false;
                    Link->Item[1] = true;
                }
                else{
                    Link->Item[2]= true;
                }
            }
            if(FEATHER_LEVEL == 3){
                if(Link->MP <16){
                    Link->Item[3] = false;
                    Link->Item[2] = false;
                    Link->Item[1] = true;
                if(Link->MP <32 && Link->MP>=16){
                    Link->Item[3] = false;
                    Link->Item[2] = true;
                    Link->Item[1] = false;
                }
                else{
                    Link->Item[3]= true;
                }
            }
        Waitframe();
        }
    }
}



//PS: you may wan't to doublecheck your numbers for your item script thingy there.



item script feather1{

    void run() {

    if(FEATHER_LEVEL == 0){FEATHER_LEVEL=1;}

    }
}




Remember, it's logic. Saying x=2 then saying x=3 will make x=3.


#4 Majora

Majora

    Unironic Marxist-Leninist

  • Members

Posted 18 November 2007 - 10:35 PM

Level 1 feather is 91
Level 2 feather is 253
Level 3 feather is 252

also, I'll try Gleeok's script. Anything I need to edit myself? or is it grab-and-go?

#5 Gleeok

Gleeok

    It's dangerous to dough alone, bake this.

  • Members
  • Real Name:Pillsbury
  • Location:Magical Land of Dough

Posted 19 November 2007 - 06:25 AM

I streamlined it a little, use this one. Just replace Item[1][2][3] with their correct values.
CODE

int FEATHER_LEVEL = 0

global script main_script {

    void run() {

        while(true){

            if(Link->InputA || Link->InputB){

            if(FEATHER_LEVEL == 2){
                if(Link->MP <16){
                    Link->Item[2] = false;
                    Link->Item[1] = true;
                }
                else{
                    Link->Item[2]= true;
                }
            }
            if(FEATHER_LEVEL == 3){
                if(Link->MP <16){
                    Link->Item[3] = false;
                    Link->Item[2] = false;
                    Link->Item[1] = true;
                if(Link->MP <32 && Link->MP>=16){
                    Link->Item[3] = false;
                    Link->Item[2] = true;
                    Link->Item[1] = false;
                }
                else{
                    Link->Item[3]= true;
                }
            }}
        Waitframe();
        }
    }
}

item script feather1{

    void run() {

    if(FEATHER_LEVEL == 0){FEATHER_LEVEL=1;}

    }
}
item script feather2{

    void run() {

    if(FEATHER_LEVEL < 2){FEATHER_LEVEL=2;}

    }
}
item script feather3{

    void run() {

    if(FEATHER_LEVEL < 3){FEATHER_LEVEL=3;}

    }
}



Edited by Gleeok, 19 November 2007 - 06:26 AM.


#6 Majora

Majora

    Unironic Marxist-Leninist

  • Members

Posted 19 November 2007 - 06:42 AM

IPB Image


Lines 1-10 in the script:

CODE

import "std.zh"

int FEATHER_LEVEL = 0

global script main_script {

    void run() {

        while(true){
........


#7 Gleeok

Gleeok

    It's dangerous to dough alone, bake this.

  • Members
  • Real Name:Pillsbury
  • Location:Magical Land of Dough

Posted 19 November 2007 - 08:58 AM

Well hey, what's one of these thingies for anyway? ...";"

#8 Joe123

Joe123

    Retired

  • Members

Posted 19 November 2007 - 12:19 PM

Lines showing commands (like setting an integer, giving Link an item etc.) should end in a semi colon, otherwise it won't compile at all.

#9 Majora

Majora

    Unironic Marxist-Leninist

  • Members

Posted 20 November 2007 - 07:21 AM

So where should the semicolon go? I tried various places and I still keep getting syntax errors.

#10 Joe123

Joe123

    Retired

  • Members

Posted 20 November 2007 - 12:18 PM

Heh, that's what you get for not being specific enough eh Gleeok?
Seems to be rather frequent in your posts nowadays icon_razz.gif

However if you don't understand it then fair enough:

CODE
import "std.zh"

int FEATHER_LEVEL = 0;

global script main_script {
    void run() {
        while(true){
            if(FEATHER_LEVEL == 2){
                if(Link->MP <16){
                    Link->Item[2] = false;
                    Link->Item[1] = true;
                }else{
                    Link->Item[2]= true;
                }
            }
            if(FEATHER_LEVEL == 3){
                if(Link->MP <16){
                    Link->Item[3] = false;
                    Link->Item[2] = false;
                    Link->Item[1] = true;
                if(Link->MP <32 && Link->MP>=16){
                    Link->Item[3] = false;
                    Link->Item[2] = true;
                    Link->Item[1] = false;
                }else{
                    Link->Item[3]= true;
                }
            }
        Waitframe();
        }
    }
}


Checking through that, I don't think there should be any syntax errors.

EDIT: The semicolon was after the first line by the way, in case you're interested.

Edited by Joe123, 20 November 2007 - 12:19 PM.


#11 Gleeok

Gleeok

    It's dangerous to dough alone, bake this.

  • Members
  • Real Name:Pillsbury
  • Location:Magical Land of Dough

Posted 21 November 2007 - 12:17 AM

Hey, I make no claims that my scripts will be typo free. But you know Majora, It tells you the line that wont compile. If it's not that line, there's a good chance it's the line before it. You should see my .z file when I get an error on line 5237, truncation error, cant cast to float...I get pissed trying to track typos down. Sometimes it's because I forgot a brace 100 lines prior. Or I get a complex web of integers going, then the script does absolutely nothing....wow, that's fun.

Edited by Gleeok, 21 November 2007 - 12:21 AM.


#12 Majora

Majora

    Unironic Marxist-Leninist

  • Members

Posted 23 November 2007 - 02:52 AM

I'm mad at you Gleeok icon_glare.gif


......
.....
....
...
..
.



Well, I would be if you were a robot. icon_razz.gif Anywho, thanks, both of you's. icon_biggrin.gif


*opens ZQuest and NotePad*

#13 Majora

Majora

    Unironic Marxist-Leninist

  • Members

Posted 23 November 2007 - 11:18 AM

Here is my entire quest.z file, please scan for errors:
CODE

import "std.zh"

int FEATHER_LEVEL = 0;

global script main_script {
    void run() {
        while(true){
            if(FEATHER_LEVEL == 2){
                if(Link->MP <16){
                    Link->Item[253] = false;
                    Link->Item[91] = true;
                }else{
                    Link->Item[253]= true;
                }
            }
            if(FEATHER_LEVEL == 3){
                if(Link->MP <16){
                    Link->Item[252] = false;
                    Link->Item[253] = false;
                    Link->Item[91] = true;
                if(Link->MP <32 && Link->MP>=16){
                    Link->Item[252] = false;
                    Link->Item[253] = true;
                    Link->Item[91] = false;
                }else{
                    Link->Item[252]= true;
                }
            }
        Waitframe();
        }
    }
}

item script feather1{

    void run() {

    if(FEATHER_LEVEL == 0){FEATHER_LEVEL=1;}

    }
}
item script feather2{

    void run() {

    if(FEATHER_LEVEL < 2){FEATHER_LEVEL=2;}

    }
}
item script feather3{

    void run() {

    if(FEATHER_LEVEL < 3){FEATHER_LEVEL=3;}

    }
}

Edited by Majora, 23 November 2007 - 12:46 PM.


#14 Joe123

Joe123

    Retired

  • Members

Posted 23 November 2007 - 12:22 PM

I take it it doesn't work then?
Does it compile properly, but just not work properly?

And can you put '[code=auto:0]...[/ code]' around the script, because it's really hard to read when it's not spaced out in tiers.

#15 Majora

Majora

    Unironic Marxist-Leninist

  • Members

Posted 23 November 2007 - 12:47 PM

http://img34.picoodl...mmm_751b081.png


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users