Please login or register.

Login with username, password and session length
Advanced search  

News:

This forum provides RSS feed. To query recent posts use this url. More...


Author Topic: Example of loop?  (Read 4584 times)

0 Members and 1 Guest are viewing this topic.

Marek

  • Occasional poster
  • **
  • Karma: 0
  • Offline Offline
  • Posts: 61
  • I'm a llama!
    • View Profile
Example of loop?
« on: May 31, 2004, 12:12:28 PM »

I'm trying to make a sort of limited help system, in that the game tracks the time and if the player hasn't done something after 5 minutes, the character will give a hint.

Could someone supply an example of a loop for such a thing, and tell me where I should probably insert it? I haven't done a loop before yet in this project so it would be great if I had a template  :)

What I'm trying to do is this:
- At the start of scene, the game stores the time in a variable
- When the game time is 5 minutes later, it checks if inventory has object "X"
- If not, then actor.Talk("Hey, maybe I should check out object X!");

Muchos gracias!
Logged

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: Example of loop?
« Reply #1 on: May 31, 2004, 12:43:57 PM »

Create a new script file with the following content and attach it to the scene in SceneEdit:

[code]
#include "scripts\base.inc"

Sleep(5 * 60000); // sleep for 5 minutes

if(!actor.HasItem("X"))
{
« Last Edit: May 31, 2004, 01:14:04 PM by Mnemonic »
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

Marek

  • Occasional poster
  • **
  • Karma: 0
  • Offline Offline
  • Posts: 61
  • I'm a llama!
    • View Profile
Re: Example of loop?
« Reply #2 on: May 31, 2004, 12:51:22 PM »

Great! However, it shows an error and I can't debug properly. For some reason the log is not being updated. Do you know how that could happen? It stopped logging sometime yesterday.
Logged

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: Example of loop?
« Reply #3 on: May 31, 2004, 01:02:12 PM »

The log file is only generated when "Debug mode" is tured on in ProjectMan.
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

Marek

  • Occasional poster
  • **
  • Karma: 0
  • Offline Offline
  • Posts: 61
  • I'm a llama!
    • View Profile
Re: Example of loop?
« Reply #4 on: May 31, 2004, 01:06:06 PM »

Doh! Thanks.
Logged

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: Example of loop?
« Reply #5 on: May 31, 2004, 01:15:13 PM »

Oops, I think I know what the problem is. There should be

#include "scripts\base.inc"

in the beginning of the script, so that the "actor" variable is known. Or did I make some other mistake? :)
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

Marek

  • Occasional poster
  • **
  • Karma: 0
  • Offline Offline
  • Posts: 61
  • I'm a llama!
    • View Profile
Re: Example of loop?
« Reply #6 on: May 31, 2004, 01:18:22 PM »

It says there's a syntax error on line 4:

Quote
Sleep(2 * 60000); // sleep for 2 minute(s)

if(!actor.HasItem("noise")
{
  // we'd better wait until the actor is ready (i.e. not walking/talking etc.)
  while(!actor.Ready) Sleep(100);
 
  // now he's ready!
  actor.Talk("What's that noise I hear?");
  Game.TakeItem("noise");
}

Adding the include didn't change anything.
Logged

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: Example of loop?
« Reply #7 on: May 31, 2004, 01:21:25 PM »

It should be:

if(!actor.HasItem("noise"))

(one extra parenthesis). I edited the code immediately after I posted but you were too fast :)
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

Marek

  • Occasional poster
  • **
  • Karma: 0
  • Offline Offline
  • Posts: 61
  • I'm a llama!
    • View Profile
Re: Example of loop?
« Reply #8 on: June 01, 2004, 12:55:46 PM »

Bingo. I really need to learn to not just look at the exact line that is referenced in the log.  :)
Logged
 

Page created in 0.035 seconds with 20 queries.