Putting multiple components of an object together

jbarnett5150
I am new to Quest and to this forum. I apologize ahead of time since this has probably been explained already but i was unable to find it in search. I want to be able to join multiple components found in the game to make one object. Specifically, the player finds a spellbook. One of the spells has multiple components that have to be found individually then mixed together in order to cast the spell.
An explanation or a link to it if it's already been covered would be much appreciated. Thanks.

HaganeSteel
Edit: Oops. Nevermind.

XanMag
I'll post a response with code in about 4-5 hours (not on computer right now). But, in short, I think you'll want to create all the possible objects that could be formed for each combination in a dead room and script those objects to move in with each command to 'fuse' them en route to the final product.

HegemonKhan
this is a bit complex with what you're asking for (even if it seemed like something simple to do ~ a lot of seemingly simple stuff, isn't actually so simple), especially for someone new to quest, and especially to coding, but if you're ready for it:

(there's many ways of doing this, depending on your design setup)

let's assume we got this design setup (conceptually):

replace my 'spell1', 'spell2', ..., and 'spellx' (or however many spells you got) (and the same with my 'item1...x ~ component1...x') with the names of your spells (or your ingredient~mixing Objects), ie: 'fireball', 'inferno', 'armageddon', 'ice', 'blizzard', 'ragnarok', 'wind', 'tornado', 'tempest', 'earth', 'quake', 'water', 'tsunami', etc etc etc (or ie: frog, rabbit_foot, etc, lol)

'spellbook' ---> Object
'mix' ---> Verb of~for your 'spellbook' Object
'spell1' ---> (sub) Object (of the 'spellbook' Object); drop=false; visible=false
...
'spellx' ---> (sub) Object (of the 'spellbook' Object); drop=false; visible=false
'cast' ---> Verb of~for EACH of your 'spellx' Objects
'item1~component1' ---> your ingredient Objects for the mixing to make your spells available~useable
...
'itemx~componentx' ---> your ingredient~mixing Objects for the mixing to make your spells available~useable

'mix' Verb (in code, sorry, but its easy for me):

replace my 'item1..x ~ component1...x' with your required Objects for the mixing, which will make your 'spell1...x' Objects available for you to use (via making them visible: visible=true)

obviously adjust for how many Objects you're using for the mixing and how many spells you got too.

if (Got (item1A~component1A) and Got (item1B~component1B) and Got (item1C~component1C)) {
spell1.visible=true
}
if (Got (item2A~component2A) and Got (item2B~component2B) and Got (item2C~component2C)) {
spell2.visible=true
}
if (Got (item3A~component3A) and Got (item3B~component3B) and Got (item3C~component3C)) {
spell3.visible=true
}


for each of your spell Objects:

add~create your 'cast' Verb and add the scripts that you want for them, for example (this is a bit advanced scripting~coding too):

'fireball' Object's 'cast' Verb:

// your fireball will target all monsters in the room that you currently can, doing 1 to X damage to each of them:

foreach (object_variable, ScopeReachableNotHeldForRoom ()) {
if (object_variable.type_of_object = "monster" and object_variable.current_life > 0) {
if (((fireball.power * player.intelligence / 100) - (object_variable.mentality / 100)) > 0) {
object_variable.current_life = object_variable.current_life - ((fireball.power * player.intelligence / 100) - (object_variable.mentality / 100))
} else {
object_variable.current_life = object_variable.current_life - 1
}
}
}

jbarnett5150
Thank you for the responses so far. I am new to quest but am picking it up quickly. I do have some knowledge of coding it's just been a really long time.

HegemonKhan
ah, if you know some coding, then the quest wiki documentation can really help you with learning more of quest:

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

http://docs.textadventures.co.uk/quest/ ... notes.html

http://docs.textadventures.co.uk/quest/tutorial/
http://docs.textadventures.co.uk/quest/guides/
viewforum.php?f=18 (more guides: Libraries and Code Samples)

http://docs.textadventures.co.uk/quest/aslx.html (quest's XML format+syntax)

http://docs.textadventures.co.uk/quest/ ... ments.html

http://docs.textadventures.co.uk/quest/elements/ (quest's Elements are the main containers~OBJECTS of OOD, at least at the user level, anyways)
http://docs.textadventures.co.uk/quest/types/ (Attributes: global VARIABLES, so long as the Object that they're attached to, exists, of course)

http://docs.textadventures.co.uk/quest/ ... /type.html (Object Types: these are quest's Classes~Groups)

http://docs.textadventures.co.uk/quest/scripts/
http://docs.textadventures.co.uk/quest/functions/ (cateogrical order)
http://docs.textadventures.co.uk/quest/ ... tions.html (alphabetical order)
http://docs.textadventures.co.uk/quest/scopes.html

lots of useful information (commands) for you to learn~use :D

XanMag
Here is a quick little room from a demo tutorial game I am piecing together. Forgive it's current crudeness, but if you copy-paste this code into a new game, you should be able to see what I did in the GUI.

Below is the code for my item room (no player access, just used to store stuff). Ignore the apples. =)

  <object name="items room">
