HTML, Quest and the Text Processor

Avantar
28 Nov 2014, 09:32
I was just wondering how possible the following is:

Firstly, I do not know a thing about HTML apart from what I Google :-)
But if I would like to make use of check boxes in the Text Processor like: <input type="checkbox" name="vehicle" value="Car" checked> I have a car<br>
Would it be possible to determine if the box is checked or not?
Something like: If the box is checked set variable.game.pov.car = 1 or true or whatever.

Thank you in advance for any advice provided.

jaynabonne
28 Nov 2014, 10:19
You can't really query the checkbox to see if it's checked without really hacky convolutions. However, you can get notification when it changes. So if it's in a known state to begin with, you can toggle your internal variable whenever it changes. Attached is a sample that does it. The code is also here:

<!--Saved by Quest 5.5.5328.26617-->
<asl version="550">
<include ref="English.aslx" />
<include ref="Core.aslx" />
<game name="checkboxcheck">
<gameid>876b3029-23fc-47bb-b969-e1146e999f20</gameid>
<version>1.0</version>
<firstpublished>2014</firstpublished>
</game>
<object name="room">
<inherit name="editor_room" />
<description><![CDATA[<br/>Vehicle:<br/><input type="checkbox" name="vehicle" checked onchange="ASLEvent('VehicleCheckChanged','car')"> Car<br/><input type="checkbox" name="vehicle" checked onchange="ASLEvent('VehicleCheckChanged','motorcycle')"> Motorcycle<br/><br/>]]></description>
<object name="player">
<inherit name="editor_object" />
<inherit name="editor_player" />
</object>
</object>
<object name="vehicles">
<car type="boolean">true</car>
<motorcycle type="boolean">true</motorcycle>
</object>
<function name="VehicleCheckChanged" parameters="param">
set(vehicles, param, not GetBoolean(vehicles, param))
msg ("Checkbox '" + param + "' changed to " + GetBoolean(vehicles, param) + "!")
</function>
</asl>

jaynabonne
28 Nov 2014, 10:24
Given your setup, you might want this more. This one uses radio buttons. It turns out it's simpler since the event only comes in for the newly selected one.

Attached and inline as before.

<!--Saved by Quest 5.5.5328.26617-->
<asl version="550">
<include ref="English.aslx" />
<include ref="Core.aslx" />
<game name="radiobuttontest">
<gameid>876b3029-23fc-47bb-b969-e1146e999f20</gameid>
<version>1.0</version>
<firstpublished>2014</firstpublished>
</game>
<object name="room">
<inherit name="editor_room" />
<description><![CDATA[<br/>I have a:<br/><input type="radio" name="vehicle" checked onchange="ASLEvent('VehicleCheckChanged','car')"> Car<br/><input type="radio" name="vehicle" checked onchange="ASLEvent('VehicleCheckChanged','motorcycle')"> Motorcycle<br/><br/>]]></description>
<object name="player">
<inherit name="editor_object" />
<inherit name="editor_player" />
<vehicle type="string"/>
</object>
</object>

<function name="VehicleCheckChanged" parameters="param">
player.vehicle = param
msg ("Player vehicle is a " + player.vehicle + "!")
</function>
</asl>

Avantar
28 Nov 2014, 10:31
Thank you very much!
I will have a look at the first one first - basically just want you to select from a list of things that is available to you. Doing it from a menu is just not going to look nice or work too well for me. What can be easier than ticking off the stuff you want? :-)
Appreciate the effort of posting code and everything in a short space of time.

Avantar
28 Nov 2014, 12:40
Yes, I will go with the first option - Sorry for just grabbing an example and post it.(took the example from the Internet) I will be a bit more clear when posting next.
Very considerate of posting the radio button example too.
I had a look at both and the first one is surely what I will need.
Basically it is to select your Skills/Talents/Feats for your level - the attached file might give the idea what I am trying to do:

Avantar
29 Nov 2014, 08:13
Is there a way the make the checked/unchecked property a variable that reads its value from an attribute?
So if you have:
<input type="checkbox" disabled checked>Simple Weapon Proficiency replace the actual checked value with say feats.status ?

Avantar
29 Nov 2014, 18:41
To answer this for anyone that also might find it useful:
You will have to use scripting even if you call the function from the text processor. You will put your HTML checkbox inside the standard message printing and call the variable in there.
This is useful for the following:
Some Feats can only be chosen when some criteria is met, otherwise they should be disabled. When choosing and accepting the Feat, it should be checked and disabled and you only have a certain amount of feats you can choose from per level and once your selected your quota - the rest of the checkboxes should be disabled.
It is pretty straight forward to set attributes and conditions from a function, but to display a textbox, dynamically have it checked, unchecked and disabled does not seem possible from the text processor and therefore this would be my answer:
msg ("<input type=checkbox "+object.attribute+" disabled=disabled>Simple checkbox")

This will display the checkbox and get it's checked property from an attribute and set it to disabled, that of course can also be replaced by an attribute.