Use two items in the inventory on eachother

So I have Item A and Item B
I am attempting to be able to combine them to make an Item C
How would i do this?
I have the code set up, but it doesn't let me select another item.


There is a guide here:
http://docs.textadventures.co.uk/quest/convert.html


@ Pixie:

quick question

for scripting a Command's usage: do (NAME_OF_COMMAND, "script")

if your Command uses Parameters, do you just add the Arguments with additional commas? for example:

<command name="example_command">
  <pattern>example #text_1_parameter# #text_2_parameter#</pattern>
  <script>
    msg (text_1_parameter + " " + text_2_parameter)
  </script>
</command>

// does this work?:

do (example_command, "script", "hi", "bye")

also, one other question:

http://docs.textadventures.co.uk/quest/expressions.html
(there was another small/brief page/link of 'general/other variables' that also showed the '=>' syntax for doing/scripting scripts, but can't find it)

HK edit, just remembered where it's at (found it), lol: http://docs.textadventures.co.uk/quest/scripts/setting_variables.html

I never knew we could do script scripting until I had seen the above links:

SCRIPT_VARIABLE => { /* scripting/scripts */ }

could I get some examples of how to use this syntax? can it be used anywhere? And how example is the syntax done?

for example, can I, and then if so, how would I do it for example a Script Dictionary, especially with/for multiple scripts per key?

SCRIPTDICTONARY_VARIABLE = NewScriptDictionary ()
dictionary add (SCRIPTDICTONARY_VARIABLE, "example_key", ???)

otherwise, for 'normal stuff', in general it's just:

SCRIPT_VARIABLE => { /* scripting/scripts */ }

correct?


Q1 You would need to add the parameters to a dictionary.

params = NewDictionary()
dictionary add (params, text_1_parameter, "hi")
dictionary add (params, text_2_parameter, "bye")
do (example_command, "script", params)

Q2 This page has how to do combat on the web version. If you go down to "The player", you can see a good example, where it is used to add a change script to the player object:
https://github.com/ThePix/quest/wiki/The-Zombie-Apocalypse-(on-the-web-version)

To get a script into a script dictionary, I think you would need to assign the script to a local variable first, and then add that to your dictionary.

To be honest, I cannot think of any time I have used it besides trying to work around the lack of an Attributes tab for the web version. If you use the desktop version, you are probably better adding scripts as attributes. Can you add the script to a type, and then give the objects that type? Or perhaps have an object that holds a bunch of scripts as attributes. In fact, outside the Ask/Tell type of situation, I cannot think of any time I used a script dictionary.


thank you Pixie!

for Q1: yay, I finally understand now (A very long while ago you or Jay showed me something with adding a dictionary into a dictionary, but I was never able to understand it at the time), hehe. By adding a Dictionary to a Dictionary, that added Dictionary's keys and values get (to be) used as Variables by containing Dictionary.

for Q2: I was just asking in-case I ever would need to do it (more likely just using the simple scripting of a script Variable, as no idea why someone would be trying to add scripts to a script dictionary by scripting). Also, I could probably do the same dictionary into a dictionary for adding scripts to a script dictionary... maybe (have to think about it more and/or try it, lol).


It is adding a dictionary to a script call rather than to a dictionary. But yes, the keys/values become local variables, with the key as the name, and values as the values.

This is what happens with commands too behind the scenes. Quest matches "object1" (for instance) in a command pattern to an object in the room, then adds them to a dictionary. Then it passes that dictionary to the command script. For you, the author, you now have a local variable called "object1" set to that object.


Hi, on a related question to NotAHamster was asking.
I always make an ObjectC and put it in my 'RoomOfRequirement' or 'Room101' and move it to the players current room.
In the GUI, when you tap the box for 'Add New Script' the 'Add Script Command' popup box appears. About halfway down, under the objects label, is 'Create an object'. Is this object 'c' in NotAHamster's query. How would you go about manipulating the object since it is not there in quest code of the game.


the 'create' (which is the same as what you're referencing with the GUI/Editor's script options in your post, Agon) Script/Function ( http://docs.textadventures.co.uk/quest/scripts/create.html ) creates an Object, meaning it will create it in the code for you (though it'll not be contained within another Object: parent = null), which you can then manipulate just like any other Object.

for example:

<object name="room">
  // <attr name="parent" type="object">null</attr> // the default is to not show this code line, but if it did, this is what it would look like. This Object is NOT contained within another Object
</object>

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

// scripting:

create (orc) // orc.parent = null // initial setting of NOT being contained within another Object
orc.life = 100
orc.damage = 10
orc.parent = room // or: MoveObject (orc, room) // setting/re-setting it to be contained within the 'room' Room Object

// ----------

<object name="room">
</object>

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

<type name="monster">
  this.life = 100
  this.damage = 10
  this.parent = room
</type>

// scripting:

create (orc, "monster")

About halfway down, under the objects label, is 'Create an object'. Is this object 'c' in NotAHamster's query. How would you go about manipulating the object since it is not there in quest code of the game.

You create it with a certain name. Then you can get it and assign it to a local variable. Then you can add attributes:

create("my new object")
obj = GetObject("my new object")
obj.parent = player
obj.alias = "My new object"

It is usually easier to summon a pre-existing object (as above), or if you want many, to clone a pre-existing object.


do you have to use the 'GetObject' first, or can you also access/get/use it directly by name, for example:

(I know that using the 'GetObject' method is often more useful as allows for dynamic handling)

create ("orc")
orc.parent = room
orc.life = 100
etc etc etc


Just tried it, and apparently you do not need the GetObject; your code will work fine.


thank you pxie!

(HK was/is too lazy, didn't care enough / not needing to use 'create' yet with quest game making, to test it himself, lol)


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

Support

Forums