<inherit name="editor_room" />
<object name="apple">
<inherit name="editor_object" />
<eat type="script">
msg ("You scarf the delicious apple down in just a few bites! Yummy!")
MoveObject (apple, items room)
SetObjectFlagOff (lush green fruits, "taken")
</eat>
<talkto type="script"><![CDATA[
msg ("You speak meaningfully to the apple.<br/><br/>It responds... \"Thanks for taking the time to speak with me. No one does that much anymore these days. I would really like to be back with my apple family. Do you think you can appease me?\"<br/><br/>You think about it and decide that you would miss your family too. You nod affirmatively and the apple grins at you. \"Thank you again!\"<br/><br/>With that, the apple dissappears from your hand and vanishes into thin air.")
MoveObject (apple, items room)
SetObjectFlagOff (lush green fruits, "taken")
]]></talkto>
</object>
<object name="love potion">
<inherit name="editor_object" />
<inherit name="edible" />
<look>This unique potion screams magic. The heart shaped-vial is cycling through all the different primary colors. It smells a bit like love.</look>
<drink type="script">
msg ("You tip the amorous potion back and it slushes down your gullet. Immediately you feel warm and fuzzy all over and you search for the closest computer programmer to kiss.")
RemoveObject (love potion)
</drink>
<take />
<takemsg>Taken... Your heart is all a-flutter.</takemsg>
<attr name="feature_edible" type="boolean">false</attr>
<eat type="script">
msg ("You tip the amorous potion back and it slushes down your gullet. Immediately you feel warm and fuzzy all over and you search for the closest computer programmer to kiss.")
RemoveObject (love potion)
</eat>
<feature_usegive />
<use type="script">
msg ("You tip the amorous potion back and it slushes down your gullet. Immediately you feel warm and fuzzy all over and you search for the closest computer programmer to kiss.")
RemoveObject (love potion)
</use>
</object>
<object name="purple potion">
<inherit name="editor_object" />
<feature_usegive />
<selfuseon type="scriptdictionary">
<item key="green potion">
msg ("You pour the contents of the purple bottle into the green bottle. A poof of air erupts and the bottles disappear. You find in your hands a new heart-shaped vial that is pulsing all the primary colors.")
RemoveObject (purple potion)
RemoveObject (green potion)
AddToInventory (love potion)
</item>
</selfuseon>
<look>This vial is filled with a deep, rich purple liquid.</look>
<take />
<takemsg>Taken... You feel at peace.</takemsg>
<use type="script">
msg ("Closer... but, you still get a foreboding feeling.")
</use>
</object>
<object name="brown potion">
<inherit name="editor_object" />
<look>It's murky brown and quite thick. It reminds you of a post party evening surprise you mind find in the toilet. Smells like one too.</look>
<take />
<takemsg>Taken... you have the urge to do a two-sie.</takemsg>
<feature_usegive />
<selfuseon type="scriptdictionary">
<item key="blue potion">
msg ("You pour the contents of the brown bottle into the blue bottle. A poof of air erupts and the bottles disappear. You find in your hands a new heart-shaped vial that is pulsing all the primary colors.")
RemoveObject (brown potion)
RemoveObject (blue potion)
AddToInventory (love potion)
</item>
</selfuseon>
<use type="script">
msg ("Closer... but, you still get a foreboding feeling.")
</use>
</object>
<object name="yellow potion">
<inherit name="editor_object" />
<look>It's a vial of yellow potion that looks and smells a bit like cat pee.</look>
<feature_usegive />
<selfuseon type="scriptdictionary">
<item key="red potion">
msg ("You pour the contents of the yellow bottle into the red bottle. A poof of air erupts and the bottles disappear. You find in your hands a new heart-shaped vial that is pulsing all the primary colors.")
RemoveObject (red potion)
RemoveObject (yellow potion)
AddToInventory (love potion)
</item>
</selfuseon>
<take />
<takemsg>Taken... You have the urge to go potty.</takemsg>
<use type="script">
msg ("Closer... but, you still get a foreboding feeling.")
</use>
</object>
</object>


And below is the room where the three combine-able items are.
  <object name="combining objects room">
