Quest transit system help. Require bus pass?

Hey there.
I am working on my little game, and I am trying to check if the user has a bus pass or not, if not they cannot ride the bus, if they do it is free.
I am not adding an option to pay with money.

My question is, how would I go about implementing this.

If player is carrying object (bus pass)....

I have tried cutting closing exists but it seems transit only uses them for coordinates.
Is there something else I can do?


I've seen a couple of guides for creating a transit system. The precise details would depend on how the one you are using works.

edit: advice not relevant to this particular system

My first thought would be to look at the exit(s) the player uses to get onto the bus. I've seen systems where there is one exit and it moves around, as well as systems where there are several exits but only one at a time is visible.
In either case, I'd try adding a script attribute to the exit (which is the "Run a script (instead of moving the player automatically)" checkbox on the exit).

My first guess for the script would be something like:

if (Got (bus pass)) {
  msg ("You board the bus and show your pass.")
  MoveObject (game.pov, this.to)
}
else {
  msg ("They won't let you on the bus without a pass.")
}

If that doesn't work, then I'd have to take a closer look at how your bus works before I could offer a suggestion.


Thanks for the quick reply!
I am actually using the transit system that is in the official tutorials, but I wasnt able to find any information about this.
http://docs.textadventures.co.uk/quest/transit_system.html

I hope this shows you what you need to help me figure this out lol :)


Ah, it looks like that's simpler than the systems I've seen discussed on the forums.

In that case, you could just modify the script to check if you have a bus pass instead of checking the player's money. The "catch bus" command would look something like:

if (not GetBoolean(player.parent, "busstop")) {
  msg ("No buses stop here.")
}
else if (not Got(bus pass)) {
  msg ("You need a bus pass to ride the bus.")
}
else {
  sl = NewStringList()
  foreach (key, game.destinations) {
    if (not ObjectDictionaryItem(game.destinations, key) = player.parent) {
      list add (sl, key)
    }
  }
  ShowMenu ("Where do you want to go?", sl, true) {
    dest = ObjectDictionaryItem(game.destinations, result)
    msg ("You take the bus to " + result)
    player.parent = dest
  }
}

Hmm that didnt seem to have worked.. it allows me to get on the bus without a bus pass..
One question though, when I convert the code back to gui view, it shows that it is setting a "flag" to the object in the top line of code.. is this intentional?
Do I need to ad something in the start script to be checking for the bus pass?


Does it give an error message at all?

What flag does it say it's setting?

You shouldn't need to do anything with the start script. Just make the bus pass an object.

if this isn't working, can you show your code?


I think the issue is in the top line, when it converts the code it says "if object does not have flag - expression player.parent flagname bussstop
print no busses here.

here is the code, its unchanged

  msg ("No buses stop here.")
}
else if (not Got(bus pass)) {
  msg ("You need a bus pass to ride the bus.")
}
else {
  sl = NewStringList()
  foreach (key, game.destinations) {
    if (not ObjectDictionaryItem(game.destinations, key) = player.parent) {
      list add (sl, key)
    }
  }
  ShowMenu ("Where do you want to go?", sl, true) {
    dest = ObjectDictionaryItem(game.destinations, result)
    msg ("You take the bus to " + result)
    player.parent = dest
  }
}```

That's not setting a flag. That's checking for the flag that the script uses to identify bus stops.

I'm sure that should work. Can you share the game so I can try it and see what's wrong?


How do I do that? I am a complete newb lol


If you're using the web version, you can press "publish" (and set it so that it's only accessible to people with the link, if you prefer), then paste the link. Or you could upload the file on some sharing site (Google Drive is good) so other people can download it. Or open the file in full code view and paste the whole thing between lines of ```.

I can't see any problems with that code, so there must be an issue somewhere else… I can't think what it could be, but there's a good chance something will jump out if I look at the code.


@ Mr Night:

you're getting on the bus, and you aren't getting the 'there are no busses here", so that means the issue is with this line of code:

else if (not Got(bus pass)) {
  msg ("You need a bus pass to ride the bus.")
}

as this 'else if' check, if you do NOT have the 'bus pass' Object in your inventory, you do NOT get on the bus.

yet, you ARE getting on the bus...

so, you must have the 'bus pass' Object in your inventory already, and that's why you're always getting on the bus.


I thought that too, but i can go hop on the bus from the start of the game with an empty inventory


the code works like this:

if condition check 1 fails (you do have the parent Object's 'busstop' Boolean Attribute's Value as 'true', so), goto condition check 2

if condition check 2 fails (you do have the 'bus pass' Object in your inventory, so), goto the 'catch all: else' condition

