Hi
I have not found a suitable answer to my query about int options:
It works but would like more that just 1 Say command.
function room_RepExec()
{
if (IsTimerExpired(1) == 1) {
int ran=Random(2);
if (ran == 0)
cdiablo2.Say("You've got the wrong man!");
// Something here like another char speaks
else if (ran == 1)cdiablo2.Say("I'm innocent!");
// Something here like another char speaks
else if (ran == 2) cdiablo2.Say("I'm missing my break time!") ;
// Something here like another char speaks
SetTimer(1, 160);
}
}
Grateful for any assistance
barefoot
Just like any other if statement
if (ran == 1) {
DoThis();
AndThis();
}
else if (ran == 2) {
DoThisInstead();
ThenThis();
}
Hi
I've scored with this using the old &&:
function room_RepExec()
{
if (IsTimerExpired(1) == 1) {
int ran=Random(2);
if (ran == 0)cdiablo2.Say("You've got the wrong man!")&& cleech.Say("Poppycock!");
else if (ran == 1)cdiablo2.Say("I'm innocent!") && cleech.Say("You're as guilty as Manson!");
else if (ran == 2) cdiablo2.Say("I'm missing my break time!")&& cleech.Say("That's such a pity!");
SetTimer(1, 120);
}
}
Just seen your reply thanks Calin
barefoot
using && in that way is very odd.
I suggest doing it the way i suggested.. it far more readable if nothign else.
As expected, using && in that really creepy way won't do the trick. It actually compiles, but a) won't if you use e.g. Display instead of Character.Say and b) only runs the first .Say, not the second one.
barefoot, you already know that commands are grouped together by putting them inside { and }, just transfer that knowledge to not just "int options" but every other situation.
Hi Calin/Khris
as suggested:
function room_RepExec()
{
if (IsTimerExpired(1) == 1) {
int ran=Random(2);
if (ran == 0) {
cdiablo2.Say("You've got the wrong man!");
cleech.Say("Poppycock!");
cginger.Say("Come clean!");
}
else if (ran == 1) {
cdiablo2.Say("I'm innocent!");
cleech.Say("You're as guilty as Manson!");
cginger.Say("And Jack the Ripper!");
}
else if (ran == 2) {
cdiablo2.Say("I'm missing my break time!");
cleech.Say("That's such a pity!");
cginger.Say("Poor little you!");
}
SetTimer(1, 120);
}
}
Cheers
barefoot
And with consistent indentation:
function room_RepExec() {
if (IsTimerExpired(1) == 1) {
int ran=Random(2);
if (ran == 0) {
cdiablo2.Say("You've got the wrong man!");
cleech.Say("Poppycock!");
cginger.Say("Come clean!");
}
else if (ran == 1) {
cdiablo2.Say("I'm innocent!");
cleech.Say("You're as guilty as Manson!");
cginger.Say("And Jack the Ripper!");
}
else if (ran == 2) {
cdiablo2.Say("I'm missing my break time!");
cleech.Say("That's such a pity!");
cginger.Say("Poor little you!");
}
SetTimer(1, 120);
}
}
The difference in readability is worth the extra few seconds this might take, AGS will do this style of indentation automatically though.