Jump to content

Photo

ZScript Quest


  • Please log in to reply
4 replies to this topic

#1 LinktheMaster

LinktheMaster

    Hey Listen, Kid

  • Members
  • Real Name:Matt
  • Location:United States

Posted 09 June 2008 - 07:53 AM

Well, I've been bored lately, so I decided to try messing around with ZScript. Overall, nothing really seems to hard about the scripting language. However, what I'm not sure about is the method in which Zelda Classic interacts with ZScripts.

From what I gather, there are three types of ZScripts. FFC, Global, and Item. From what I understand, FFC and item scripts both only take place right when the item or FFC is created on the screen, and global scripts are limited to specific times. However, I'm wondering how you go about creating a script which can take place at any time, multiple times.

Let's say, for example, I want to create an arrow script that will home in on an enemy. In order to do that, a script will constantly modify the arrow's position in order to go closer to the enemy. I can do the math, it's just figuring out how to make a script that will continuously be ran. icon_razz.gif

Any help would be appreciated. I probably could have figured something out if I had been able to find enough example scripts, but I didn't find any that helped in this forum.

Edit: I made a typo in the title. icon_frown.gif I miss being able to go back and edit those.

Edited by LinktheMaster, 09 June 2008 - 07:55 AM.


#2 AgentLym

AgentLym

    • Zelda and Pokémon Master •

  • Members
  • Location:Skyloft

Posted 09 June 2008 - 09:37 AM

Hm... well, I'm not the best scripter so I'm not totally sure how to make an arrow that homes in on enemies, but...

To make a script constantly run, you'll have to have a 'while()' loop in it somewhere.

I know that's not a very good explanation... Sorry 'bout that. For some help, go HERE

I'm still learning, but this is where I usually get most of my references and such.

Hope that helps!

Edited by AgentLym, 09 June 2008 - 09:37 AM.


#3 LinktheMaster

LinktheMaster

    Hey Listen, Kid

  • Members
  • Real Name:Matt
  • Location:United States

Posted 09 June 2008 - 09:46 AM

Yeah, I've been trying to use the while(true) and Waitframe(), but I still can't seem to get items to be modified more than once.

Still, thanks anyway.

#4 Joe123

Joe123

    Retired

  • Members

Posted 09 June 2008 - 10:27 AM

You've creating 'weapon sprites' or 'lweapons', not 'items'.

An item is something Link can pick up; an lweapon is something that damages enemies.


CODE
item script homing bow{
    void run(){
        bowattack = true;
    }
}

bool bowattack;

global script slot_2{
    void run(){
        while(true){
            if(bowattack){
                //sort out some homing arrow code here
            bowattack = false;
            }
        Waitframe();
        }
    }
}


Bit of a pseudo-code for you.

Item scripts only run for one frame.

Edited by Joe123, 09 June 2008 - 10:28 AM.


#5 LinktheMaster

LinktheMaster

    Hey Listen, Kid

  • Members
  • Real Name:Matt
  • Location:United States

Posted 09 June 2008 - 10:32 AM

QUOTE(Joe123 @ Jun 9 2008, 10:27 AM) View Post

You've creating 'weapon sprites' or 'lweapons', not 'items'.

An item is something Link can pick up; an lweapon is something that damages enemies.
CODE
item script homing bow{
    void run(){
        bowattack = true;
    }
}

bool bowattack;

global script slot_2{
    void run(){
        while(true){
            if(bowattack){
                //sort out some homing arrow code here
            bowattack = false;
            }
        Waitframe();
        }
    }
}


Bit of a pseudo-code for you.

Item scripts only run for one frame.

Dang. I actually just figured that part out RIGHT before you posted this. And yeah, I meant lweapon before. Sorry. Anyway, thank you very much. icon_smile.gif


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users