Frictional Games Forum (read-only)
Boolean??!! Syntax help? - Printable Version

+- Frictional Games Forum (read-only) (https://www.frictionalgames.com/forum)
+-- Forum: Amnesia: The Dark Descent (https://www.frictionalgames.com/forum/forum-6.html)
+--- Forum: Custom Stories, TCs & Mods - Development (https://www.frictionalgames.com/forum/forum-38.html)
+---- Forum: Development Support (https://www.frictionalgames.com/forum/forum-39.html)
+---- Thread: Boolean??!! Syntax help? (/thread-19176.html)



Boolean??!! Syntax help? - Nuclearbones - 11-11-2012

I'm in a major predicament because I can't load this map. I'm not sure what's wrong with the script and I don't see anything wrong with it. I'm not sure what it is, maybe it's a syntax error or something, but all the way down to the red text...

////////////////////////////
// Run first time starting map
void OnStart()
{
//Valves
SetEntityConnectionStateChangeCallback("valve_iron_1", "Unlock1");
SetEntityConnectionStateChangeCallback("valve_iron_2", "Unlock2");
SetEntityConnectionStateChangeCallback("valve_iron_3", "Unlock3");

//Levers
SetEntityConnectionStateChangeCallback("lever_simple01_22", "OpenSecurityGate");
ConnectEntities("", "castle_portcullis_1", "lever_simple01_23", false, 1, "CloseGate");

}

void Unlock1(string &in asEntity, int alstate)
{
if (alstate == 1)
{
PlaySoundAtEntity("", "15_body_impact.snt", "Player", 0.0f, false);
SetWheelStuckState(asEntity, 1, true);
AddLocalVarInt("var_1", 1);
GET();
}


}

void Unlock2(string &in asEntity, int alstate)
{
if (alstate == -1)
{
PlaySoundAtEntity("", "15_body_impact.snt", "Player", 0.0f, false);
SetWheelStuckState(asEntity, 1, true);
AddLocalVarInt("var_1", 1);
GET();
}
}

void Unlock3(string &in asEntity, int alstate)
{
if (alstate == -1)
{
PlaySoundAtEntity("", "15_body_impact.snt", "Player", 0.0f, false);
SetWheelStuckState(asEntity, 1, true);
AddLocalVarInt("var_1", 1);
GET();
}
}

void GET()
{
if (GetLocalVarInt("var_1")==3)
{
////OPENING THE GATE
PlaySoundAtEntity("", "24_bang.snt", "Player", 0.0f, false);
SetMoveObjectState("castle_portcullis_1", 1.0f);
}
}

////CLOSE THE GATE
void CloseGate(string &in asConnectionName, string &in asMainEntity, string &in asConnectEntity, int alState)
{
if (alstate == 1)
<--- "alstate not declared" and "Expression must be of Boolean type".
{
PlaySoundAtEntity("", "24_bang.snt", "Player", 0.0f, false);
SetMoveObjectState("castle_portcullis_1)", 0.00f);
}
}

////OPEN SECURITY GATE
void OpenSecurityGate(string &in asEntity, int level_state)
{
if (level_state == 1)
{
SetMoveObjectState("safety_normal_vert_1", 1.0f);
}
}

////////////////////////////
// Run when entering map
void OnEnter()
{

}

////////////////////////////
// Run when leaving map
void OnLeave()
{

}

The alstate message is what threw me off the most. But the Boolean message??!! I'm dealing with levers, I need integers not Boolean values!

I would appreciate it if somebody helped look through the script and see if there is anything that would trigger these messages to appear. Thanks.


RE: Boolean??!! - Obsidiaguy - 11-11-2012

Does letter case matter? Capital, lowercase?

"void CloseGate(string &in asConnectionName, string &in asMainEntity, string &in asConnectEntity, int alState)
{
if (alstate == 1)"


RE: Boolean??!! Syntax help? - Nuclearbones - 11-11-2012

Yes actually. Scripts are case sensitive. And I fixed that and it stopped giving me the messages but the function wont work. So then I fooled around with script areas. After that wouldn't work, I just decided I would leave the door open. :/


RE: Boolean??!! Syntax help? - palistov - 11-11-2012

Use some debug messages in your script. It will help you understand what is going on in your script and when. Using debug messages can help you pinpoint a lot of semantics errors. (script compiles but doesn't do what you intended)

For example, before you go into the if-else construct in your function CloseGate, add a debug message 'AddDebugMessage("Gate is at state: " + alState, false);' -- Do the same for a lot of your functions and see where the hiccup is.

Edit: misunderstood some of your script, editing out some of the misunderstandingsnessness Big Grin