Jump to content

Photo

Item check -> Door Type Change Script


  • Please log in to reply
8 replies to this topic

#1 Zephlon

Zephlon

    Experienced Forumer

  • Members

Posted 31 December 2007 - 10:18 AM

I'm tring to make a script that will change the door types of the current screen if Link has a certain item.

CODE
// Item check -> Door Type Change Script
// By Mega Link
//
// Arguments:
// D0 = ID of item to check for.
// D1 = top door type
// D2 = left door type
// D3 = right door type
// D4 = bottom door type
//
// Door Types:
// 0 = Wall
// 1 = Open/Passage
// 2 = Locked
// 3 = Unlocked
// 4 = Shuttered
// 6 = Bombable
// 7 = Bombed
// 8 = Walk Thourgh
// 10 = Boss Locked
// 11 = Boss Unlocked
// 12 = Open Shutter
// 14 = One Way Shutter

ffc script itemshutters {

void run(int itemID, int doorup, int doorleft, int doorright, int doordown)
    {
    if (Link->Item[itemID] == true)
        {
        Screen->Door[DIR_UP] = doorup;
        Screen->Door[DIR_LEFT] = doorleft;
        Screen->Door[DIR_RIGHT] = doorright;
        Screen->Door[DIR_DOWN] = doordown;
        }
    }
}


But it changes the door regardless of Link having the item or not, and it thinks the int door* variables are bools.
__________________

Edited by Mega Link, 31 December 2007 - 10:48 AM.


#2 Gleeok

Gleeok

    It's dangerous to dough alone, bake this.

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

Posted 31 December 2007 - 11:33 AM

I don't know why it would do that. For comparison, here is one of the first scripts I ever made:

ffc script random_door_generator{ //ver2.1

void run(){

int ddoor = 0;
int udoor = 0;
int ldoor = 0;
int rdoor = 0;
int RandNum = Rand(4);

if (Link->Dir == 0 && Screen->Door[DIR_DOWN] == D_WALL){ ddoor = 1;}
if (Link->Dir == 1 && Screen->Door[DIR_UP] == D_WALL){ udoor = 1;}
if (Link->Dir == 2 && Screen->Door[DIR_RIGHT] == D_WALL){ rdoor = 1;}
if (Link->Dir == 3 && Screen->Door[DIR_LEFT] == D_WALL){ ldoor = 1;}

if (RandNum == 0 && Screen->Door[DIR_DOWN] == D_WALL){ Screen->Door[DIR_DOWN] = D_SHUTTER;}
if (RandNum == 0 && Screen->Door[DIR_UP] == D_WALL){Screen->Door[DIR_UP] = D_SHUTTER;}
if (RandNum == 1 && Screen->Door[DIR_RIGHT] == D_WALL){Screen->Door[DIR_RIGHT] = D_SHUTTER;}
if (RandNum == 1 && Screen->Door[DIR_LEFT] == D_WALL){Screen->Door[DIR_LEFT] = D_SHUTTER; }
if (RandNum == 2 && Screen->Door[DIR_DOWN] == D_WALL){Screen->Door[DIR_DOWN] = D_SHUTTER;}
if (RandNum == 2 && Screen->Door[DIR_UP] == D_WALL){Screen->Door[DIR_UP] = D_SHUTTER;}
if (RandNum == 2 && Screen->Door[DIR_RIGHT] == D_WALL){Screen->Door[DIR_RIGHT] = D_SHUTTER;}
if (RandNum == 3 && Screen->Door[DIR_LEFT] == D_WALL){Screen->Door[DIR_LEFT] = D_SHUTTER;}
if (RandNum == 3 && Screen->Door[DIR_RIGHT] == D_WALL){Screen->Door[DIR_RIGHT] = D_SHUTTER;}
if (RandNum == 3 && Screen->Door[DIR_UP] == D_WALL){Screen->Door[DIR_UP] = D_SHUTTER; }

if (ddoor == 1){Screen->Door[DIR_DOWN] = D_1WAYSHUTTER;}
if (udoor == 1){Screen->Door[DIR_UP] = D_1WAYSHUTTER;}
if (rdoor == 1){Screen->Door[DIR_RIGHT] = D_1WAYSHUTTER;}
if (ldoor == 1){Screen->Door[DIR_LEFT] = D_1WAYSHUTTER; }
}
}


