Please login or register.

Login with username, password and session length
Advanced search  

News:

Latest WME version: WME 1.9.1 (January 1st, 2010) - download

Author Topic: [Resolved] Random responses.  (Read 2855 times)

0 Members and 1 Guest are viewing this topic.

Teukros

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 6
  • Must escape the room!
    • View Profile
    • Polymorphic Games
[Resolved] Random responses.
« on: September 28, 2012, 05:08:19 AM »

I used the book's script set up to call up one of several predefined responses when left clicking on a regional entity:

Code: [Select]
var mountaindescribe;
 
mountaindescribe[0] = "Those mountains look gorgeous from out here.  Probably a pain and a half to climb, though."; 
mountaindescribe[1] = "That song that mentions purple mountain majesties...they never saw this.";
mountaindescribe[2] = "Never was one for rock climbing.  I'd rather just kick something in a gym.";
mountaindescribe[3] = "Staring at those mountains makes me hungry.  I don't know why it makes me hungry.  Maybe because I'm hungry all the time...";
mountaindescribe[4] = "What a boring view.  Never changes, nothing dynamic.  No wonder I prefer TV.";

var rdffg = Random(0,4);

on "Leftclick"
{
  Game.Msg(mountaindescribe[rdffg]);
}

Instead of getting a random response each time I click, instead, I get the same response every time in a session, which changes each time I reload the game.  What am I doing wrong?
« Last Edit: September 28, 2012, 07:49:15 AM by Teukros »
Logged
"The only reason to get up in the morning is to outdo yourself -- to do it better than you've ever done it before.  [And if you haven't done it better by nightfall] look at your globe and pick a spot...it's always morning somewhere." --Carmen Sandiego

Azrael

  • Regular poster
  • ***
  • Karma: 9
  • Offline Offline
  • Gender: Male
  • Posts: 155
    • View Profile
    • Mad Orange
Re: New question regarding random responses.
« Reply #1 on: September 28, 2012, 07:27:25 AM »

The script is loaded with the scene, so your script it will create a random number only when the scene is loaded.
If you want a random responses on the LeftClick event you have to put the Random inside the LeftClick event, like this:

Code: WME Script
  1. var mountaindescribe;
  2.  
  3. mountaindescribe[0] = "Those mountains look gorgeous from out here.  Probably a pain and a half to climb, though."
  4. mountaindescribe[1] = "That song that mentions purple mountain majesties...they never saw this.";
  5. mountaindescribe[2] = "Never was one for rock climbing.  I'd rather just kick something in a gym.";
  6. mountaindescribe[3] = "Staring at those mountains makes me hungry.  I don't know why it makes me hungry.  Maybe because I'm hungry all the time...";
  7. mountaindescribe[4] = "What a boring view.  Never changes, nothing dynamic.  No wonder I prefer TV.";
  8.  
  9. var rdffg;
  10.  
  11. on "Leftclick"
  12. {
  13.   rdffg = Random(0,4);
  14.   Game.Msg(mountaindescribe[rdffg]);
  15. }
Logged

Teukros

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 6
  • Must escape the room!
    • View Profile
    • Polymorphic Games
Re: New question regarding random responses.
« Reply #2 on: September 28, 2012, 07:48:53 AM »

Thanks a lot!  That worked perfectly.
Logged
"The only reason to get up in the morning is to outdo yourself -- to do it better than you've ever done it before.  [And if you haven't done it better by nightfall] look at your globe and pick a spot...it's always morning somewhere." --Carmen Sandiego
 

Page created in 0.051 seconds with 21 queries.