Errors in Javascript - any way to track this?

I've got some issues in my javascript code. The problem is that there are lots of branches and sections with java in them and it's tough to figure out where I'm at when it fails.

If there any way for java script to print to the screen (like traditional squiffy does)? That way I could put location statements in debugs and figure out where I'm failing.

Help!


K.V.

I think it's squiffy.write() or squiffy.ui-write().

I can't clearly remember. . .


UPDATE

It is squiffy.ui.write().

Example 1:

[[testing]]

[[testing]]:
    squiffy.ui.write("Hello, world!");

Example 2

@set foo=1
@set bar=2
[[testing 2]]

[[testing 2]]:
    squiffy.ui.write("foo = " + squiffy.get("foo") + "<br/>bar = " + squiffy.get("bar"));
    squiffy.ui.write("foo = {foo}<br/>bar = {bar}");

I couldn't get either to work. However, I did come up with this (off an old posting). This can be used to tell me what's going on via a dialog.

    if (get("alertor")){alert("SPECIAL");}

I can activate it when I'm close to the place and seed these all through the code to try to get to the bottom of the lockups.


Edited: Ooops, silly mistake, got the key combo wrong

If you're playing in a web browser, you can write messages to the javascript console.

Press Ctrl+Shift+J to open the console in Chrome (think it's the same in other browsers, but not sure). You can write messages to the console using javascript like this: console.log("Something happened!");

This means you don't have to worry so much about remembering to remove the alerts before you release the game to players, as they're unlikely to have the console open.


Thank you all -these solutions are great! I'm going with Console.log since that works really smooth. Now I can figure out whats wrong!


K.V.

Just for completion's sake, it is squiffy.ui.write(). I edited my previous post in case anyone wants to know how to print from JS, but the log seems like a better idea in this case.


This topic is now closed. Topics are closed after 180 days of inactivity.

Support

Forums