Making a Fireplace that can burn certain objects?

I'm totally new to Quest...and coding to a large extent, and I'm trying to create some things that may be out of my league, but I want to try a bit of everything to start with. Right now I have this fireplace that I want to make capable of turning certain objects to ash. I have looked over the tutorials for making one object into another, so I created an object to be burned (a note), some ash, and the fireplace itself, but I'm having trouble making it so that when I type in something like "burn note in fireplace", it will actually do that. I can get it to work if I say "use note with fireplace", but that's not quite how one would go about trying to preform that action, you know? Anyway any help would be very appreciated! You may have to explain it as though you're talking to a child: this is a bit overwhelming to me but I really want to learn all I can about it! Thanks in advance!


J_J

I would use a command instead of a verb. You can put in any combination of phrases like this: "burn #object# in fireplace" then as an if expression write: "if object = note" and then add the msg, make the note invisible and replace it with ash.

The command will let you burn multiple items this way, or give snarky comments if they try and burn something you don't want them to.


also, here's some links to get you started with learning quest and its coding:

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

(take it slow, one thing at a time, as it's quite OVER-whelming and a lot of stuff to learn, when you're totally new to quest and to coding)

(ask if you need help with anything and/or need anything explained more/better)


to add to J_J's post:

There's two ways of getting/using typed-in inputs:

  1. the 'get input' Script/Function: http://docs.textadventures.co.uk/quest/scripts/get_input.html

in the GUI/Editor: add new script -> 'output' section/category -> 'get input' Script/Function -> [add scripting: add new script/s]

<!--
example using a 'Function' Element, called by the built-in 'start' Script Attribute of the 'game' Object (the 'game.start' Script Attribute is activated/executed/run/fired at game start, as the very first thing done by the game, when you play it, making the 'game.start' Script Attribute good for game introduction,character creation, and/or whatever else you want done before the person is able to start playing your game)
-->

<game name="NAME_OF_GAME">

  <attr name="start" type="script">

    set_name_of_player_function

    on ready {

      msg ("Player Name: " + player.alias)

    }

  </attr>

</game>

<function name="set_name_of_player_function">

  msg ("Name?")

  get input {

    player.alias = result

  }

</function>
  1. the 'Command' Element: http://docs.textadventures.co.uk/quest/elements/command.html

in the GUI/Editor: left side's "tree of stuff (Elements)" -> under 'game' -> 'Commands' -> Add -> [set up your Command]

<command name="NAME_OF_COMMAND">

  <pattern>PATTERN_EXPRESSION</pattern>

  <script>

    // scripting

  </script>

</command>

The 'Command' Element has a lot of functionality, so we'll be using that (as already stated by J_J in his/her post)

the 'pattern' of the Command is instructions for how it is to handle/parse/understand your typed-in input/s during game play

the first 'word' of the 'pattern' needs to be unique, as it will be what distinguishes one Command from another, so Quest will know which Command to use. I like to call this first 'word', as: the command activator word

for example, the built-in 'use' and 'useon' Commands, uses (pun sorry): guess what its activator word is (answer: use)

