Jump to content

Photo

FFC that detects if you have a particular item


  • Please log in to reply
25 replies to this topic

#16 MoscowModder

MoscowModder

    Sometimes lurking. Rarely posting.

  • Members
  • Location:Wisconsin

Posted 07 February 2013 - 08:09 PM

Different errors are caught at different stages in the compiling process. Catching an error makes the compiler stop after the current stage finishes.

#17 Anthus

Anthus

    Lord of Liquids

  • Members
  • Location:Ohio

Posted 07 February 2013 - 11:33 PM

Could I possibly use this script too please? String control codes are fine if you have a Guy, but this works nicely if you don't have a Guy, or NPC on screen.

#18 MoscowModder

MoscowModder

    Sometimes lurking. Rarely posting.

  • Members
  • Location:Wisconsin

Posted 07 February 2013 - 11:52 PM

Any script I write for request can be considered free for the taking unless it's very specific to the design of the requester's project, in which case you'd want to ask them.

In this case, you can just go ahead and take it.

#19 Anthus

Anthus

    Lord of Liquids

  • Members
  • Location:Ohio

Posted 08 February 2013 - 12:11 AM

QUOTE(MoscowModder @ Feb 7 2013, 11:52 PM) View Post

Any script I write for request can be considered free for the taking unless it's very specific to the design of the requester's project, in which case you'd want to ask them.

In this case, you can just go ahead and take it.


Ok, that makes sense icon_smile.gif

Thanks a lot, this is pretty cool. I'll post if I need any help setting it up, but I think I got it.

#20 Jamian

Jamian

    ZC enthusiast

  • Members

Posted 08 February 2013 - 10:20 AM

QUOTE(MoscowModder @ Feb 7 2013, 07:09 PM) View Post

Different errors are caught at different stages in the compiling process. Catching an error makes the compiler stop after the current stage finishes.


Thanks, it compiles now. I had actually removed the faulty bit myself in the first script, but had forgotten about it.

Edited by Jamian, 08 February 2013 - 10:22 AM.


#21 Anthus

Anthus

    Lord of Liquids

  • Members
  • Location:Ohio

Posted 15 February 2013 - 02:20 AM

I was wondering if there was anyway this script could be modified to check if you have three different items (and if you don't nothing happens)?

The context is, I want to have a "gate" that checks if you have three items before entering to get the super awesome plot sword. icon_biggrin.gif

This would be greatly appreciated.

#22 Russ

Russ

    Caelan, the Encouraging

  • Administrators
  • Location:Washington

Posted 15 February 2013 - 02:28 AM

Easy enough, just a quick little change to the original script...

CODE
ffc script stepWithItem{
    void run(int triggerItem, int triggerItem2, int triggerItem3 ){
        while(!Screen->State[ST_SECRET]){
            if ( Link->Item[triggerItem] && Link->Item[triggerItem2] && Link->Item[triggerItem3] && DistanceLink(this->X+8, this->Y+8) <= 8 ){
                Screen->TriggerSecrets();
                Screen->State[ST_SECRET] = true;
                Game->PlaySound(SFX_SECRET);
            }
        Waitframe();
        }
    }
}

//Returns distance to Link's center
int DistanceLink ( int x, int y ){
    return Distance ( Link->X+8, Link->Y+8, x, y );
}


D0, D1, and D2 are the IDs for the three items you want the script to check for. And credit goes to MoscowModder for writing it, since the change I made is pretty much insignificant.

#23 Anthus

Anthus

    Lord of Liquids

  • Members
  • Location:Ohio

Posted 15 February 2013 - 03:29 AM

QUOTE(Russ @ Feb 15 2013, 02:28 AM) View Post

Easy enough, just a quick little change to the original script...

CODE
ffc script stepWithItem{
    void run(int triggerItem, int triggerItem2, int triggerItem3 ){
        while(!Screen->State[ST_SECRET]){
            if ( Link->Item[triggerItem] && Link->Item[triggerItem2] && Link->Item[triggerItem3] && DistanceLink(this->X+8, this->Y+8) <= 8 ){
                Screen->TriggerSecrets();
                Screen->State[ST_SECRET] = true;
                Game->PlaySound(SFX_SECRET);
            }
        Waitframe();
        }
    }
}

//Returns distance to Link's center
int DistanceLink ( int x, int y ){
    return Distance ( Link->X+8, Link->Y+8, x, y );
}


D0, D1, and D2 are the IDs for the three items you want the script to check for. And credit goes to MoscowModder for writing it, since the change I made is pretty much insignificant.


Thanks a lot icon_smile.gif I will credit both of you. I have a pretty comprehensive list of all scripts I've used so far. This is awesome.

EDIT: Oops, I ran into an error while compiling. It says: "scripts\stepwithitem.z, Error S10: Function Distance Is Undeclared."

Edited by Anthus, 15 February 2013 - 02:34 PM.


#24 Anthus

Anthus

    Lord of Liquids

  • Members
  • Location:Ohio

Posted 16 February 2013 - 01:34 PM

I just wanted to say, I actually got the modified script working (needed std.zh in my script file), but the single one won't compile,

IPB Image

EDIT: Wait a sec, I saved it wrong >.> Okay, I got it saved as a .z file now, my bad.

But, it still won't compile. My thought was, since there is another very similar script, it might not work right. (Since the three one worked).

IPB Image

Edited by Anthus, 16 February 2013 - 01:42 PM.


#25 Saffith

Saffith

    IPv7 user

  • Members

Posted 16 February 2013 - 02:11 PM

And that's why you shouldn't use global functions more than necessary. icon_razz.gif This should do:

CODE
ffc script stepWithItem{
    void run(int triggerItem, int triggerItem2, int triggerItem3 ){
        while(!Screen->State[ST_SECRET]){
            if ( Link->Item[triggerItem] && Link->Item[triggerItem2] && Link->Item[triggerItem3] && SWI_DistanceLink(this->X+8, this->Y+8) <= 8 ){
                Screen->TriggerSecrets();
                Screen->State[ST_SECRET] = true;
                Game->PlaySound(SFX_SECRET);
            }
        Waitframe();
        }
    }
    
    //Returns distance to Link's center
    int SWI_DistanceLink ( int x, int y ){
        return Distance ( Link->X+8, Link->Y+8, x, y );
    }
}


In this case, the function name had to be changed , or it would fail for the same reason, even though it's no longer global. The renaming is unnecessary if you also adjust whatever other script defines that function.
(The function could also just have been deleted, since it already exists, but then it would depend on that other script.)

#26 Anthus

Anthus

    Lord of Liquids

  • Members
  • Location:Ohio

Posted 19 February 2013 - 05:32 PM

Thanks, that one works now icon_smile.gif


1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users