HTML table or javascript alert box
lefay39
01 Feb 2013, 11:36I am trying to implement an HTML table summarising the values of player attributes (scores) each time the player moves to a different room. Basically, I cannot seem to address objects or attributes correctly from within external HTML or javascript. I just get an 'undefined' error each time I try this.
Having failed to implement the table I then tried doing it with javascript alert. Same problem. I just can't seem to reference objects from in external files. The alert works so long as I only put a text string, but that is not what I require. Any ideas?
Sarah
Having failed to implement the table I then tried doing it with javascript alert. Same problem. I just can't seem to reference objects from in external files. The alert works so long as I only put a text string, but that is not what I require. Any ideas?
Sarah

Pertex
01 Feb 2013, 11:40Could you post an example what your are trying to do?
lefay39
01 Feb 2013, 12:20OK - it's very simple (or should be). I insert HTML file. The first one, testScript.HTML contains the following
<script>
alert('Helpfulness =')
</script>
This works fine
However, when I try to address an object and its attribute
<script>
alert('Helpfulness ='+ player.Helpfulness)
</script>
I get this error
JavaScript error at line 2: 'player' is undefinedJavaScript error at line 2: Could not complete the operation due to error 80020101.
player.Helpfulness works fine when I use it as an expression within Quest.
I have tried a number of different things including increasing the 'depth' of the reference' e.g. game.FeaturedProducts.player.Helpfulness (and others) and also using the GetAttribute function. Nothing helps.
<script>
alert('Helpfulness =')
</script>
This works fine
However, when I try to address an object and its attribute
<script>
alert('Helpfulness ='+ player.Helpfulness)
</script>
I get this error
JavaScript error at line 2: 'player' is undefinedJavaScript error at line 2: Could not complete the operation due to error 80020101.
player.Helpfulness works fine when I use it as an expression within Quest.
I have tried a number of different things including increasing the 'depth' of the reference' e.g. game.FeaturedProducts.player.Helpfulness (and others) and also using the GetAttribute function. Nothing helps.

Pertex
01 Feb 2013, 13:20Ok, you can't use Quest objects or attributes in Javascript functions, you can only pass parameters from Quest to Javascript. Read some more information about it here:
http://quest5.net/wiki/Using_Javascript
http://quest5.net/wiki/Javascript
http://quest5.net/wiki/Using_Javascript
http://quest5.net/wiki/Javascript
lefay39
01 Feb 2013, 15:02OK - that makes sense. Thanks. Unfortunately, what I am actually trying to do is activate either the alert or the table when I click a button (created by inserting HTML) so I'm still going to have the same problem, because I will be calling the function from the HTML file. I haven't found any way to make and position a button or clickable link other than inserting HTML - unless I am missing something.
Also, I really can't make head not tail of the add javascript thing. I've added javascript, but then when I try to call it , using the 'Call Function' option in 'Add Script' I get this error on running
Error: Error adding script attribute 'beforeenter' to element 'FeaturedProducts': Function not found: 'scoreThing'
the same function works beautifully when called from within HTML
This is why I have been calling the script from html files.
On a related, but different note - the button needs to be displayed following the Room description, but I am having real difficulty positioning it. Wherever I put the 'Insert HTML' script which creates the buttons (I'm trying to position it by trying different parts of the Scriptstab for the Room), it displays between the line with the objects list and the line with the exits list. I though I had cracked it when I thought of putting it in Description, but putting anything other than text in there get rid of the rest of the room description.
I'm sorry I'm being such a noob pain, but your help is greatly appreciated.
Thanks
Sarah
Also, I really can't make head not tail of the add javascript thing. I've added javascript, but then when I try to call it , using the 'Call Function' option in 'Add Script' I get this error on running
Error: Error adding script attribute 'beforeenter' to element 'FeaturedProducts': Function not found: 'scoreThing'
the same function works beautifully when called from within HTML
This is why I have been calling the script from html files.
On a related, but different note - the button needs to be displayed following the Room description, but I am having real difficulty positioning it. Wherever I put the 'Insert HTML' script which creates the buttons (I'm trying to position it by trying different parts of the Scriptstab for the Room), it displays between the line with the objects list and the line with the exits list. I though I had cracked it when I thought of putting it in Description, but putting anything other than text in there get rid of the rest of the room description.
I'm sorry I'm being such a noob pain, but your help is greatly appreciated.
Thanks
Sarah