A few topics down from this one is the question about a password prompt. I was wondering if the prompt can be used to let the player type his own name, which can then be stored as a variable for use in the passages after (eg I type 'Jack', all passages name 'Jack' instead of 'PlayerName'). Is this possible?
::Macro textinput [script]
try {
version.extensions['textinput'] = {
major:1, minor:0, revision:0
};
macros['textinput'] = {
handler: function(place, macroName, params, parser) {
v = params[0].replace("$","");
var input= document.createElement('input');
input.type = "text";
d = v+"TextInput";
input.id = d;
input.addEventListener('keyup', function()
{
state.history[0].variables[v] = document.getElementById(d).value;
});
place.appendChild(input);
},
init: function() { var v; var d;},
};
} catch(e) {
throwError(place,"textinput Setup Error: "+e.message);
}
::Name Entry
Enter Your Name:
<<textinput $playerName>>
[[Say Hello]]
::Say Hello
Hello <<print $playerName>>!
try
{
version.extensions['textinput'] = {
major:1, minor:0, revision:0
};
macros['textinput'] = {
handler: function(place, macroName, params, parser) {
v = params[0].replace("$","");
var input= document.createElement('input');
input.type = "text";
d = v+"TextInput";
input.id = d;
input.defaultValue = params[1];
input.addEventListener('keyup', function()
{
state.history[0].variables[v] = document.getElementById(d).value;
});
place.appendChild(input);
},
init: function() { var v; var d;},
};
} catch(e) {
throwError(place,"textinput Setup Error: "+e.message);
}
Awesome! Thanks for this!
On Tuesday, February 5, 2013 9:36:48 PM UTC+1, HarmlessTrouble wrote:
Just use a regular link. There never was a button iirc.
> --
> You received this message because you are subscribed to a topic in the Google Groups "Tweecode / Twine" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/topic/tweecode/Rl-OhqTQvb4/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to tweecode+u...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
Were you able to get textinput working in 1.4? I'm getting the same issue as you. I have the text input box without the button and pressing enter does nothing.
input[type="text"] {
background-color: green;
}
.passage button {
color: red
}