JScript + world.sound + timer problem

Posted by Feantur on Sat 16 Oct 2004 12:31 PM — 9 posts, 35,718 views.

#0
I have a timer that runs at intervals. It is set to send to script and it has one line which is also the line it reports to be having an error in:

Expected hexadecimal digit
Line in error:
world.Sound("c:\windows\media\x.wav");

What hexadecimal digit?
Amended on Sat 16 Oct 2004 12:32 PM by Feantur
Greece #1
It probably tries to interpret \x as a hex sequence, like in \x31. Try escaping the backslashes.
Australia Forum Administrator #2
It *will* do that. Each backslash needs to be two backslashes.
#3
Great, this works now. Thanks!

The next thing I'd like to tackle would be resetting the timer whenever I send something to the world. How could I do that?
USA #4
http://www.gammon.com.au/forum/bbshowpost.php?bbsubject_id=1692
Use a plugin callback (which either means moving the whole thing to a plugin, or just this callback with a way to reset a main world thing (such as world.execute).

Use OnPluginCommand, or OnPluginSend, depending on which you want.

I... think thats the only way. There might be a way that escapes me at the moment to do it without a plugin.
#5
Uhoh. I don't have any experience with writing plugins for the client... :-(
USA #6
Its easy. Its just like writing triggers and such.

Only you have a different script "space", think of it as just a different environment. It cant talk directly with the script space for your main world, or any other plugin.

And that callback, just make it a subroutine in your plugin file.

Its the exact same stuff youve been doing with triggers/et al for the world file. Only you have to edit it in a text editor (or the plugin wizard).

Search the forums (browse the plugin forum) there are some nice simple examples that you can use to build on (like having to use <[CDATA] to enclose your script stuffs.
#7
Right, I lost track of this a bit. I've looked at a few plugins since the last post on this thread - don't manage to get it to work.

Is there some tutorial on how to write plugins?

I assume what you suggested is writing a plugin that calls on the timer and resets it. What I don't understand is, how does the plugin know when to do the call at the timer?
Amended on Sat 18 Dec 2004 03:55 AM by Feantur
Australia Forum Administrator #8
The bottom of this page covers it briefly:

http://www.gammon.com.au/plugins/