Ah, yeah, I see now. There are a few different problems. First, this:
Code:
void run(int SomariaBlockX, int SomariaBlockY, int SomariaCheck, int SomariaBlockPosition)
{
If you declare variables there, they
will be reset to 0 every time the item is used. If you want them to keep their values, declare them before run(), like this:
Code:
item script CaneSomaria
{
int SomariaBlockX = 0;
int SomariaBlockY = 0;
int SomariaCheck = 0;
int SomariaBlockPosition = 0;
void run()
{
That makes them global variables. they'll only be initialized once; after that, they'll start the script with the same values they ended with last time.
You'll also want to make those CmbR
X variables global, or they'll get reset, too.
Although as it is, you never actually change their values, y'know.
However, there'll be a problem with doing this, in this case: SomariaCheck won't be reset when you go to another screen. You'll also need to check which screen and map you're on when the item is used and treat SomariaCheck as 0 if they've changed since last time.
You can't just use screen variables, since those don't get reset when you leave the screen. If you left and came back, they might be wrong.
There's also this. This might be a problem, or it might be what you intended. Just in case...
Code:
if (SomariaCheck == 1)
{
if (Screen->ComboS [SomariaBlockPosition] == 15)
{
Screen->ComboD [SomariaBlockPosition] = CmbR;
Screen->ComboC [SomariaBlockPosition] = CmbRC;
Screen->ComboT [SomariaBlockPosition] = CmbRT;
Screen->ComboF [SomariaBlockPosition] = CmbRS;
Screen->ComboI [SomariaBlockPosition] = CmbRI;
Screen->ComboS [SomariaBlockPosition] = CmbSd;
SomariaCheck = 0;
}
}
if (Link->Dir == 0)
{
That won't alternately create and destroy a block; that'll destroy a block
and create a new one every time you use the item. If that's what you meant for it to do, it's fine. Otherwise, you can change it by putting an else before the second if statement or by putting
Quit(); after setting SomariaCheck to 0.
That's still not quite perfect, but it'll definitely be closer, at least.