How do I change the traits of an object in-game with another

Mr.WereWolph
I am making a game on quest and I would like to know how I can set up a system to make it so that I can microwave things and change their traits such as the amount of HP received and the name. EX:
>Take Chinese Takeout
You picked up Chinese takeout.
>Use microwave on chinese takeout
The chinese takeout is now cooked and safe to eat

Properties:

Before: "Chinese Takeout", does -10 HP
After: "Cooked Chinese Takeout", does +20 HP.

HegemonKhan
Note:

if you haven't gone through the tutorial ( http://docs.textadventures.co.uk/quest/tutorial/ ), you'll need to do so, to be able to do this within the GUI~Editor (and then you'll need help with how to do this in the GUI~Editor, if you can't figure it out from my mostly in-code help below, which isn't likely).

As, you're asking to do some bit more advanced stuff beyond the quest basics, so if you don't even know the quest basics, this will not be easy for you to do what you want.

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

for within scripting (your global Turnscript, for my example method of doing this):

to set~create and~or alter Attributes:

in GUI~Editor: run as script -> add a script -> variables -> set a variable or attribute -> [EXPRESSION] -> (see below)

in Code: Object.Attribute = Value_or_Expression

example: player.strength = 0

---------

basic math computation code expressions:

Addition:

Object.Attribute = Object.Attribute + Value_or_Expression

Subtraction:

Object.Attribute = Object.Attribute - Value_or_Expression

Multiplication:

Object.Attribute = Object.Attribute * Value_or_Expression

Division:

Object.Attribute = Object.Attribute / Value_or_Expression

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

examples (using addition):

Object.Attribute = Value_or_Expression

player.strength = 0
player.bonus_strength_at_level_up = 3

Object.Attribute = Object.Attribute + Value_or_Expression

player.strength = player.strength + 5
// (0) -> (0+5) -> (5+5) -> (10+5) -> etc etc etc

player.strength = player.strength + player.bonus_strength_at_level_up
// (0) -> (0+3) -> (3+3) -> (6+3) -> etc etc etc

----------

in scripting (such as within a 'cook' Verb for~of your 'microwave' Object, for this example method of doing this):

as for changing the name:

the 'NAME' Attribute is the ID for the quest engine: the NAME Attribute must be unique, no 2+ NAME Attributes can be the same.

instead... you can use the 'ALIAS' Attribute:

in Code: Object.alias = "XXX"

initial setting (alias): food.alias = "pizza"

within the 'heat' Verb for~of the 'microwave' Object, here's example scripting:

food.alias = "hamburger"

this is in code... sorry... it's so easy~fast for me to do it via code... sighs

in the GUI~Editor, you do it this way:

run as script -> add a script -> variables -> set a variable or attribute -> [EXPRESSION] -> Object.alias = "XXX"

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

to add (initially set attributes) in the GUI~Editor:

'whatever: XXX' Object -> Attributes (Tab) -> Attributes -> Add -> (see below)

Attribute Name: XXX
Attribute Type: string or boolean or int (integer, for example: 0) or double (decimal number, for example: 0.0), script, etc...
Attribute Value: (depends upon your Attribute Type)

so to make your own String Attribute (if you don't want to use the default 'ALIAS' String Attribute), for example:

(I'm using my own naming~labeling system for this, hehe)

'food' Object -> Attributes (Tab) -> Attributes -> Add ->

Attribute Name: name_string
Attribute Type: string
Attribute Value: pizza

or, another (but separate from what you want to do) example:

'player' Object -> Attributes (Tab) -> Attributes -> Add ->

Attribute Name: first_name_string
Attribute Type: string
Attribute Value: HK

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

just read this in your post:

changing from doing '-10 hp' to '-20 hp'

this involves using the 'if' scripts and global Turnscripts... (this is a bit complex ~ complicated):

within your (global) Turnscript:

if (food.alias = "hamburger") {
player.hp_integer = player.hp_integer - 20
} else if (food.alias = "pizza") {
player.hp_integer = player.hp_integer - 10
}
game.turns = game.turns + 1

Silver
Reheating rice is potentially more harmful than eating a cold Chinese takeout. :D

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

Support

Forums