You have two options:
1. Use 2.55, and itemdata scripts.
if ( Hero->PressR )
{
itemdata id = Game->LoadItemData[itemnumber];
id->RunScript(); //Run any arbitrary item script based on the button press
}
itemdata script sbomb
{
void run()
{
//Check that there are no super bombs on screen
for ( int q = Screen->NumLWeapons(); --q )
{
lweapon l = Screen->LoadLWeapon(q);
if ( l->ID == LW_SBOMB ) Quit();
}
unless ( Game->Counter[CR_SBOMB] ) return; //Check if Link has ammo
--Game->Counter[CR_SBOMB]; //Reduce the counter
//Create the weapon, and position it properly.
lweapon sb = Screen->CreateLWeapon(LW_SBOMB);
sb->Dir = Hero->Dir;
switch(Hero->Dir)
{
case DIR_UP:
{
sb->X = Hero->X;
sb->Y = Hero->Y - 16;
break;
}
case DIR_DOWN:
{
sb->X = Hero->X;
sb->Y = Hero->Y + 16;
break;
}
case DIR_LEFT:
{
sb->X = Hero->X-16;
sb->Y = Hero->Y;
break;
}
case DIR_RIGHT:
{
sb->X = Hero->X+16;
sb->Y = Hero->Y;
break;
}
}
}
}
In 2.53.x, you'd need to code a global function for R:
void RButton()
{
if ( Link->PressR )
{
//Check that there are no super bombs on screen
for ( int q = Screen->NumLWeapons(); --q )
{
lweapon l = Screen->LoadLWeapon(q);
if ( l->ID == LW_SBOMB ) return;
}
if ( !Game->Counter[CR_SBOMB] ) return; //Check if Link has ammo
--Game->Counter[CR_SBOMB]; //Reduce the counter
//Create the weapon, and position it properly.
lweapon sb = Screen->CreateLWeapon(LW_SBOMB);
sb->Dir = Link->Dir;
if ( Link->Dir == DIR_UP )
{
sb->X = Hero->X;
sb->Y = Hero->Y - 16;
break;
}
else if ( Link->Dir == DIR_DOWN )
{
sb->X = Hero->X;
sb->Y = Hero->Y + 16;
break;
}
else if ( Link->Dir == DIR_LEFT )
{
sb->X = Hero->X-16;
sb->Y = Hero->Y;
break;
}
else
{
sb->X = Hero->X+16;
sb->Y = Hero->Y;
break;
}
}
}