Having a link call a function in gamebook

duskdark
Not sure if I phrased that correctly, but basically I want to turn a flag on by a player clicking on a link in gamebook. The idea is I have created my own combat, class and stats system in gamebook, but I want to creat a shop. I would like to set it up so I dont have to create a different page with the turnflagon function for every item in the shop. Instead making a link from the shop back to itself that turns the flag on for me. Is this even possible in gamebook mode. I've tried commandlink and it wants a page instead of a function, and i tried <finction></function> but coulnt imbed it in a link.

hopefully I was descriptive enough in my question

duskdark
Oh, and I understand text adventure mode is better for this type thing, but i'm not confident in my scripting abilities enough yet to try it.

HegemonKhan
use the 'text box' (page type: [text] or [script+text]), and on the right side are some of the text commands (as well as typing in your own text commands):

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

though, I've still not worked with this text processor yet, still doing it the more complicated way with scripting (it's funny how I the code noob post thorough scripting, and Jay a code pro, posts simple text processor stuff, hehe, or maybe that's why I do it the harder way, whereas Jay does it the easiest way, hehe), so I can't help with any questions or problems you've got with using the text processor commands, but Jay and others can help you.

(one of these days, Jay, I'll get to learning the text processor, when I get more time in life to go back to learning to code more, sighs)

duskdark
Yeah, I've tried everything I can with the text processor stuff. I've also tried everything I could figure out in the script window. My issue is I need a way for a player turn on a flag (or set a variable) by clicking a link that returns hem to the same page.

jaynabonne
Here is a quick and dirty way to do it using custom HTML links and ASLEvent. You can directly invoke a function and pass it arguments. I'm whipping this out before work, so I just added it into my "gbtest" game, so there's some other stuff in there you don't need. Just focus on Page1 and the function SomeFunction. Basically, the link directly invokes that function with an argument string which is then set into a player parameter. You can have the function (or functions) do whatever you like, and the argument string can be whatever you like as well.

Important note: your function *must* accept a single argument, even if you don't use it for anything.

I just have the function redisplay the page with the new value, but (again) you can have it do what you like. Even set a flag. :)

For those who don't want to or can't open the attachment, the magic is in links like this:

<a class="cmdlink"  onclick="ASLEvent('SomeFunction','swords')">This is for swords</a><br>
<a class="cmdlink" onclick="ASLEvent('SomeFunction','shields')">This is for shields</a><br>

ASLEvent directly invokes a Quest function, passing it the argument string.

duskdark
Thank you so much, you have saved my day... I have spent the whole day reading old forum posts, trying different combinations of code and script, and climbing the wall. It took me a minute to get what you were saying (i don't know anything about anything... i need to take a couple classes lol) but you saved my Game!

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

Support

Forums