light a cigarette?

mblann
so, I want my player to be able to light a cigarette. But he has to have matches to do so. So far I have cigarettes as an object on the player...and matches located elsewhere. Once the matches are "taken" I can't seem to "use" them to light the cigarette. Any suggestions?

Thanks in advance.

HegemonKhan
here's some links for you:

http://docs.textadventures.co.uk/quest/
http://docs.textadventures.co.uk/quest/tutorial/
http://docs.textadventures.co.uk/quest/ ... jects.html
http://docs.textadventures.co.uk/quest/ ... ripts.html
http://docs.textadventures.co.uk/quest/ ... jects.html

----------

I'm too lazy to look up on how to use the default 'use' Function, but one such example conceptually of what you can do:

'cigarette' (Object) -> 'light' (Verb) -> (see below, this is in code, hopefully you can fingure out how to do it in~via the GUI~Editor, as I'm tired, I've been doing a lot of posting today, lol)

if (matches.parent = player and cigarette.parent = player) {
cigarette.lit = true
msg ("You light the cigarette using the matches that you've got in your hand.")
} else if (matches.parent = player and not cigarette.parent = player) {
msg ("You need a cigarette in your hand, in order to be able to light it.")
} else if (not matches.parent = player and cigarette.parent = player) {
msg ("You need matches in your hand, in order to be able to light the cigarette.")
} else if (not matches.parent = player and not cigarette.parent = player) {
msg ("You need both a cigarette and matches, in your hands, in order to be able to light a cigarette.")
}


the 'light' Verb is a custom (self made~added) Verb
the 'lit' is a custom (self made~added) Boolean~Flag Attribute ('Set flag on')

you'd then want some script for what happens if your cigarette is lit:

if (player.cigarette.lit = true) {
player.stress = player.stress - 50
msg ("Your nerves are calmed, due to the chemicals being inhaled.")
}

OurJud
I imagine it would be the same as my key/safe puzzle I did earlier. In which case, and presuming both cigs and matches are objects:

Select the cigarettes in the side panel >>
Verbs tab (main panel) >>
Add (either select something suitable from the list) or add your own, such as smoke >>
Change 'Print message' to 'Run a script' >>
Add new script >>
If >>
Open the 'expression and change to 'Player is carrying object' >>
pick 'matches' from the drop down >>
Add new script >>
Print a message >>
Type your message, i.e "You light the cigarette" >>
Add Else If >>
'Player is NOT carrying object' >>
pick matches again >>
Add new script >>
Print a message >>
Type your message, i.e "You don't have any matches'.

I like this idea, can't see how it would influence the gameplay, but it's a nice touch and would add atmosphere.

mblann
Thanks for the replies...that helps. Yeah, doesn't affect gameplay, at least not yet ;-) but wanted to add some realism.

Silver
I've got matches in my game. The player has an object (a container but that's irrelevant) called 'box of matches' in their inventory. I added the alias match and matches to that object. In the verb section I added one called 'strike'. A script follows this. I thought of other options people might try such as 'use match' etc to return "why not try striking one?" to nudge them in the right direction.

Okay. I have a room called Junk in my game (the room name is irrelevant) where I store objects yet to be implemented and somewhere to discard objects. It isn't a room that can ever be explored by the player, it's just for shifting objects about. In there I have created an object called 'lit match'.

Okay back to the first paragraph. When the player types 'strike match' I select it to start a script. The first thing I do in the script is describe what has happened with a print msg.
"You strike the match and everything is briefly lit in glorious technicolor" or similar.
Then I get the script to move the lit match from junk to the player object.
Then I get the script to start a timer. Let's call it matchlit.

So the player is now holding a lit match that you can do all sorts with. Like light your cigarette. Or commit arson. But *sigh* nothing lasts forever. So let's get on that timer you just started.

In the timer you called matchlit you set it for ten seconds, because you're cruel like that, when the timer ends you run a script with that too. First you print a message to say what has happened like "the flame withers and now all you have is a piece of smouldering charcoal".
But you're still holding a lit match! So you get the script to move the lit match object BACK to the room called Junk and then you move another object you created in the room Junk called burnt matchstick from Junk to the player.

