Open bar question

improvstartrek
17 Sept 2016, 20:18

Apologies, I do realize that this type of question is quite common, and I've read a number Forum answers that answer questions very similar to mine, but I'm afraid I can't quite work out how to do what I'm going for and this Forum seems very responsive and helpful.

I'm a Mac user working exclusively in the online editor, and my goal is this:
-Open Bar
-No Cash System
-Set Menu of Drinks (kept as objects with individual traits under "none" location)
-Bartender will you give any drink you request, as many times as you ask, as long as you've drank the drink of the same type that you've already been given.
-To track this whether or not the player has drank their drink, my plan was to return the object to "none" and reduced the counter when they take the drink action.

My question is this: Is this the best way to handle this? I'm trying to use expressions so that I don't need to write a command for every individual drink, but my best efforts so far have failed.

  if (GetInt(#object#, "number") < 1) {
    MoveObject (#object#, Bar)
    msg ("\"Here ya go!\"")
    IncreaseObjectCounter (#object#, "number")
  }
} 

improvstartrek
17 Sept 2016, 20:21

A screenshot of my current attempts, if it's helpful. I'm prepared to hear I'm completely off base here.


hegemonkhan
17 Sept 2016, 20:42

just some quick hints/help for you:


Commands use these below as its Parameter VARIABLES:

#text#
#textXXX#

#object#
#objectXXX#

the '#text#' assumes that the input is a string, for its usage of it
the '#object#' assumes that the input is the name/reference of an Object, for its usage of it

my 'XXX' just means that you can replace it with whatever letters, numbers, and/or a few other symbols, too. You just have to have it start with '#text/#object' and end with '#'

what the #'s are programmed to do for a Command's 'pattern', is to put whatever you type in for your input during game play, into the correspondingly-same-named Variables but without the #'s:

'#text#' Parameter VARIABLE -> 'text' Variable VARIABLE = YOUR_TYPED_IN_INPUT
'#text123456789' Parameter VARIABLE -> 'text123456789' Variable VARIABLE = YOUR_TYPED_IN_INPUT

so, in your scripting, you would use, for example :

// using #text#:
msg (text)
// outputs your input

// using #text123456789#:
msg (text123456789)
// outputs your input

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

another (lame) example (just to show using multiple Parameters):

// you type in during game play:
// mix snail toad ginger

<command name="mix_command">
  <pattern>mix #text1# #text2# #text3#</pattern>
  <script>
    if (text1 = "snail" and text2 = "toad" and text3 = "ginger") {
      player.potion = "weird potion"
    }
  <script>
</command>


this helps with understanding/using a 'menu' design:

http://docs.textadventures.co.uk/quest/guides/character_creation.html


as for more details on using Attributes and the 'if' Script:

http://textadventures.co.uk/forum/samples/topic/5559/attributes-and-if-script-guide-by-hk


and here's a bunch of guides that are very helpful:

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


also, if you're able to (this is a bit more advanced), you may want to look into using List Attributes:

http://docs.textadventures.co.uk/quest/guides/using_lists.html


if you still need help, let me/us know!


hegemonkhan
17 Sept 2016, 21:01

you almost got it right:

  1. you don't need the parenthesis in your first script line: (object = "Sea Breeze" or object = " Whiskey")
  2. remove the pound/hash encasing your 'object' Variable in your clone object script line: #object#
  3. also in your clone object script line, you want to move your cloned object to: player (replace 'object' with 'player')
  4. see my 'Attribute and If Script' link for understanding and/or on how to correctly do counters (addition)

improvstartrek
17 Sept 2016, 21:46

So I thought I already understood what you're saying here, but I must still be confused on some points since I don't know why the scripts I've set up won't work.

FWIW, I am using expressions with #text# successfully to get outputs that include players inputs. ie: addressing NPCs in a room of people of getting different responses based on who they address; or using a voice-controlled lift that works by having the player state their destination.

It's the switch to #object# that seems to have me confused. So let me ask specifically: is there syntax I should be using so that the #object# from the player input becomes the Object being moved by the move command. Or is it a situation where the input can only be output in messages, not in the internal scripts themselves.


improvstartrek
17 Sept 2016, 23:18

Thank you for the syntax help, that's exactly what I needed.

I took a look at your tutorial on counters, and I realized there was a simpler option for me (important because of both my limited skills and the fact that the web interface doesn't offer access to the Attributes tab). Instead of cloning the object and using a counter, I'm simply using a flag to indicate whether the drink is poured or not, and moving the same Object back and forth between the Bar Room and the none Room. I realize it's more limited but will be sufficient to what the game needs. Sorry that didn't occur to me to do that before starting this thread.

I hope its okay to ask you a trouble-shooting question, because now that I've made your syntax changes I'm running into another issue.

1)Ordering something from the list in the game that's in the nonenow generates the message:

"I can't see that."

I'm not sure what settings I need to change so that the drinks don't need be visible for the player to order them.

2)In the course of troubleshooting I tried starting with the Sea Breeze in the Bar, and despite meeting the If condition (object = "Sea Breeze") the output was the If Else response (We don't serve that here).

Any ideas on where I should looking for the source of these behaviors?


hegemonkhan
18 Sept 2016, 07:52

your top script line needs to be:

(note: it's better to NOT have spaces for/in your names of things, due to parsing issues, I personally like using underscores)

object.name = "Sea Breeze" or object.name = "Whiskey"
~OR~
object = Sea Breeze or object = Whiskey


if/when you use the '#object# Parameter VARIABLE, quest ONLY searches the room you're in, for looking for the inputted Object

you're going to have to do some different scripting:

http://docs.textadventures.co.uk/quest/functions/contains.html

if (Contains (none, Sea Breeze) or Contains (none, Whiskey)) { /* scripts */

there's also the 'visible' and 'scenery' built-in Boolean Attributes:

http://docs.textadventures.co.uk/quest/attributes/scenery.html
http://docs.textadventures.co.uk/quest/attributes/visible.html


The Pixie
18 Sept 2016, 11:44

For #object# to work, you need the object to be in the room or inventory, so the whiskey object would need to start in the bar, but be set to be scenery so the player does not see it. Set it back to scenery when the drink is finished and moved back.

Rather than have a counter, just see where the object is; if the player has it, it cannot be ordered again.

A problem you have is that your ORDER command should check if this object is a drink. You do not want ORDER BAR TENDER or ORDER SHIRT to work. Or DRINK BAR TENDER either.

As you are restricted to the on-line editor, you cannot set custom attributes or types, so I cannot see a neat way to do this. What you could do is give each drink a name that starts "drink", as well as an alias that is the real name the player will see and use. You could than test if the name starts "drink".


improvstartrek
18 Sept 2016, 22:42

Thank you both, I'll experiment with the Contains scripting and the scenery options. It may be that the exact behavior I'm looking for isn't possible to create in the online editor, but thanks for your efforts to help with the work around. It may be that I'll just need to create individual "If" and "Else If" for each drink(using #text# expressions instead of #object#s), which will be a little tedious but probably less work in the long run than setting up VM to use the app with.