Creating a hyperlink which runs a script

OurJud
I suspect I should know how to do this, but I really can't work it out. Nor can I find any documentation that answers my question.

I don't like the 'wait x seconds' feature, and I'm none too keen on the 'wait for key press' either. For those reason I want to create an underlined link which when pressed will trigger a 'move player' script.

TIA

HegemonKhan
text processor commands for the Command hyperlinks:

http://docs.textadventures.co.uk/quest/ ... essor.html

msg ("text {command:your_command_pattern_here:what_you_want_the_hyperlink_to_say_or_be_named/called} text")

and to create your own Commands:

http://docs.textadventures.co.uk/quest/ ... mmand.html

--------------

here's a quick example:

<game name="xxx">
<start type="Script">
msg ("Click on this hyperlink: {command:info:character information}, to see your character's stats")
</start>
</game>

<command name="example_command">
<pattern>info</pattern>
<script>
ClearScreen
msg ("Name: " + player.alias)
msg ("Strength: " + player.strength)
// etc etc etc player stats
wait {
ClearScreen
}
</script>
</command>


--------------------------------

if you want to see the full potential of this:

viewtopic.php?f=18&t=4057&hilit=levellib (Pixie's+Jay's stat choosing-raising "Command UI" Level Up Library)

OurJud
Thanks, HK, but converting that to give me a link which moves a player to another room is beyond me.

And I need to do it in the UI, not in the game's main code.

I'd have thought there would be a 'Create link' script in the UI. Something like:

Link ("Begin...")
OnClick {
MoveObject (player, forest)
}

jaynabonne
It would be a bit tricky to try to include full script capabilities in text markup. The straightforward way is what HK said: create a command to do what you want and then invoke the command. The command gives you place to put the script.

I also wrote a command once which (as argument) took the name of a script to run. That way, I'd have a single command that I could use to invoke multiple scripts. I could dig that up if it would be useful.

But either way, you need a command to run, which (if you have a command line input) means the player could probably type in the same thing. You could make the command text obscure enough or only have the command available where you need it, to minimize that possibility.

So that's two useful potential command processor extensions now: one to call a script to generate the text to insert, and another which allows calling a script when clicked!

OurJud
So, I click on the room in question, 'Add a command', give it the pattern of 'Begin...' and run a script which moves the player.

And then in the room I do what?

msg ("Begin... {command:Begin...}")

jaynabonne
It would actually be:

msg ("{command:Begin...:Begin...}")

The string after the first colon is the command to run, and the string after the second colon is the string to put in the link.

jaynabonne
(And they don't have to be the same string. Your command can be text like "-BEGINCOMMAND-" or something else obscure. But it can be what you want (more or less).)

OurJud
Okay, I think I got that. Thanks everyone.

Can I just say, for future reference, that I still need things spelling out for me. I appreciate that if I can figure things out for myself when people point me in the general direction, I would probably learn more, but my brain doesn't work like that.

I hope that doesn't come across as ungrateful, but if I can save those who help me the headache of having to explain things over and over, then that's good, isn't it?

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

Support

Forums