They're not boolean, It looks right on first glance.


EDIT; Oh, I think there was a door bug in one of the newer builds, that might be a problem also.

Also you imported std.zh right? Doesn't hurt to ask.

Edited by Gleeok, 31 December 2007 - 11:37 AM.


#3 Zephlon

Zephlon

    Experienced Forumer

  • Members

Posted 31 December 2007 - 01:56 PM

QUOTE(Gleeok @ Dec 31 2007, 10:33 AM) View Post
Also you imported std.zh right? Doesn't hurt to ask.


Yes. I took that script out of the main file.


Would doing this fix the problem where it changes the door regardless of Link having the item or not?

CODE
// Item check -> Door Type Change Script
// By Mega Link
//
// Arguments:
// D0 = ID of item to check for.
// D1 = top door type
// D2 = left door type
// D3 = right door type
// D4 = bottom door type
//
// Door Types:
// 0 = Wall
// 1 = Open/Passage
// 2 = Locked
// 3 = Unlocked
// 4 = Shuttered
// 6 = Bombable
// 7 = Bombed
// 8 = Walk Thourgh
// 10 = Boss Locked
// 11 = Boss Unlocked
// 12 = Open Shutter
// 14 = One Way Shutter

ffc script itemshutters {

void run(int itemID, int doorup, int doorleft, int doorright, int doordown)
    {
    if (Link->Item[itemID] == true)
        {
        Screen->Door[DIR_UP] = doorup;
        Screen->Door[DIR_LEFT] = doorleft;
        Screen->Door[DIR_RIGHT] = doorright;
        Screen->Door[DIR_DOWN] = doordown;
        }
    else {void quit()}
    }
}


#4 Joe123

Joe123

    Retired

  • Members

Posted 31 December 2007 - 01:58 PM

Are you allowed to put 'void Quit();'?

I thought it was just 'Quit();'?

Does it compile like that?

#5 Zephlon

Zephlon

    Experienced Forumer

  • Members

Posted 01 January 2008 - 12:25 PM

I got a compile time error:

http://i210.photobuc..._Link/cp001.jpg

Edited by Mega Link, 01 January 2008 - 12:28 PM.


#6 Joe123

Joe123

    Retired

  • Members

Posted 01 January 2008 - 02:07 PM

CODE
ffc script itemshutters {
    void run(int itemID, int doorup, int doorleft, int doorright, int doordown){
        if(Link->Item[itemID] == true){
            Screen->Door[DIR_UP] = doorup;
            Screen->Door[DIR_LEFT] = doorleft;
            Screen->Door[DIR_RIGHT] = doorright;
            Screen->Door[DIR_DOWN] = doordown;
        }
    }
}


The 'else quit' bit was unnecessary, if a script gets to the end without hitting a loop it'll quit anyway.

Try that one.

Edited by Joe123, 01 January 2008 - 02:07 PM.


#7 Zephlon

Zephlon

    Experienced Forumer

  • Members

Posted 01 January 2008 - 03:08 PM

Nope. Link doesn't have the item, and all of the doors open.

#8 Joe123

Joe123

    Retired

  • Members

Posted 01 January 2008 - 03:38 PM

I only fixed the compile errors, I don't know how/why it doesn't work, sorry.

#9 Gleeok

Gleeok

    It's dangerous to dough alone, bake this.

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

Posted 01 January 2008 - 09:45 PM

CODE
import "std.zh"
ffc script itemshutters {
    void run(int itemID, int doorup, int doorleft, int doorright, int doordown){
        if(Link->Item[254]){
            Screen->Door[DIR_UP] = doorup;
            Screen->Door[DIR_LEFT] = doorleft;
            Screen->Door[DIR_RIGHT] = doorright;
            Screen->Door[DIR_DOWN] = doordown;
        }
    }
}


If this doesn't work then you're a screwed.

If it does then just change the 254 to itemid. You need std.zh for this.


1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users