(at the bottom left corner, is the 'filter' -> 'show library elements' -> shows (show/hide toggle) the built-in stuff in the left side's "tree of stuff" as light grey text, for example the 'use' and 'useon' Commands)

<command name="use">

  <pattern>use #object#</pattern>

</command>

<command name="useon">

  <pattern>use #object1# on #object2#;use #object1# with #object2#</pattern>

</command>

so, you should use 'burn' for your Command for what you want to do:

(you can name the Command whatever you want, you don't have to use my name in the example below)

(try to quickly create a naming/labeling system/convention that works well for you, as it's a huge pain to go back and change everything to a different/new/better naming/labeling system/convention, lol)

<command name="burn_command">

  <pattern>burn</pattern>

</command>

now, we're going to be typing in for our input, what object we want to try to burn, and thus we need to tell quest to store that part of our input into a VARIABLE, so that we can then act upon it with our Command:

this is done by putting the below into the 'pattern' of the Command:

#object#
or
#objectXXX#

(the 'XXX' is my way of saying that you can write in whatever you want for it, for examples: #object1#, #object_1#, #object2#, #object_2#, #object_1_parameter#, #object_2_parameter#, etc etc etc. You must have it start with '#object' and end with '#')

now, there's also:

#text#
or
#textXXX#

(the 'XXX' is my way of saying that you can write in whatever you want for it, for examples: #text1#, #text_1#, #text2#, #text_2#, #text_1_parameter#, #text_2_parameter#, etc etc etc. You must have it start with '#text' and end with '#')

but, we're going to be using '#object#/#objectXXX#', as we want to it look for Objects, and not just use the inputted text, which is the difference between using the '#object#/#objectXXX#' and '#text#/#textXXX#'

<command name="burn_command">

  <pattern>burn #object_1# in #object_2#;burn #object_1# with #object_2#;fry #object_1# in #object_2#;fry #object_1# with #object_2#;incinerate #object_1# in #object_2#;incinerate #object_1# with #object_2#</pattern>

</command>

the semicolon separates the pattern expressions, so you can handle different inputs (handling "guess the verb", as what might be obvious to you to type in 'burn', it might not be for someone else, they may type in 'fry', and also notice that you could type in 'in' or maybe 'with' depending on what action the person playing the game is trying)

very important: have the most complex/longest pattern expressions be first to least complex/long pattern expressions last, as otherwise it'll never be able to parse the longer/complex inputs during game play

now, for how it works:

say I type in during game play:

burn note in fireplace
// or
// burn note with fireplace
// or
// fry note in fireplace
// or
// fry note with fireplace
// or
// incinerate note in fireplace
// or
// incinerate note with fireplace

notice how my input matches up (as it HAS TO) with the 'pattern' of the Command (same 1 space between burn+note, note+in, and in+fireplace) (same placement of 'burn', 'note', 'in', and 'fireplace' between my input and the 'pattern' of the Command)

now, those '#' symbols in the 'pattern' of the Command, take the inputted text in the same placement as it, and will store it into a 'Variable' VARIABLE of the same name as it (minus the '#' symbols):

so, for my example, the 'Variable' VARIABLES would be:

object_1
object_2

stored in 'object_1' would be (a pointer/reference to) the 'note' Object
stored in 'object_2' would be (a pointer/reference to) the 'fireplace' Object

now, since I'm using the '#object#/#objectXXX#', the 'note' and 'fireplace' must be existing Objects, and those Objects must be reachable (within the current room you're in and accessible, for example: not within a closed container Object), otherwise it fails to find them and thus it doesn't have them stored and thus you can use them in the Command's scripting, and thus the Command's 'unresolved' message is displayed letting you know your inputs failed:

<command name="burn_command">

  <pattern>burn #object_1# in #object_2#;burn #object_1# with #object_2#;fry #object_1# in #object_2#;fry #object_1# with #object_2#;incinerate #object_1# in #object_2#;incinerate #object_1# with #object_2#</pattern>

  <script>

    // scripting

  </script>

  <unresolved>Wrong inputs, try again!</unresolved>

</command>

now... the scripting... and using our 'object_1' and 'object_2' 'Variable' VARIABLES:

(a simple example only, hopefully you'll be able to understand this stuff... I'm using some stuff you probably don't know about yet, so, if not, ask us to explain it, or about/of whatever stuff in it)

<game name="NAME_OF_GAME">
</game>

<object name="room">

  <inherit name="editor_room" />

</object>

<object name="internal_storage">
</object>

<object name="player">

  <inherit name="editor_object" />
  <inherit name="editor_player" />

  <attr name="parent" type="object">room</attr>

</object>

<object name="note">

  <inherit name="editor_object" />

  <inherit name="flammable_type" />

  <attr name="parent" type="object">room</attr>

</object>

<object name="fireplace">

  <inherit name="editor_object" />

  <inherit name="spark_type" />

  <attr name="parent" type="object">room</attr>

</object>

<object name="ash">

  <inherit name="editor_object" />

  <attr name="parent" type="object">internal_storage</attr>

</object>

<type name="flammable_type">
</type>

<type name="spark_type">
</type>

<command name="burn_command">

  <pattern>burn #object_1# in #object_2#;burn #object_1# with #object_2#;fry #object_1# in #object_2#;fry #object_1# with #object_2#;incinerate #object_1# in #object_2#;incinerate #object_1# with #object_2#</pattern>

  <script>

    // this is just a simple example, so it doesn't handle all of the issues associated with all of the functionality involved (see if you can see/spot/understand/realize some of these issues, hint: think logically about what you're doing and what are all of the different things/scenarios/actions/situations that can happen with what you're doing, what happens if you were to try doing this again, etc etc etc)

    if (DoesInherit (object_1, "flammable_type") and DoesInherit (object_2, "spark_type")) {

      object_1.parent = internal_storage

      ash.parent = player.parent

    }

  </script>

  <unresolved>Wrong inputs, try again!</unresolved>

</command>

You could start doing:

  1. a new TYPE for combustible objects. For example you could create a <TYPE name="type_wood"> with attributes and a script "BURN" that starts when the object is in the fireplace.
  2. Apply this type to every objects that you want to burn.
  3. Make a turnscript that check if the objects is in the fireplace and eventually starts the "burn" script.

There are several ways you could do this. Pascal's is probably the best if you want a system that handles fire properly. I will offer a simpler approach, which will do what you want, I think.

I would do this with two commands, one to handle BURN PAPER and one to handle BURN PAPER IN FIREPLACE. Before we get to the commands, give the fireplace a new attribute "fire", set it to be a Boolean and true. This will tell Quest this is something objects can be burned on. Then for the paper, give it an attribute "ashes", and make this a string that can be used for the name (alias) of the ashes, say "ashes of the paper". You could also give the paper another attribute "ashes_look" and that will be used for the description of the ashes.

For the first command give it this pattern:

burn #object1# on #object2#;burn #object1# in #object2#;burn #object1# with #object2#

Give it a name, "cmd_burn_with" (commands do not usually need names, but this will be useful later). Paste in the code:

if (not GetBoolean(object2, "fire")) {
  msg (CapFirst(GetDisplayName(object2)) + " " + Conjugate(object2, "be") + "n't a fire.")
}
else if (not HasString(object1, "ashes")) {
  msg (WriteVerb(object1, "do") + "n't burn.")
}
else {
  msg ("You burn the " + GetDisplayAlias(object1) + " with the " + GetDisplayAlias(object2) + ".")
  create ("ashes of " + object1.name)
  ashes = GetObject("ashes of " + object1.name)
  ashes.parent = object1.parent
  ashes.alias = object1.ashes
  if (HasString(object1, "ashes_look")) {
    ashes.look = object1.ashes_look
  }
  else {
    ashes.look = "This is all that is left of the " + GetDisplayAlias(object1) + " after you burnt " + object1.article + "."
  }
  object1.parent = null
}

The code checks if the second object is on fire (i.e., the "fire" attribute is true), then checks the first object can be burnt (i.e., it has an "ashes" string). If so, it creates a new object, the ashes of the first object, placing that whereever the first object is, and then removes that object.

The second command has this pattern:

burn #object1#

Here is the code:

l = FilterByAttribute(ScopeReachable(), "fire", true)
if (ListCount(l) = 0) {
  msg ("There is no fire here to burn anything on.")
}
else {
  d = NewDictionary()
  dictionary add (d, "object1", object1)
  dictionary add (d, "object2", ObjectListItem(l, 0))
  do (cmd_burn_with, "script", d)
}

This looks for an object present with the "fire" attribute. If it finds one, it passes that and object1 to the first command to do all the work. Note that if there are two fires in the room, one will be selected arbitarily by Quest.


^bookmarked

Thanks, Pixie.


I would have probably gone for the simpler option, and made the fireplace a container with a script.

==> put paper in fireplace

It burns to ash!


Thanks for the advice J_J! I was kinda scared no one would reply to this! When I tried that and did a quick playthrough, though, I got this error message:

Error running script: Error compiling expression 'Sticky Note': RootExpressionElement: Cannot convert type 'Element' to expression result of 'Boolean'

Which...I do not understand.

(EDIT)

Oh jeeze I should have refreshed my page before posting! So many helpful comments! I'll get back to you all once I've tried them out! Thanks so much!


In this summer days I am struggling with the code, trying to create a "simplified" combustion system. If the result will be ok I'll share the code.
The basics seems simple (I must said "seems", but it wasn't).
We can divide the combustion process of wood in three steps:

  1. Drying
  2. Burning
  3. Coal.
    My goal is to code something that can "give the feeling" (not to apply the rules of physics and thermodynamics that are too far from my possibilities), and to create a simplified CRAFTING system.

There was this a while back, I've tried contacting the user in the past, but to no avail, so not sure how far they came with their code. If anyone has any more info about it, maybe they can post any further developments.
http://textadventures.co.uk/forum/samples/topic/ml6jq-varughw7yeme--iw/world-template


Remove (paper)
msg ("It burns to ash!")

Log in to post a reply.

Support

Forums