<inherit name="editor_room" />
<object name="red potion">
<inherit name="editor_object" />
<look>This red potion is in an open vial. It smells of elderberries and is slightly thicker than water.</look>
<smell>It smells of elderberries... and your father.</smell>
<feature_usegive />
<selfuseon type="scriptdictionary">
<item key="blue potion">
msg ("You pour the contents of the red bottle into the blue bottle. A poof of air erupts and the bottles disappear. You find in your hands a new purple potion bottle.")
RemoveObject (blue potion)
RemoveObject (red potion)
AddToInventory (purple potion)
</item>
<item key="green potion">
msg ("You pour the contents of the red bottle into the blue bottle. A poof of air erupts and the bottles disappear. You find in your hands a new brown potion bottle.")
RemoveObject (green potion)
RemoveObject (red potion)
AddToInventory (brown potion)
</item>
<item key="yellow potion">
msg ("You pour the contents of the yellow bottle into the red bottle. A poof of air erupts and the bottles disappear. You find in your hands a new heart-shaped vial that is pulsing all the primary colors.")
RemoveObject (red potion)
RemoveObject (yellow potion)
AddToInventory (love potion)
</item>
</selfuseon>
<take />
<takemsg>Taken... Your mother was a hamster and...</takemsg>
<use type="script">
msg ("You do not want to do this yet. You have a bad feeling it will kill you.")
</use>
</object>
<object name="green potion">
<inherit name="editor_object" />
<look>This green potion is in an open vial and it smells of grass and is slightly less viscous than water.</look>
<smell>It smells like a freshly cut lawn.</smell>
<feature_usegive />
<selfuseon type="scriptdictionary">
<item key="blue potion">
msg ("You pour the contents of the red bottle into the blue bottle. A poof of air erupts and the bottles disappear. You find in your hands a new yellow potion bottle.")
RemoveObject (blue potion)
RemoveObject (green potion)
AddToInventory (yellow potion)
</item>
<item key="red potion">
msg ("You pour the contents of the red bottle into the blue bottle. A poof of air erupts and the bottles disappear. You find in your hands a new brown potion bottle.")
RemoveObject (green potion)
RemoveObject (red potion)
AddToInventory (brown potion)
</item>
<item key="purple potion">
msg ("You pour the contents of the purple bottle into the green bottle. A poof of air erupts and the bottles disappear. You find in your hands a new heart-shaped vial that is pulsing all the primary colors.")
RemoveObject (purple potion)
RemoveObject (green potion)
AddToInventory (love potion)
</item>
</selfuseon>
<take />
<takemsg>Taken... you get the urge to mow your lawn.</takemsg>
<use type="script">
msg ("You do not want to do this yet. You have a bad feeling it will kill you.")
</use>
</object>
<object name="blue potion">
<inherit name="editor_object" />
<look>This blue potion is in an open vial and the fluid inside is very light, somewhere between a liquid and a gas. It smells of lilac.</look>
<smell>It smells like a lilac bush.</smell>
<take />
<takemsg>Taken... You feel light as a feather.</takemsg>
<feature_usegive />
<selfuseon type="scriptdictionary">
<item key="red potion">
msg ("You pour the contents of the red bottle into the blue bottle. A poof of air erupts and the bottles disappear. You find in your hands a new purple potion bottle.")
RemoveObject (blue potion)
RemoveObject (red potion)
AddToInventory (purple potion)
</item>
<item key="green potion">
msg ("You pour the contents of the red bottle into the blue bottle. A poof of air erupts and the bottles disappear. You find in your hands a new yellow potion bottle.")
RemoveObject (blue potion)
RemoveObject (green potion)
AddToInventory (yellow potion)
</item>
<item key="brown potion">
msg ("You pour the contents of the brown bottle into the blue bottle. A poof of air erupts and the bottles disappear. You find in your hands a new heart-shaped vial that is pulsing all the primary colors.")
RemoveObject (brown potion)
RemoveObject (blue potion)
AddToInventory (love potion)
</item>
</selfuseon>
<use type="script">
msg ("You do not want to do this yet. You have a bad feeling it will kill you.")
</use>
</object>
<object name="Magoo">
<inherit name="editor_object" />
<inherit name="editor_player" />
<look>You're Magoo. A simple being trapped in a test game.</look>
<attr name="pov_look">You're Magoo. A simple being trapped in a test game.</attr>
</object>
</object>


I chose to do it this way because I felt it easier to script all the possible combinations (I think there were only 12 total). In the Use tab of the editor, say for the red potion, I would add use on (handle objects individually) (add) blue potion and then script what I want to happen (combine and remove the two potions and then move the purple potion to inventory). On the BLUE potion use tab, I just copy-pasted the scripts I used for the red potion use with blue potion script.

The other option, which I did not include here (but will later for the tutorial) would be the use of commands. You can add a command for the room like... use red potion on blue potion; use blue potion on red potion; use red on blue; use blue on red; pour red into blue; pour blue into red; mix red and blue; mix red and blue potions; mix blue and red potions; mix blue and red; ... etc, etc until you input in the command bar any possible text the player may type to mix the two potions together. Then add your script as I did above. Your method depends on how you instruct the player to make a combination. If, for example, you specifically tell them to combine ingredient one with ingredient two, then I think I would use the command option, but if you want to use the generic method of use ___ on ___ (which is common for many/most TA's), I would use the method I mentioned above in code. Or, if you really want to be a coding hero, you can do both and cover your bases for all possible combinations.

I added a edible option for the 'love potion', too. If you're curious, you have to click 'make editable copy' to alter the built-in edible command.

Let me know if you have questions about this. Also, there may be a better/simpler way to code this, but this is what I would do.

Good luck!

XanMag

jbarnett5150
Thanks XamMag. That's exactly what I was looking for. Much appreciated.

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

Support

Forums