PDA

View Full Version : Detecting Selected Item



ShadowMancer
07-07-2007, 02:25 PM
Is there any way to detect what item is currently selected for B button. I would like to make a sheild item that has effect only when selected.
So bassicaly when the sheild item is selected I will use a script to give Link the sheild, then take it away again when not selected. I know FFC Item scripts only run for one frame so I will need to use a FFc that follows Link from screen to screen and checks for the selected item. Any help would be appricated.

Dan Furst
07-07-2007, 03:14 PM
There is no way to tell what item is selected in "B".

I think the best you're going to get is to have Link use the item (press B once) and then the item becomes active until B is pressed again. That way, if any other item is used, the shield goes away.

I would do it like this
bool flag = false;

item script shield{
void run()
{
flag = !flag;
}
}

ffc script do_shield{
void run()
{
while(true)
{
if(flag)
{
// activate shield

if(Link->InputB)
{
flag = false;
// deactivate shield;
}
}
Waitframe();
}
}
}

Master_of_Power
07-07-2007, 03:34 PM
Doesn't it detect whether you hold down the button too?

Well, either way, this is a pretty decent start to getting it consistant with Gameboy style Zeldas

ShadowMancer
07-09-2007, 12:09 AM
Yes I think that option will work for my quest, all I have to do is make it take MP while in use, this way it works like a switch. I have not tested the script yet but it looks good, just one question what exactly does this line do?

flag = !flag;

it looks like it would set bool flag to false.. mabye :confused:

thanks for the script and the idea, I am going to do a similar thing with my 'Elven Armor' item, when activated acts as a red ring and takes MP when not activated acts as a blue ring..

pkmnfrk
07-09-2007, 06:47 AM
It just flips the value in flag. ! is the "not" operator. So, if flag is true, then !flag (not flag = not true) == false.

Dan Furst
07-09-2007, 09:53 AM
Right, the long way of doing it is

if(flag == true) flag = false;
else flag = true;

Fire Wizzrobe
07-31-2007, 06:28 PM
Can global variables be accessed on any screen?

C-Dawg
07-31-2007, 07:06 PM
Yes, by any script.