Different reaction when entering same location second time

OurJud
Sorry for all the questions. I am trying the tutorials and things, to try and figure them out for myself, but I'm finding it all a little puzzling.

I want a slightly different scenario to play out, if my player decides to enter the same location twice.

This is the set-up for my Gamebook adventure:

Location A: Outside a shop (one of the options here is 'Enter shop')

Location B: Inside the shop (woman behind the counter asks, "Can I help you?" When the player has finished in the shop, he is given the option "Leave shop"

This command naturally returns him to Location A.

At this point, I want to either remove the 'Enter shop' option, or preferably have it remain, but if the player enters the shop a second time, have the woman say something different like "Back already?"

I know I could do this by simply creating separate pages, but for reasons of memory and load speeds, I don't want to have to create separate pages for the same location, just so I can have a different scenario if the player enters twice.

Silver
You can run an 'on first time' script. the trouble is I'm not sure if the scripts are available for game books. That's why it's sometimes better to use the quest text adventure engine and make it look like a game book so you get all the scripts etc.

HegemonKhan
useful link for you:

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

and here's the 'firsttime~otherwise' Script ( http://docs.textadventures.co.uk/quest/ ... ttime.html ), which is what you want.

also, you can just make an event flag counter attribute too:

game.counter_integer = 0

(and have scripting game events change it's value)

then for your 'check' scripts:

if (game.counter_integer = 0) {
// do script 1
} else if (game.counter_integer = 1) {
// do script 2
} else if (game.counter_integer = 2) {
// do script 3
} else ... etc etc etc
}

an example:

game.dialogue_event_flag_integer = 0

npc1 (or page4 for Gamebook version):

if (game.dialogue_event_flag_integer = 0) {
msg ("hello, I'm no one important.")
} else if (game.dialogue_event_flag_integer = 1) {
msg ("Oh, hi again, here's a wooden sword for you.")
} else (game.dialogue_event_flag_integer = 100) {
msg ("Muwahaha, you finally found the final bad guy in the game, me, now you die!")

jaynabonne
Check out the text processor: http://docs.textadventures.co.uk/quest/ ... essor.html

To do what you want, just add this text:

{if not Page1.visited:Can I help you?}{if Page1.visited:Back already?}


No funky scripting needed. Just nice in-text markup... (To be honest, the "visited" part is not really documented, but it works. It's an attribute automatically set by Quest when you visit a room.)

OurJud
Thank you, all - much appreciated.

I've got that working how I want it now, but may I just sneak in a question regarding scripts?

I've seen lots of answer to questions on this forum, where people provide blocks of code/script (as above). The thing is, I have absolutely no idea how or where I'm supposed to insert this code??

Jaynabonne, I exclude your method from this, as I can clearly see what you're telling me to do, but the larger blocks of script... where do they go??

HegemonKhan
code is quick and easy to post, but obviously not of much help to all those who don't know how to code~program and~or quest's code. It's usually me who posts code, and in the past I've posted GUI~Editor help, but it takes much longer to do so for me, time which I don't have anymore now that I'm working.

So, just ignore my code posts if you don't understand them, and wait for Jay or the others to help you via the GUI~Editor.

the two super scripts, which especially when used together, let's you do 90% of everything that you want to do within your game, are:

1. the 'set a variable or attribute' Script:

in the GUI~Editor: run as script (Gamebook version: set your 'pageX' as a 'script' or 'script+text' ) -> add a script -> variables -> 'set a variable or attribute' Script -> [EXPRESSION] -> Object_name.Attribute_name = Value_or_Expression

// instead of choosing [EXPRESSION] where you have to write~type in the code syntax, you can choose the other more non-code friendly options (I've not really worked with the GUI~Editor, so I just prefer using [EXPRESSION] as I can jsut type~write in the code that I want, instead of trying to figure out what options do what I want it to do, lol.

examples the general syntax (Object_name.Attribute_name = Value_or_Expression) above:

Gamebook version only has two Objects for you to use: 'game' and 'player'

for my own naming~labeling convention~system, I like to '_AttributeType' at the end of my Attribute's NAME (and underscores for spaces), examples:

player.strength_integer = 100
player.strength_string = "strong"
orc.dead_boolean = false
player.head_object = helmet
player.favorite_color_stringlist = split ("black;red", ";")

String Type Attributes:

player.alias = "HK"
player.age = "adult"

player.gender2 = "male"
// 'gender2' is used here by me as there's already the default 'gender' (and 'article' too) String Attribute(s) for using the 'he~she~it~him~her" (I never remember what 'gender' and 'article' match up to: 'he~she~it' and 'him~her', lol), if I used 'gender', it would OVER-RIDE the default 'gender', removing this~its functionality of 'his~her~he~she~it' from the game.

Integer Type Attributes:

player.strength = 100
game.strength = 100
orc.strength = 50

// example of a complex '=Expression' (vs instead of a simple '=Value' above), below:
player.damage = player.weapon_damage + player.weapon_damage * player.strength / 100 - orc.armor_class - orc.armor_class * orc.endurance / 100

Double Type Attributes:

player.damage = 46.065

Boolean (or Flag) Attributes:

orc.dead = false
player.flying = true

etc etc etc (the other Attribute Types are more complicated to work with, so leaving them out for this)

2. the 'if' Script:

in the GUI~Editor:

run as script (Gamebook version: set your 'pageX' as a 'script' or 'script+text' ) -> add a script -> scripts -> 'if' Script -> [EXPRESSION] -> (Object_name.Attribute_name = Value_or_Expression) ->
-> then -> add a script -> variables -> 'set a variable or attribute' Script -> [EXPRESSION] -> (Object_name.Attribute_name = Value_or_Expression) ->
else if -> [EXPRESSION] -> ((Object_name.Attribute_name = Value_or_Expression) ->
-> then -> add a script -> variables -> 'set a variable or attribute' Script -> [EXPRESSION] -> (Object_name.Attribute_name = Value_or_Expression) ->
else ->
-> add a script -> variables -> 'set a variable or attribute' Script -> [EXPRESSION] -> (Object_name.Attribute_name = Value_or_Expression) ->

----------

so, when used together, you can do pretty much anything, an example (in code):

Character Creation:

Text Adventure version

Full Game (well, it's not really much of a game though, laughs) Code

<asl version="550">
<include ref="English.aslx" />
<include ref="Core.aslx" />
<game name="blah">
<gameid>an_algorithm_generated_unique_string</gameid>
<version>1.0</version>
<firstpublished>2014</firstpublished>
<start type="script">
msg ("What is your name?")
get input {
player.alias = result
show menu ("What is your gender?", split ("male;female", ";"), false) {
player.gender_string = result
show menu ("What is your race?", split ("human;dwarf;elf", ";"), false) {
player.race_string = result
msg ("")
msg (player.alias + " is a " + player.gender_string + " " + player.race_string + ".")
if (player.race_string = "human") {
player.strength_integer = 1
player.intelligence_integer = 1
if (player.gender_string = "male") {
player.strength_integer = player.strength_integer + 1
} else if (player.gender_string = "female") {
player.intelligence_integer = player.intelligence_integer + 1
}
} else if (player.race_string = "dwarf") {
player.strength_integer = 2
if (player.gender_string = "male") {
player.strength_integer = player.strength_integer + 1
} else if (player.gender_string = "female") {
player.intelligence_integer = player.intelligence_integer + 1
}
} else if (player.race_string = "elf") {
player.intelligence_integer = 2
if (player.gender_string = "male") {
player.strength_integer = player.strength_integer + 1
} else if (player.gender_string = "female") {
player.intelligence_integer = player.intelligence_integer + 1
}
}
}
}
}
</start>
</game>
<object name="room">
<inherit name="editor_room" />
<object name="player">
<inherit name="editor_object" />
<inherit name="editor_player" />
</object>
</object>
</asl>

jaynabonne
In case you missed it, the answer to your question was this parenthetical bit of HK's response: :)

Gamebook version: set your 'pageX' as a 'script' or 'script+text'

Hopefully, if someone gives you some code to use to solve a problem (as opposed to general scripting patterns), they will also tell you where exactly to put it.

OurJud
Thank you again, both.

HK, thanks for going to the trouble of posting all that. I can't pretend it's anything other than extremely daunting right now, but I do appreciate it.

Rather than post the identical question - which is now slipping down the forum unanswered, could I use the UI to fade the text of the previous location? I'm using light grey text on a black background, and don't have the 'clear screen for each new page' option ticked, and therefore want to 'dim' the text of the previous location to make it clearer where my player is up to.

Also, another unanswered question I have: Can I remove the underline from the links (Gamebook mode)?

HegemonKhan
I believe Jay's in-text (text processor) code, also goes here too (after you set your pageX to being a 'script' or 'script+text'):

pageX as being a 'script' only:

run as script -> add a script -> output -> print a message -> [EXPRESSION] -> copy and paste Jay's code (or write your own using Jay's example)

pageX as being a 'script+text' :

there should (also) be a text box... just type (or copy->paste) in Jay's code, or your own using Jay's code as an example, into this text box.

-------

ya, it's daunting (I too was a total noob to quest and to coding~programming myself about 2-3 years ago), if you want to see how overwhelmed I myself was check out my own noob thread:

viewtopic.php?t=3348

I was so confused just by all of the terms... laughs...

-------

I tried to explain a bit more for you with using the GUI~Editor (though it's not explanatorily detailed) in my last post

--------

, but ya, ignore my code stuff, as it is daunting, but if you at some point want to learn quest's code, then come back to my code posts, and try to learn them, and feel free to ask for any help, when you want to learn quest's code.

OurJud
Thanks, HK, I actually understood that last bit and think I could follow that easily enough.

HegemonKhan
see my last post or 2 posts, as I edited in more content... sorry about that.

OurJud
HegemonKhan wrote:see my last post or 2 posts, as I edited in more content... sorry about that.


Ah, OK. Thanks.

OurJud
Oh, sorry, I thought you were saying you'd edited to answer my two questions about removing underline from links and fading the text of the last location.

HegemonKhan
I don't know how to do those other questions you have, wait for Jay or others to answer them for you.

very useful links (though most of them do involve using~putting code lines into your game code ~ or you'll have to figure out how to do them via the GUI~Editor's options, but the 'tutorial' and 'guides' do have some good GUI~Editor help with pics too!):

http://docs.textadventures.co.uk/quest/
http://docs.textadventures.co.uk/quest/ ... notes.html
http://docs.textadventures.co.uk/quest/tutorial/
http://docs.textadventures.co.uk/quest/guides/
http://docs.textadventures.co.uk/quest/ ... aries.html
http://docs.textadventures.co.uk/quest/ ... aries.html
viewforum.php?f=18 (more guides: libraries and code samples)

----

maybe these might do what you want (don't know as I haven't ever used them yet):

http://docs.textadventures.co.uk/quest/ ... riter.html
http://docs.textadventures.co.uk/quest/ ... amble.html (this sounds promising ~ what you want)

hope this helps (ask if you need help with using them).

OurJud
Thanks very much, Hegemon.

Neither of those last two are what I want to do. *Annoyingly I found a thread where someone had asked exactly the same question AND been given an answer, but I'm damned if I can find it now.

Ah well, onwards for now.

* Found it!

viewtopic.php?f=10&t=4590&p=30115&hilit=black+background#p30115

OurJud
The above is obviously for a TA. Can I still use it for a GB?

Same problem as before, how do I enter this script???

I go to Game >> Add new script... but then I don't know what I'm supposed to do from there...

jaynabonne
Yes, I was just looking at that. Unfortunately, it doesn't work in Gamebook mode, as game books don't support turnscripts. So I've been trying to find a different method, and I found one. (I hope you're using the downloaded desktop Quest. Otherwise it's probably not possible to do.)

An important note: BE SURE TO SAVE A COPY OF YOUR GAME FILE BEFORE ATTEMPTING THIS.

You can use a "roomenter" game script attribute to perform the same function as a turnscript. Also unfortunately, the class name that code uses doesn't exist in GB mode either. So I came up with a bit of a hack. :) The code is this:


<roomenter type="script">
JS.eval ("$('div[id^=\"divOutputAlign\"]').css('opacity', '0.5');")
JS.eval("getCurrentDiv().css('opacity', '1.0');")
</roomenter>

That is an attribute to be added to the game object. You can do that in code view (if you dare!). It's not actually that hard. Here is what my game object looks like with the change:

  <game name="gbtest">
<gameid>1cbef79e-ceee-41de-a6fb-f268af68a718</gameid>
<version>1.0</version>
<firstpublished>2014</firstpublished>
<roomenter type="script">
JS.eval ("$('div[id^=\"divOutputAlign\"]').css('opacity', '0.5');")
JS.eval("getCurrentDiv().css('opacity', '1.0');")
</roomenter>
</game>

As you can see, the new roomenter attribute just needs to be inserted before the line with the </game> closing tag.

If you get stuck, post your game file, and I'll add it for you and send it back.

jaynabonne
Here is a screen capture of what it looks like in the GUI editor. I'm not sure that's any easier, but...

dimgbdiv.png

The text on the two lines is:

eval ("$('div[id^=\"divOutputAlign\"]').css('opacity', '0.5');")

and

eval ("getCurrentDiv().css('opacity', '1.0');")

OurJud
Ok.

I have downloaded the the software, but have been creating in online so far. However, I'm not so far in that I can't just copy and paste everything over if needs be.

I'll try it online first, if I can get my head around your and JB's instructions. Will report back later.

Thanks,

OurJud
HALLELUJAH!

Thank you so much, both of you.

I entered the javascript and it works like an absolute dream - online too!

jaynabonne
Great! :)

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

Support

Forums