tol'ja so
Eh, nevermind Zoria's post.
Needs a global script and an active item script. Set the constant to the item ID of your boomerang.
import "std.zh"
const int BoomerangID = 123; //set number to boomerang item ID
global script Active{
void run(){
while(true){
if ( Game->Counter[CR_SCRIPT1] == 0 ) {
if ( GetEquipmentA() == BoomerangID )
Link->InputA = false;
if ( GetEquipmentB() == BoomerangID )
Link->InputB = false;
}
Waitframe();
}
}
}
item script BoomerangActive{
void run(){
Game->Counter[CR_SCRIPT1] --;
}
}
This is untested but should do.
Aye, obviously it was this simple.
Tol'ja.
You can get
most of the way there with these hacks, but, not in a 'foolproof' way.
If you want something better:
const int SFX_ERROR = 63;
//Call before Waitdraw() in the infinite loop of your active script.
//It might suffice.
void BoomerangCancel()
{
int iA = GetEquipmentA(); int iB = GetEquipmentB();
itemdata idA = Game->LoadItemData(iA);
itemdata idB = Game->LoadItemData(iB);
int icA = idA->Class; int icB = idB->Class;
if ( Link->PressA() )
{
if ( icA == IC_BRANG )
{
if ( Game->Counter[CR_SCRIPT1] > 0 )
{
--Game->Counter[CR_SCRIPT1];
}
else { Link->PressA = false; Game->PlaySound(SFX_ERROR); }
}
}
if ( Link->PressB )
{
if ( icB == IC_BRANG )
{
if ( Game->Counter[CR_SCRIPT1] > 0 )
{
--Game->Counter[CR_SCRIPT1];
}
else { Link->PressB = false; Game->PlaySound(SFX_ERROR); }
}
}
}
This may do what you want. The only way to interrupt using the brang itemclass items is to cancel button presses,
however, this can also cancel buttoninputs needed by other scripts, and cause conflicts. (
e.g., If you have a script that reads pressing A, or B, to talk to an NPC.)
Fully scripting the item is the only way to do what Cukeman wants, without a chance of quest bugs.
If that gives you an error on itemdata->Class, change 'Class' to 'Type'.
Avataro also forgot, or didn't know that this type of thing
requires a proper call to Waitdraw() in the active script, and must be called prior to it:
global script TestBrangCounter
{
void run()
{
while(1)
{
BoomerangCancel(); // <---- Must be BEFORE Waitdraw()
Waitdraw(); // <---- MUST CALL this instruction!
Waitframe();
}
}
}
The
bug that causes his script to repeat is
caused primarily by reading
Link->Input, instead of
Link->Press, but either way, you want this kind of event to occur prior to drawing.
(It can still cause issues with other code that requires reading button presses on the same button, all the same.)
P.S. I used itemdata here, as that ensures that the code works with
any boomerang class item, rather than specific item IDs.
If you
want a list of specific items, then you'd iterate an array that contains a list of each specific item ID against each button press. Let me know if you need that.
P.P.S.
I have an error on line 11. Editing that post, to correct it, using Android OS would require me to manually re-tab the whole thing.
Remove the
parens from PressA
() ... It should be
PressA
Sorry for the classic
Zoria-length post, but these were all key points to cover.
P.P.P.S.
Try changing Quit(); to Waitframe();. Might not make a difference, but you never know.
Calling Waitframe() in an item script acts as Quit(). As soon as the frame ends, the script execution (item script stack execution) immediately halts.