PDA

View Full Version : Not again! (More Script Problems!)



Nimono
02-18-2007, 12:52 PM
Sigh.... First off, someone PLEASE tell me the rules on double-posting here. -_-

My new problem is this one little error message:

"Cannot cast from Bool to Float!"

It comes up whenever I try to compile this script:

// Harp of Ages: Yes, it's true! If you have certain items, this Harp will do different things!
// Changable Variables:
// ID1- ID of the item you wish to be the Tune of Echoes, the first Harp tune. Use std.zh for the IDs.
// ID2- ID of the item you wish to be the Tune of Currents, the second Harp tune. See above.
// ID3- ID of the item you wish to be the Tune of Ages, the final Harp tune. Also see the first.
// DrmntTmeHle- Combo used by the Dormant/Sleeping Time Hole (Before using Tune of Echoes).
// OpnTmeHle- Combo used by the Open/Awakened Time Hole (After using Tune of Echoes).
// Note: Due to limitations... IF YOU AWAKEN A TIME PORTAL, USE IT. If you leave the screen after awakening one and come back, if you use the Tune
// of Echoes again, you MUST leave the screen, come back, and do it AGAIN! Otherwise, you'll go to the wrong place... >_<

import "std.zh"
item script HarpofAges
{
int CurMap = 0;
int CurDMap = 0;
int CurScrn = 0;
int LastMap = 0;
int LastDMap = 0;
int LastScrn = 0;
int WrpMap = 0;
int WrpDMap = 0;
int WrpScrn = 0;
int WrpMap2 = 0;
int WrpDMap2 = 0;
int WrpScrn2 = 0;
int ID1 = 46;
int ID2 = 47;
int ID3 = 0;
int DrmntTmeHle = 0;
int OpnTmeHle = 0;
int Time = 1;
int TimeCheck1 = 1;
int TimeCheck2 = 0;
int FFCLocation = 0;

void run()
{
CurMap = Game->GetCurMap();
CurDMap = Game->GetCurDMap();
CurScrn = Game->GetCurScreen();
WrpMap = CurMap + 1;
WrpDMap = CurDMap + 1;
WrpScrn = CurScrn;
WrpMap2 = CurMap - 1;
WrpDMap2 = CurDMap - 1;
WrpScrn2 = CurScrn;
if (Link->Item[16] == true)
{
if (CurMap == 2 || CurMap == 4 || CurMap == 6 || CurMap == 8 || CurMap == 10)
{
Time = 0;
Link->PitWarp(WrpDMap2, WrpScrn2);
Quit();
}
else if (CurMap == 1 || CurMap == 3 || CurMap == 5 || CurMap == 7 || CurMap == 9)
{
Time = 1;
Link->PitWarp(WrpDMap, WrpScrn);
Quit();
}
}
else if (Link->Item[47] == true)
{
if (CurMap == 2 || CurMap == 4 || CurMap == 6 || CurMap == 8 || CurMap == 10)
{
Time = 0;
Link->PitWarp(WrpDMap2, WrpScrn2);
Quit();
}
else if (CurMap == 1 || CurMap == 3 || CurMap == 5 || CurMap == 7 || CurMap == 9)
{
Time = 1;
}
}
else if (Link->Item[46] == true)
{
ffc FFCLocation = Screen->LoadFFC(32);
FFCLocation = (FFCLocation->X) + (FFCLocation->Y);
if (Screen->ComboD [FFCLocation] == DrmntTmeHle)
{
Screen->ComboD [FFCLocation] = OpnTmeHle;
}
}
}
}
Every time it reaches one of the checks for if Link has an item or not... It gives me that error. I HAVE to find out how to check if Link has a certain item or not, or this script won't exactly work right.... I know I could make it work without the item checks, but...

cbailey78
02-18-2007, 03:17 PM
You're not double posting. Double posting means posting a topic and replying yourself with the same username.

Nimono
02-18-2007, 03:20 PM
You're not double posting. Double posting means posting a topic and replying yourself with the same username.

-_- Wow. Thanks for being SO off-topic. I wasn't asking if I was double-posting here. I was asking for the rules on double-posting. Like, how long must I wait before it's okay (if it ever is)?

Back to the thread itself, does anyone have any idea why beta 16c gives me that compiler error?

The_Amaster
02-18-2007, 03:32 PM
This could just be an overall 16c error. Remember when I was trying to import your Shovel and Cane of Somaria scripts, I got a similar error.

DarkDragon
02-18-2007, 03:34 PM
I think what might be going on is that == only works on ints. Instead of


if(foo == true)

try


if(foo)

This behavior is not intended though, and if == still doesn't work for bools in the latest alpha, please post a bug report and I'll investigate.

Oh, and as for double posting, AGN rules forbid it universally. I personally have no problems with it, as long as the new post contains genuine new information, so you could say that double-posting in here is decriminalized if not legal.

Nimono
02-18-2007, 03:58 PM
I think what might be going on is that == only works on ints. Instead of


if(foo == true)

try


if(foo)

This behavior is not intended though, and if == still doesn't work for bools in the latest alpha, please post a bug report and I'll investigate.

Oh, and as for double posting, AGN rules forbid it universally. I personally have no problems with it, as long as the new post contains genuine new information, so you could say that double-posting in here is decriminalized if not legal.
Will do, but wouldn't "if(foo)" make it so it does the next line of code if it's true or not? I'll test this out in the latest build now.

Edit: Well, well, well.... Nope, still doesn't work in 219, the latest windows Alpha. Time to make a bug report.

DarkDragon
02-18-2007, 05:15 PM
If == were working correctly,


if(foo)

would be exactly the same as