'else condition', you get on the bus


so...

  1. maybe your 'Got' Function isn't working correctly or the code for what is the 'inventory' isn't working correctly
  2. you got the 'bus pass' Object in your inventory, but its hidden (you can't see it)
  3. something is wrong with your transit code: it's not matching the library's transit code that mrangel posted: maybe you left out a 'not' in your code... make sure your code matches up exactly with mrangel's posted transit library code
  4. there might be an issue/incompatibility with pixie's most recent version of quest that you're using and with the transit library's code

Well I have followed the instructions to the best of my ability, ive gone over it now about 5 times and redone the entire transit system making sure i didnt miss anything.

I almost wondering if the code mrangel sent me is just in the wrong order


hmm... we can't really help until we see the code... we're just guessing at stuff... as we're blind here... without any code...

hopefully, your game isn't too big yet... and if you don't mind making your game code public:

just right click directly on your 'XXX.aslx' game file and choose to 'open' it, and select a text editor software (notepad, wordpad, Apple: text editor, notepad++, etc) to open it with

( highly recommend you download this really powerful and totally free text editor software, even if you don't ever plan on learning to code and to do coding, it's still really cool and useful as it has a lot of powerful editing controls/features, that I still need to learn and start using, lol: https://notepad-plus-plus.org )

and what you're seeing, now that you opened it, is your entire game code

highlight all of it, copy it, and paste it here, like so:

m```
(paste your entire game code here)
m```

those strange characters/symbols are from the tilde (~) key, just don't hold down the shift key (as this gives you the tilde, lol)

but without the m's in front, which will look like this:

(paste your entire game code here)

also... do the same for any libraries you're using (find your 'XXX.aslx' library files and do the same)

if you've been working online, then you got to 'publish' the game onto the quest servers/site, as this then allows you to download it onto your computer.

When you publish a game, it bundles/zips all of your files (your 'XXX.aslx' game file, any 'XXX.aslx' libraries files you might be using, and any picture/music/animation/vid files you've got) into a 'XXX.quest' publishing file

so, when you download it, you get the 'XXX.quest' publishing bundled/zipped file

you got to unbundle/unzip it (via using such unzipping/unbundling software: winrar, winzip, etc), to get at the 'XXX.aslx' game file and/or library files, so you can then open them up, to get at their code


if you don't want to make your game code public...

quest site now has a pm system again... but its got a character limit and is more clunky to work with...

so, best bet is to upload your code to some/whatever 3rd party site, and then send us the link for viewing it


OK ... it looks like you have the catch script in 3 different places.

  1. You have the "catch bus" command.
    This will be activated if the player types "catch bus".
    This includes the standard script, not the version I modified, so it will allow the player to ride the bus whether they have a pass or not.

  2. Then there is the "catch" verb on the bus stop.
    This would be run if the player types "catch bus stop" when they are in a location which also contains the bus stop.
    This is the standard script, and would tell the player "No busses stop here" because they aren't inside the bus stop.

  3. Then you have created a new script attribute "buspass".
    Running this script would allow the player to travel if they are carrying the bus pass, and say "You need a bus pass to ride the bus." if they aren't.
    This script is never run, because it isn't a command or a verb.

You need to paste the script I gave you into the "catch bus" command. Putting it in a script attribute doesn't do anything unless that script attribute is connected to the game somehow.


P.S.

if you're interested in learning quest's coding and code structure, and/or more about quest basics, and/or more advanced quest stuff:

http://textadventures.co.uk/forum/general/topic/ljjm32av4e2t9ot49k478g/help#710be61e-eae1-4af1-8363-520cc718ba1c

ask if you need help with anything and/or need any explanation of anything


ah, mrangel figured out your problem already:

it has to do with how the library's code that you're using, is set up... you've not put mrangel's code into all of the right places that it needs to be..


Oh man, thank you mr angel and hegemonkhan!

I will out this to practice when I get back to it and see what happens.

And as a side note, I actually use notepad ++ and sublime text editor for web development which is my day job, so I know it well, but mostly for JS, html and css lol.


So just to clarify, I am deleting the attribute I created, AND deleting what i put on the exit, and only putting that code on the command :D

Edit: I got it working, thank you very much guys!


for/in the notepad++, select the 'xml' language, as this matches up with quest's custom 'aslx' language, for the color coding of it, in notepad++


ah, another web developer... hehe :D

I only learned the basics of web page making (some/basic html and css usage), something that I need to get around learning more of (html, css, JS, etc web/scripting languages... and then there's all the mobile device / app-making languages too... argh) ... sighs...


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

Support

Forums