That probably makes no sense but I've basically told you the main mechanic to the opening room of the game I'm working on but meh, whatever, I'm a libertarian communist.

Silver
Actually making the box of matches a container wasn't irrelevant. I needed a response to a request to "open box of matches" which I then set a print message of "why not try striking one?" I had to make it a container to do that iirc.

mblann
Wow, I like the detail and all of the lit match/burnt match thing. Thanks for the input.

mblann
So, I have another question. I'm wanting the matches to decrease in number as they are used. So I created the following:
"There are " + book of matches.count + " matches left." (book of matches is my object)
Where "book of matches.count" = 3 (or whatever)
How do I add the code or expression or whatever it's called to when a match is used, it reduces the count by one?

Silver
I'm no good for this. Hopefully one of the code monkeys will show up...

<coughs>

HegemonKhan
see the other thread, I've posted there and I think Avantar has too, hopefully you can understand one of our posts (most likely Avantar's, laughs).

if you just want to increase~decrease by a value of 1, then you can use the GUI~Editor's:

run as script -> add a script or add new script -> variables -> 'increase object counter' or 'decrease object counter' -> (see below)

Increase counter [OBJECT] (whatever Object) [COUNTER NAME] (whatever Attribute's Name)

example:
in GUI~Editor, using the 'increase object counter' Script: Increase counter [OBJECT] (game) [COUNTER NAME] (turns)
in code: game.turns = game.turns + 1
in GUI~Editor, using the 'set a variable or attribute' Script instead: (same as 'in code' above)

-----

so if you want to increase or decrease by more than 1 (and also be able to multiply or divide), then you need to use the 'set a variable or attribute' Script, instead.

-----

off-topic:

monkeys have tails, humans do not have tails, humans are NOT monkeys!

apes do not have tails, humans do not have tails, humans ARE apes.

so, I'm (just a newborn) code APE :D

APES:

humans, chimps, bonobos, gorillas, and orangutans

MONKEYS:

old world (europe, asia, africa) monkeys (non-prehensile tail: can't hang from trees with their tails: baboons)
new world (north and south americas) monkeys (prehensile tails: can hang from trees: meh, none are cool to know, lol)

Avantar
@HegemonKhan
"...hopefully you can understand one of our posts (most likely Avantar's, laughs)"
The wealth of information you posted me before still comes in handy and is still a life saver! Yes, the answer might be a simple line of code, but once you understand it, you can just formulate your own and for me the willingness of taking the time going into detail explanations of how it works, is priceless and more than I can say of myself. So...If nobody said thanks before - I do.

@mblann
Yes, I have posted some code in the other thread that might make some sense with HK's explanation of things. So it will be a good thing playing around with verbs, commands, attributes - just to see how Quest's structure works, where to put things and what they all do. From there things will be a little easier to do.

OurJud
I've been playing around with cigarette use and can't figure out a little problem.

I have the cigarettes as an object and can trigger the description of him lighting one if he types 'use cigarettes' - simple enough.

But for logical purposes, I would like to set a timer (for say two minutes) during which time the command 'use cigarettes' would get the response, 'You're already smoking one.'

And then after the two minutes is up, the command would be reset and he would be able to light another one.

Just to complicate things further, I would like to have the message 'You take a final draw from the cigarette and flick the butt into the air' once the two-minute timer has run down.

HegemonKhan
first, create the Timer (add Timer), don't add the Timer for a specific room (don't make it local), instead click on the upper left most Object 'Object' in the left side's 'tree of stuff', so that it is highlighted, as this ensures that when you (using the bar at the top of the screen) add~create your Timer, it is global (usable by the entire game, not just when inside a specific room, which is 'locally' ).

Think of global Timers and Turnscripts as global Functions, which can be flipped on or off during any time and any where during the game, just like how a Function can be 'called upon' at any time and anywhere doing the game. Except that unlike Functions, Timers and Turnscripts have coding that already allows for the use of real-time-ticking and for 'turn-increasing~decreasing'.

make sure that the 'enable~enabled' check box, is *UN*checked, as we don't want it to be activated~running~executing until we lit our cigerette, right? (Right!)

choose the Timer's interval for '2 minutes'

Timer's Scripting (Scripts):

(these occur AT the 2 minute interval (at the 2 minute mark, not from 0 to the 2 minute mark. If you wanted to do something like that you'd set the Timer to be 1 second, so it does it's Scripting at every 1 second via not having a 'disable Timer' ending script)

msg ("You take a final draw from the cigarette and flick the butt into the air.")
the last script in the Timer is the ~ 'disable Timer' Script (under the Timer category, lol), to disable the timer, of course.

----

now, in your 'use a cigerrete' Verb's scripting:

if (Timer_name.enabled = true) {
-> msg ("You're already smoking one.")
} else if (Timer_name.enabled = false) {
-> msg ("You light your cigerrete.")
-> Timer_name.enabled = true
}

find the ~ 'enable Timer' Script choice (under the Timer category, lol)

--------

lastly, due to using a Timer, you have NO~ZERO need for a Boolean (or better String) Attribute as a flag for the cigerette being lit or not, the Timer (enabled vs disable) is already (is now) our flag for this (so we don't want another flag as a boolean or string attribute, as that would cause errors.

--------

it takes a long time to train your brain in this 'if'~code logic way of thinking~mindset~mentality~thought process, as the order and structure of~for this 'if' logic isn't intuitive, until you get your brain trained in it.

Silver
OurJud wrote:I've been playing around with cigarette use and can't figure out a little problem.

I have the cigarettes as an object and can trigger the description of him lighting one if he types 'use cigarettes' - simple enough.

But for logical purposes, I would like to set a timer (for say two minutes) during which time the command 'use cigarettes' would get the response, 'You're already smoking one.'

And then after the two minutes is up, the command would be reset and he would be able to light another one.

Just to complicate things further, I would like to have the message 'You take a final draw from the cigarette and flick the butt into the air' once the two-minute timer has run down.


You do the same as we did yesterday with the if script and the flag. you also start a timer. when the timer finishes get it to run a script to print the cigarette finished message and to unset the flag again.

OurJud
Thanks, people. I promise not to barrage you with follow-up questions if I can't do this :)

OurJud
Silver wrote:You do the same as we did yesterday with the if script and the flag. you also start a timer. when the timer finishes get it to run a script to print the cigarette finished message and to unset the flag again.


Like a charm! :D

mblann
Ahhh...this has been interesting for sure. ;-)

Thanks to everyone for all the great input.
Who would have thought lighting cigarettes would have been such an interest?

OurJud
mblann wrote:Ahhh...this has been interesting for sure. ;-)

Thanks to everyone for all the great input.
Who would have thought lighting cigarettes would have been such an interest?

They're a very knowledgeable and helpful bunch, and no mistake! And yes, it's great that these threads can benefit so many others. I'd never have considered cigarette use if it wasn't for the OP.

I'm just thankful so much can be done via the interface - I'd be stumped otherwise.

Out of interest, what is the core programming language for Quest?

Silver
OurJud wrote:

"Silver"

You do the same as we did yesterday with the if script and the flag. you also start a timer. when the timer finishes get it to run a script to print the cigarette finished message and to unset the flag again.



Like a charm! :D



Yay! :D

HegemonKhan
@OurJud:

quest's code is it's own, but it resembles 'XML (eXtensible Markup Language)' in syntax and structure.

you can download notepad++ ( http://notepad-plus-plus.org/ ), and after you installed and opened it, simply at the bar at the top, under languange, choose 'XML', and you'll have a huge help with~in reading, writing~crafting, and troubleshooting quest's code (and many other code languages too, besides 'XML', if you should deal with them beyond quest).

OurJud
Thanks, HK. I already have notepad, of course, so it might be worth having a dabble. I became quite a dab hand with CSS after a couple of years messing around with blogger templates and such, so I don't suppose there's any reason I couldn't pick this one up too.

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

Support

Forums