Read-only archive of the Armageddon Games Forums Archive (2000–2026) · About this archive

Detecting Selected Item

7 replies · 2,139 views · Started 07 July 2007

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.

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();
}
}
}

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

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 😕

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..

It just flips the value in flag. ! is the "not" operator. So, if flag is true, then !flag (not flag = not true) == false.