I'm getting an error in a specific function as you can see above but I can't figure out the exact location it wants me to put the (. Can anyone solve this problem?
function oCdoor_Interact()
{
if (Game.DoOnceOnly(oCdoor_Interact))
{cEgo.Walk(192, 55, eBlock, eWalkableAreas);
Display("As you move to open the door it suddenly springs open!"
Display(" 'STAY BACK!' ");
Display(" 'George! Oh thank go!' ");
Display("It's your best friend Ken!");
Display(" 'When I heard the ship was being invaded I fled down the hall and hid in the closet. I was afraid to come out but I'm glad to see you. We got outta here!' ");
cEgo.AddInventory(iKen);
}
else
{Display("TEST");
}
}
:confused:
function oCdoor_Interact()
{
if (Game.DoOnceOnly(oCdoor_Interact)) // oCdoor_Interact is not a String variable!
{
cEgo.Walk(192, 55, eBlock, eWalkableAreas);
Display("As you move to open the door it suddenly springs open!" // MISSING closing parenthesis and semicolon!
Display(" 'STAY BACK!' ");
Display(" 'George! Oh thank go!' ");
Display("It's your best friend Ken!");
Display(" 'When I heard the ship was being invaded I fled down the hall and hid in the closet. I was afraid to come out but I'm glad to see you. We got outta here!' ");
cEgo.AddInventory(iKen);
}
else
{
Display("TEST");
}
}
It is telling you that an opening parenthesis was expected because oCdoor_Interact is the name of a function. In AGS there's no such thing as a function-pointer, or anything like it, so when the script parser sees a function name it expects the very next character to be the opening parenthesis.
The Game.DoOnceOnly function takes a String parameter, not a function name as a callback. You could still use the name of the function if you want, but you'll have to enclose it in double quotes ("oCdoor_Interact").
You are also missing a closing parenthesis and semicolon on the fifth line of your code snippet, as I commented on above.
Here is the amended code:
function oCdoor_Interact()
{
if (Game.DoOnceOnly("oCdoor_Interact"))
{
cEgo.Walk(192, 55, eBlock, eWalkableAreas);
Display("As you move to open the door it suddenly springs open!");
Display(" 'STAY BACK!' ");
Display(" 'George! Oh thank go!' ");
Display("It's your best friend Ken!");
Display(" 'When I heard the ship was being invaded I fled down the hall and hid in the closet. I was afraid to come out but I'm glad to see you. We got outta here!' ");
cEgo.AddInventory(iKen);
}
else
{
Display("TEST");
}
}
P.S. You can format your code for forum posts by putting it between [code] and [/code] tags.
Also if you want to put " instead of ' you can.
I think it's
Display(" \"STAY BACK!\" ");//will display "STAY BACK"