So I am working on this hotspot that will have this message that will appear only once, I tried using Int but several errors keep popping up like undefined Int. I was wondering how do I define this Int, and see if there is any other problems in my coding.
Thank you in advanced.
[CODE=ags]
function room_Load()
{
Int Guardroom = hHotspot5_AnyClick ();
}
{
if (Guardroom == 0) {
cToyf.Say("placeholder Dialog.");
Display("Evil Dialog");
cToyf.Say("Pain dialog");
Display("Feeling weak Dialog.");
}
if (Guardroom == 1) {
cToyf.Say("It's the security room. Currently it's locked.");
Guardroom +=1;
}
[/CODE=ags]
It is "int" (lowercase), not "INT". AGS script is case sensitive (as most of the scripting and programming languages I knew).
Other than that, if the script you posted is your actual script from game, it won't work that way. You are defining a local variable "Guardroom", that will exist only inside the function Room_Load. If you want to use this variable in other functions, declare a global variable instead, outside of any function.
http://www.adventuregamestudio.co.uk/wiki/Scripting_tutorial_part_1#Variable_Scope
You can use Game.DoOnceOnly():
function hHotspot5_AnyClick() {
if (Game.DoOnceOnly("guard room")) {
cToyf.Say("placeholder Dialog.");
Display("Evil Dialog");
cToyf.Say("Pain dialog");
Display("Feeling weak Dialog.");
}
else {
cToyf.Say("It's the security room. Currently it's locked.");
}
}
I have used "guard room" as parameter, but it doesn't matter what you put, as long as you don't use the same text elsewhere in your game.
Using an int:
int guardRoom = 0;
function hHotspot5_AnyClick() {
if (guardRoom == 0) {
cToyf.Say("placeholder Dialog.");
Display("Evil Dialog");
cToyf.Say("Pain dialog");
Display("Feeling weak Dialog.");
guardRoom++;
}
else {
cToyf.Say("It's the security room. Currently it's locked.");
}
}
I'll also recommend naming your hotspots before creating the event functions; you'll get hSecurityRoom_AnyClick which is a lot more readable. You can still rename the function in the event list and script though.
Also, is there a specific reason why you're using AnyClick instead of LookAt?