PDA

View Full Version : Need "Item Checking" Script ASAP



Majora
12-26-2006, 11:00 PM
Yea, Like the Room Type "Level 9 Entrance" except that this the script makes the room "Check for X Sword" where "X" is:

The White sword
The Magic Sword
The Master Sword

3 seperate scripts, 1 for each sword, and should work like this:

You enter the first room of a dungeon and a guy with a string says "You can only advance if you have the proper weapon. Do you hav it?" the script tells the guy to check for the white sword (or one of the other 2) and if you have it, he says "Very well, you are prepared for the challenge ahead, you may pass" and he disappears.

Or something like that, the basic concept is "Check for X sword:
-> sword is present ->go to string X -> allow passage
->sword not present->go to string Y ->deny passage"

Or however that translates into scripting lingo, just trying to sound techno-logically advanced:tongue:.


Thanks in advance.

The_Amaster
12-27-2006, 12:19 AM
This would be great for any item. If someone decides to do this, any way the script could have a section where it specifies item class and number. Only I need the same thing, only it checks for Slash and Spin attack. (And yes, I'm making an item that you get when you get slash to act as a marker)

C-Dawg
12-27-2006, 12:09 PM
Here.



// =====================
// check_item - This script will
// execute only if Link has an item
// specified by the D0 variable of
// this FFC. Refer to std.zh for the
// list of item numbers.
// =====================
ffc script check_item{
void run( int item ){
if ( Link->Item[item]){

// --- insert what you want to happen here ---

} // end of if
} end of void run
} end of ffc script

The_Amaster
12-27-2006, 12:27 PM
Soo..what do we enter in the brackets. Item name, or class and level, or what? And what code would we use to make it a pass or impass thing? I know once L implements the callString(or whatever), we could display messages too.

Majora
12-27-2006, 12:33 PM
Cool, thanks C-Dawg. I will try it out

EDIT: cant get it to work (I know absolutely NOTHING of scripting)
this is what it looks like when i go to Tools ->compile Z-script->import->compile! :(




// =====================
// check_item - This script will
// execute only if Link has an item
// specified by the D0 variable of
// this FFC. Refer to std.zh for the
// list of item numbers.
// =====================
ffc script check_item{
void run( int item ){
if ( Link->Item[6]){

// --- NPC 2 Disappears---

} // end of if
} end of void run

C-Dawg
12-28-2006, 11:13 AM
Heh. Let me guess, it compiles but does nothing?

The line I typed stating: "// --- insert what you want to happen here --" is a filler and a comment. The compiler will ignore anything on a line after "//". You can't actually type in what you want to happen in english. You have to replace the entire line with the code accomplishing what you want.

I'm not sure what you want to accomplish by the NPC moving away. There isn't a "destroy NPC" command that I'm aware of. So you can either set its hit points to zero, or move it off the screen. This code will do both.



// =====================
// check_item - This script will
// execute only if Link has an item
// specified by the D0 variable of
// this FFC. Refer to std.zh for the
// list of item numbers.
// =====================
ffc script check_item{
void run( int item ){
if ( Link->Item[item]){

npc NPC_to_disappear = Screen->LoadNPC(2); // this will load up
// npc 2 into a variable
// "NPC_to_dissapear."
NPC_to_dissapear->X = 300; // moves NPC off of the screen
NPC_to_dissapear->HP = 0; // sets NPC hp to zero.
} // end of if
} end of void run
} end of ffc script

Majora
12-28-2006, 12:18 PM
Just for clarification, These are the steps I will do:

Copy and paste into a .txt(notepad) file
Change file extension rom .txt to .z
Go into ZQuest
Go to the room I need this script for
Go to Tools?-> Compile ZScript
Click import
Find the file that was a .txt but I changed to .z
click "Edit"
in the part that reads "if (link-> item[Item]" I will put "if (link->item[6]"

thats what I will do, can I do that?

C-Dawg
12-28-2006, 05:12 PM
Well... why not do this.

(1) Copy and paste the script into a wordpad file.
(2) Ensure it says "Link->Item[item]". CAPITALIZATION MATTERS.
(3) Save as a .z instead of .txt, just as you said.
(4) Open your quest in Zquest. Go to Tools->Compile, import, choose your script.
(5) Click the compile button. If there are no errors, the code will compile and you will be presented with a screen where you can set your script to a numbered FFC slot. Set it to the first open slot, remember this number.
(6) Go to the room on which you would like the script to execute. Make an FFC and place it where you want Link to stand. Now, while you're editing that FFC, select the FFC script slot you chose in step (5) in the lower right box. It's labeled "script," I believe. Lastly, click on "Data" and put the item number you want into D0.

If it compiles correctly, this should work. Code could have typos, though.

Majora
12-28-2006, 07:21 PM
Did all the steps you said but when I hit "Compile!" I get this message


Pass 1: Parsing
Line 2: Syntax Error, Unexpexted Item, Expecting Identifier,
on Token Item.
Fatal Error P00: Can't open or Parse input file!"


EDIT: Will do those steps again, but double checking each step of the way, I will edit this post after I try again.

EDIT2: It finally worked! (Compiling at least) All I had to do was get rid of all those "=" and put the code all on one line! Thanks C-Dawg!

C-Dawg
01-01-2007, 11:20 PM
Well, the error your getting is because you can't use "item" as a variable name. My bad. Try this:



// =====================
// check_item - This script will
// execute only if Link has an item
// specified by the D0 variable of
// this FFC. Refer to std.zh for the
// list of item numbers.
// =====================
ffc script check_item{
void run( int item_to_check ){
if ( Link->Item[item_to_check]){

npc NPC_to_disappear = Screen->LoadNPC(2); // this will load up
// npc 2 into a variable
// "NPC_to_dissapear."
NPC_to_dissapear->X = 300; // moves NPC off of the screen
NPC_to_dissapear->HP = 0; // sets NPC hp to zero.
} // end of if
} end of void run
} end of ffc script


The issue is, I think, that "item" is a reserved word in ZScript. It's like "int" or "ffc" in that it is an object type. So you can't use it for other names.