if(foo == true)

that is, the next code would execute if foo were true, and wouldn't otherwise. The == true is just redundant.
If you wanted, you COULD keep adding == true checks


if( (foo==true)==true)



if( ((foo==true)==true))==true )

all of which amounts to the same thing.

Nimono
02-18-2007, 05:42 PM
If == were working correctly,


if(foo)

would be exactly the same as


if(foo == true)

that is, the next code would execute if foo were true, and wouldn't otherwise. The == true is just redundant.
If you wanted, you COULD keep adding == true checks


if( (foo==true)==true)



if( ((foo==true)==true))==true )

all of which amounts to the same thing.

I get it now. But then, it should still be fixed, just in case someone needs to make a check for if foo is false, right? Or is there another way?

DarkDragon
02-18-2007, 05:46 PM
To check if foo is false, you can use the not operator (!), which turns false to true, and true to false. Thus all of the following are equivalent:


if(foo == false)



if(!foo == true)



if(!foo)

But yes, I'll fix it, just because there's no reason == shouldn't work on booleans (especially since rewriting if(foo == bar), for two booleans foo and bar, is annoying.)

Nimono
02-18-2007, 06:31 PM
To check if foo is false, you can use the not operator (!), which turns false to true, and true to false. Thus all of the following are equivalent:


if(foo == false)



if(!foo == true)



if(!foo)

But yes, I'll fix it, just because there's no reason == shouldn't work on booleans (especially since rewriting if(foo == bar), for two booleans foo and bar, is annoying.)

Thanks. Oh, by the way, something's faultering in my script now:

// Harp of Ages: Yes, it's true! If you have certain items, this Harp will do different things!
// Changable Variables:
// ID1- ID of the item you wish to be the Tune of Echoes, the first Harp tune. Use std.zh for the IDs.
// ID2- ID of the item you wish to be the Tune of Currents, the second Harp tune. See above.
// ID3- ID of the item you wish to be the Tune of Ages, the final Harp tune. Also see the first.
// DrmntTmeHle- Combo used by the Dormant/Sleeping Time Hole (Before using Tune of Echoes).
// OpnTmeHle- Combo used by the Open/Awakened Time Hole (After using Tune of Echoes).
// Note: Due to limitations... IF YOU AWAKEN A TIME PORTAL, USE IT. If you leave the screen after awakening one and come back, if you use the Tune
// of Echoes again, you MUST leave the screen, come back, and do it AGAIN! Otherwise, you'll go to the wrong place... >_<

import "std.zh"
item script HarpofAges
{
int CurMap = 0;
int CurDMap = 0;
int CurScrn = 0;
int LastMap = 0;
int LastDMap = 0;
int LastScrn = 0;
int WrpMap = 0;
int WrpDMap = 0;
int WrpScrn = 0;
int WrpMap2 = 0;
int WrpDMap2 = 0;
int WrpScrn2 = 0;
int ID1 = 32;
int ID2 = 19;
int ID3 = 0;
int DrmntTmeHle = 0;
int OpnTmeHle = 0;
int Time = 1;
int FFCLoad = 0;
int FFCLocation = 0;

void run()
{
CurMap = Game->GetCurMap();
CurDMap = Game->GetCurDMap();
CurScrn = Game->GetCurScreen();
WrpMap = CurMap + 1;
WrpDMap = CurDMap + 1;
WrpScrn = CurScrn;
WrpMap2 = CurMap - 1;
WrpDMap2 = CurDMap - 1;
WrpScrn2 = CurScrn;
if (Link->Item[ID3])
{
if (CurMap == 2 || CurMap == 4 || CurMap == 6 || CurMap == 8 || CurMap == 10)
{
Time = 0;
Link->PitWarp(WrpDMap2, WrpScrn2);
Quit();
}
else if (CurMap == 1 || CurMap == 3 || CurMap == 5 || CurMap == 7 || CurMap == 9)
{
Time = 1;
Link->PitWarp(WrpDMap, WrpScrn);
Quit();
}
}
else if (Link->Item[ID2])
{
if (CurMap == 2 || CurMap == 4 || CurMap == 6 || CurMap == 8 || CurMap == 10)
{
Time = 0;
Link->PitWarp(WrpDMap2, WrpScrn2);
Quit();
}
else if (CurMap == 1 || CurMap == 3 || CurMap == 5 || CurMap == 7 || CurMap == 9)
{
Time = 1;
}
}
else if (Link->Item[ID1])
{
ffc FFCLoad = Screen->LoadFFC(32);
FFCLocation = (FFCLoad->Y & 240)+(FFCLoad->X>>4);
if (Screen->ComboD [FFCLocation] == DrmntTmeHle)
{
Screen->ComboD [FFCLocation] = OpnTmeHle;
Screen->ComboT [FFCLocation] = 1;
}
}
}
}
It's not doing anything, even if I have the specified items. I also need the help of an FFC to tell where a combo is, because there's no other way to find the combo's location, and just specifying a hardcoded location (one that'll never change) isn't a very good idea. I've checked to see if it was instead grabbing FFC 1, but... Nope. It's just plain not working. Any help would be appreciated. :D

Edit: Ehehehe..... I just figured out that my problem was that the FFCs ALWAYS reset if you leave their combos at 0.... Not a very wise idea to make them do that, I feel. Aaanyways.... Now, the combo it changes seems to refuse to be a warp. I can set it to ANY of the walkable warp types for average warp-tile transitions (That is, Direct Warp or Stairs), yet.... Walking on it does nothing. As shown in the above, updated script, I tried to change the combo type during the script, but it doesn't work. :( Can anyone help me on this?