Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Using the browser's console & script pasages

Let's say there's a script passage called "a script" which just has "var x = 5". (simplified example obv.)

With the game running in the browser, I open the console and want to set that x to 1 instead to test something.
Of course the x is not in the global scope, but where is it ?

Comments

  • note: this is my understanding of how things work and could be incorrect, Leon or TheMadExile would have a better understanding.

    The content of the Script Passages are just plain text until it is eval()ed, and the variables set using var's are only in scope while the eval is happening.

    To see/debug the java-script generated by eval() in Firefox, open the debugger (using F12) and select the Source tab, then to create the eval()ed code refresh the page (using F5). Once this is done you use the little down arrow next to the filename to display a list of available java-script and select an option with the word eval in it, it will look something like "filename line nnnn > eval". You can set breakpoints and inspect variables like any other java-script but you can only use the console to change variable values while your have paused execution using a breakpoint because they are only in scope while the code is being eval()ed.

    I hope this helps.
  • If you really need a variable in a script to be accessible from the console, just change, say, "var m = "figs";" to "window.m = "figs";"
  • I see, thanks.
Sign In or Register to comment.