Ticking off a list of actions.

Soulreapersword
01 Jul 2017, 12:00

Hey all, I'm new here. Just started writing my first story. I'm also a novice and programming and scripts.

I'm basically looking for a way to implement something like this:
John first decided to
-go to the bathroom
-get dressed
-eat breakfast
-look out the window

and as you complete each action it removes it from the list of available actions. Is there a way to do this without adding about 30 different pages, each with the same text and different numbers of links available? Thank you,

Bonus question, How do I make it so after say 2 choices, the player is forced onto another page (an interruption of some kind)? Thanks again :)


XanMag
01 Jul 2017, 13:51

I assume this is a game book, yes? And not a text adventure.


Soulreapersword
01 Jul 2017, 15:19

Game book, yes.


major powers
01 Jul 2017, 17:58

This is how I would do it.

Use "HasSeenPage" on all the pages and then tell it to remove the relevant links. As such:

AddPageLink (ThePageYoureOn, BathroomPage, "Link text here")
AddPageLink (ThePageYoureOn, DressedPage, "Link text here")
AddPageLink (ThePageYoureOn, BreakfastPage, "Link text here")
AddPageLink (ThePageYoureOn, WindowPage, "Link text here")
if (HasSeenPage(BathroomPage)) {
  RemovePageLink (ThePageYoureOn, BathroomPage)
}
if (HasSeenPage(DressedPage)) {
  RemovePageLink (ThePageYoureOn, DressedPage)
}
if (HasSeenPage(BreakfastPage)) {
  RemovePageLink (ThePageYoureOn, BreakfastPage)
}
if (HasSeenPage(BathroomPage)) {
  RemovePageLink (ThePageYoureOn, WindowPage)
}

Then on each of those four pages, set a relevantly named flag on to use later:

SetFlagOn ("Bathroom")

Then add this to every page. You can have the Gamebook check for as many flags as you like (keep adding "and"s and parentheses). Then this will force them to a new page if the desired flags are set:

if (GetBoolean(game, "Bathroom") and (GetBoolean(game, "Window"))) {
  MovePlayer (ANewPageHere)
}

This can all be typed in by hand if you go to code view. When you go back to GUI view, you'll see how the game entered it in for you.


major powers
01 Jul 2017, 18:32

By the way, using flags makes more work for you if you want them to be able to do those four things (bathroom, window, breakfast, get dressed) in any order whatsoever, and then move them to a new page if they've done any combination of two of those things. In that instance, a relatively easy way is to set a counter on the first page. I'm calling it PageCounter1:

SetCounter ("PageCounter1", 0)

Then on each of the four pages, increase the counter as such:

IncreaseCounter ("PageCounter1")

Then, also on each of the four pages, put this in. This will check to see if the counter has been increased to 2 (meaning you've visited any two of the four pages). This will force the player to a new page:

if (GetInt(game, "PageCounter1") = 2) {
  MovePlayer (ANewPageHere)
}

Richard Headkid
08 Jul 2017, 19:41

Hello all!

How might one pull this off in a Quest text adventure?

UPDATE: I asked just before I found the answer. (I think.) It looks like a list is the way to go. I can add to the list with each score increase to keep track of 'The Story So Far'.


The Pixie
08 Jul 2017, 21:14

There is a guide that might be useful:
http://docs.textadventures.co.uk/quest/keeping_a_journal.html

I am experimenting with a quest library. This may not be the final version, but might do what you want (requires Quest 5.7):
https://github.com/ThePix/quest/wiki/Quest-Library


Richard Headkid
08 Jul 2017, 21:34

@The Pixie

Thanks!


Doctor Agon
08 Jul 2017, 22:14

Hi Pixie, was looking at some sort of Quest/Task List myself, but attaching it to the Journal function using ListAdd/ListRemove. Just looking through the tutorial notes, What if the player eats the apple? Go to the attributes tab and find eat(in grey). Do you mean 'feature_edible' or do you have to add a verb 'eat'.

Update: Added a verb 'eat' and that bit seems to work ok. I've encountered an issue though, having got the apple and after giving the apple to Mary, if you then speak to Mary for the first time, she asks 'Where's that apple' instead of 'Thanks for the apple'.

Update: Used the following in the 'speak to' verb script, changing the first 'Else If...' statement to check if the QuestState has been successful

if (apple.parent = null) {
  msg ("Well I was going to ask you for an apple...")
}
else if (QuestState(apple_for_mary) = "Successful") {
  msg ("Thanks for the apple.")
}
else if (QuestState(apple_for_mary) = "Inactive") {
  msg ("Can you get me an apple please?")
  QuestStart (apple_for_mary, "Get an apple for Mary")
}
else {
  msg ("Where's that apple?")
}

Will be using these new functions in my adventure.

Thanks Pixie


hegemonkhan
09 Jul 2017, 03:27

my guide on Lists/Dictionaries:

http://textadventures.co.uk/forum/samples/topic/5137/list-and-dictionary-extensive-guide-by-hk

and this 'explore' and 'travel' sample code of mine, removes the 'discover new land events' items from the list (not the best code --- has some mistakes/inefficient code as I got confused with the 'ListCount(xxx) - 1 / index' stuff as this was backwhen I was first learning lists/dictionaries, but it works):

http://textadventures.co.uk/forum/samples/topic/5138/explore-and-travel-code-sample-by-hk

to have a chance of undrstanding it easier:

  1. start with the 'explore_function' Function (only got a case for the 'homeland', but can be easy to set up more cases for each of the other lands/areas). when you 'explore' the homeland, there's random events (only new land/area discovery events, but can easily add whatever events), and since these are one-time only events, I handle removing them from the 'data_object.homeland_event_stringlist' list, so when you 'explore' the 'homeland' again, you can't get that same discover-land/area event again.

  2. next look at the 'data_object.homeland_events_scriptdictionary', which is called/activated by 'explore' the 'homeland' action, and which adds this land/area to your travel list, now allowing you to travel to this new land/area.

  3. last is the 'travel_function' which moves you amongst the lands/areas (intentional attempt at designing a game that doesn't use Exits (this was back when I was first learning to use lists/dictionaries and trying to do this type of design of no Exits for travel)


The Pixie
09 Jul 2017, 08:07

Doctor Agon, thanks, I have updated the library tutorial with you code.