exovercount = exovercount + 1
if (exovercount % 10 = 0) {
msg("Something happens now")
}
XanMag wrote:At the end of a function, I have: SetObjectFlagOn (Commons, "exover")
which allows the player to leave the current room. I want to have random messages pop up every 10th turn or so at this point. At the end of this function (or once the flag is set), I want the random messages to pop up no matter where the player is within the game.
So... I have created a Boolean attribute on a room (Commons) called "exover". In the little box in the GUI... I leave the "True" box unticked?
Then, also on the Commons, I created an integer attribute called "exovercount". Do I leave the exovercount integer equal to zero?
I also created a "changedexover" script that enables "exoverturnscript".
Then... in the turn script that is not attached to an object, I copy-paste the code you supplied above?
I will have random messages selected at that point every 10th player turn, but I'm pretty sure I can make that work.
If all above is okay, do I have at the end of my function (above) a script that sets the Boolean attribute "exover" to true?
<object name="Commons">
<attr name="exover" type="boolean">false</attr>
</object>
~VS~
<object name="Commons">
<attr name="exover" type="boolean">true</attr>
</object>
<object name="Commons">
<attr name="exover" type="boolean">false</attr>
<attr name="count" type="int">0</attr> // see if you can understand why this is needed (this is a more advanced-difficult question)
<attr name="changedexover" type="script"><!CDATA[
while (Commons.count < 5) { // see if you can understand why this is needed (this is a more advanced-difficult question)
if (Commons.exover = true) {
msg ("hi")
Commons.exover = false // see if you can understand what's going on here
} else if (Commons.exover = false) {
msg ("bye")
Commons.exeover = true // see if you can what's going on here
}
count = count + 1 // see if you can understand why this is needed (this is a more advanced-difficult question)
}
]]></script>
</object>
SetObjectFlagOn (Commons, "exover")
<exover type="boolean">false</exover>
<exovercount type="int">0</exovercount>
<changedexover type="script">
EnableTurnScript (exoverturnscript)
</changedexover>
<turnscript name="exoverturnscript">
<script>
game.exovercount = game.exovercount + 1
if (game.exovercount % 10 = 0) {
n = GetRandomInt (0, ListCount (game.suntzu) - 1)
msg ("A voice booms over the loud speakers, " + StringListItem (game.suntzu, n))
}
</script>
</turnscript>
<suntzu type="stringlist">
<value><![CDATA[<b>"I have a whole bunch of my random messages here..."</b>]]></value>
</suntzu>
<turnscript name="exoverturnscript">
<script>
game.exovercount = game.exovercount + 1
if (game.exovercount % 10 = 0) {
n = GetRandomInt (0, ListCount (game.suntzu) - 1)
msg ("A voice booms over the loud speakers, " + StringListItem (game.suntzu, n))
}
</script>
</turnscript>
<game name="blah">
<attr name="exovercount" type="int">0</attr>
</game>
random_number = GetRandomInt (0, 1000)
if (random_number % 2 = 0) { // if ( Remainder = 0)
msg ("The random number " + random_number + " is even")
} else {
msg ("The random number " + random_number + " is odd")
}
get input {
factor = result
}
random_number = GetRandomInt (0, 1000)
if (random_number % factor = 0) {
msg ("The random number " + random_number + " is divisible by " + factor)
} else {
msg ("The random number " + random_number + " is not divisible by " + factor)
}
days = GetRandomInt (0, 1000)
month = ( (days / 31) % 12 ) + 1
// the '+1' is so that I can use '1-12' instead of having to use '0-11' in the 'if' block below
if (month = 1) {
msg ("Jan")
} else if (month = 2) {
msg ("Feb")
} else if (month = 3) {
msg ("Mar")
} else if (month = 4) {
msg ("Apr")
} else if (month = 5) {
msg ("May")
} else if (month = 6) {
msg ("Jun")
} else if (month = 7) {
msg ("Jul")
} else if (month = 8) {
msg ("Aug")
} else if (month = 9) {
msg ("Sep")
} else if (month = 10) {
msg ("Oct")
} else if (month = 11) {
msg ("Nov")
} else if (month = 12) {
msg ("Dec")
}
<object name="Commons">
<attr name="exover" type="boolean">false</attr>
<attr name"exovercount" type="int">0</attr>
<attr name="changedexover" type="script">
if (Commons.exover = true) {
EnableTurnscript (Commons, "exoverturnscript")
} else if (Commons.exover = false) {
DisableTurnscript (Commons, "exoverturnscript")
}
</attr>
</object>