Wow, thanks Khris. That's amazing how you can churn out these formulas like that.

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
Show posts MenuQuote from: Khris on Mon 15/07/2024 15:03:16So to get this straight:
- When the room in entered, you randomly set Greed to 1, 2 or 3.
- Next you start dialogs that reduce Greed by 1 multiple times
- But when Greed goes down to 0, you're not getting the line about the demon being defeated?
The first thing you need to check is that your room_RepExec is linked to the room event*, since unlike on_event, it actually needs to be linked or AGS will simply ignore it.
In the long run however you should use a function to reduce the variable which then also checks if it reached 0, because this check doesn't have to run 40 times per second. A related issue with your current code is that if you fix it, AGS will now keep displaying the message, leaving you unable to do anything else.
(* if this turns out to be the issue here, we need to think of a way to clarify and really emphasize this mechanism in the manual, given how often it still stumps beginners)
// room script file
function on_event(int event, int data)
{
if (event == eEventEnterRoomBeforeFadein)
{
aCantrell_manic_dance.Play();
int ran=Random(2);
if (ran==0) { Greed++; cAngel2.ChangeRoom(5); }
if (ran==1) { Greed += 2; Demon2.ChangeRoom(5); }
if (ran==2) { Greed += 3; cDemon.ChangeRoom(5); }
}
}
function room_RepExec()
{ if (Greed == 0) {
cAngel2.ChangeRoom (1); cEgo.ChangeRoom (1); cDemon.ChangeRoom (1); Display("The demon has been defeated!");
}
}
Quote from: Khris on Mon 15/07/2024 10:04:31If you declare a variable in the room script, it only exists in that room.That is exactly what I already figured. The only problem is I already tested it and took out the line where I declare it (I already added it to the global pane), but it didn't change anything.
Since the dialog line that reduces Fear doesn't throw an error, my guess is you declared Fear twice. Which means you're working with two separate variables which just happen to have the same name.
To create an actual global variable, either use the global variables pane, or export/import it.
// room script file
function on_event(int event, int data)
{
if (event == eEventEnterRoomBeforeFadein)
{
aCantrell_manic_dance.Play();
int ran=Random(2);
if (ran==0) cAngel2.ChangeRoom(5); Greed++;
if (ran==1) cEgo.ChangeRoom(5); Greed += 2;
if (ran==2) cDemon.ChangeRoom(5); Greed += 3;
}
}
function repeatedly_execute()
{ if (Greed == 0)
{
cAngel2.ChangeRoom (1); cEgo.ChangeRoom (1); cDemon.ChangeRoom (1); Display("The demon has been defeated!");
}
}
// Dialog script file
@S // Dialog startup entry point
Angel: &2 "And the earth was without form, and void; and darkness was upon the face of the deep. And the Spirit of God moved upon the face of the waters."
Display("The demon writhes in agony!");
GiveScore(1);
bGenesis1V2.Visible = true;
Greed--;
stop
// room script file
int Fear;
function on_event(int event, int data)
{
if (event == eEventEnterRoomBeforeFadein)
{
aCantrell_manic_dance.Play();
int ran=Random(2);
if (ran==0) cAngel2.ChangeRoom(5); Fear += 1;
if (ran==1) cEgo.ChangeRoom(5); Fear += 2;
if (ran==2) cDemon.ChangeRoom(5); Fear += 3;
}
}
function repeatedly_execute()
{ if (Fear == 0)
{
cAngel2.ChangeRoom (1); cEgo.ChangeRoom (1); cDemon.ChangeRoom (1); Display("The demon has been defeated!");
}
}
// Dialog script file
@S // Dialog startup entry point
Angel: &1 "In the Beginning, God created the Heaven and the Earth."
Display("The demon writhes in agony!");
GiveScore(1);
bGenesis1V1.Visible = true;
Fear -= 1;
stop
By continuing to use this site you agree to the use of cookies. Please visit this page to see exactly how we use these.
Page created in 0.027 seconds with 14 queries.