How do I set an object's alias via script?
Krammy
12 Jan 2014, 00:14I couldn't find anything in the search, so I hope this helps others in the future. Is there a way I can switch an object's alias via a script running in another object?
I tried using the "Set an object's attribute (named by an expression)" thingy, but I couldn't figure out how it worked. It kept giving me errors.
I'm using the desktop version of Quest, as it's a lot more customizable.
I tried using the "Set an object's attribute (named by an expression)" thingy, but I couldn't figure out how it worked. It kept giving me errors.
I'm using the desktop version of Quest, as it's a lot more customizable.
tlk
12 Jan 2014, 00:33I believe what you want in your script is "set a variable or attribute", and you want it to say:
Set variable [object.alias] = [expression] ["newalias"]
Where "object" is whatever object whose alias you want to change, and "newalias" is whatever you want the new alias to be (make sure to include the quotes). In code it would look like this:
Set variable [object.alias] = [expression] ["newalias"]
Where "object" is whatever object whose alias you want to change, and "newalias" is whatever you want the new alias to be (make sure to include the quotes). In code it would look like this:
object.alias = "newalias"
HegemonKhan
12 Jan 2014, 02:57just to add:
The "set a variable or attribute" (and just remember in its drop-down-box to select "EXPRESSION", don't leave it selected on "???") and "If..." Scripts enables you to do most of whatever you may want to do, they're very powerful~useful Scripts.
In Code, it's syntax~format is this:
object.attribute = value_or_expression
~OR~
variable = value_or_expression
which is exactly the same thing as what you do in the GUI~Editor's "set a variable or attribute" Script:
Set variable "object.attribute" = [EXPRESSION] "value_or_expression"
~OR~
Set variable "variable" = [EXPRESSION] "value_or_expression"
so here's some examples:
Object (Name): player
Attribute (Name): alias
Attribute (Type): string
Value_or_Expression: Value
Value: "HK"
(the quotes are required for when your Attribute Type is a: string)
(but, the quote usage is more complicated when you're doing an Expression, and not just merely a single Value)
(the built-in "alias" Attribute's Type is a: string, so it needs the quotes)
-------------------------------------
Variable: you_go_first
Value_or_Expression: Value
Value: true_or_false
-----------
Object (Name): monster
Attribute (Name): dead
Attribute (Type): boolean
Value_or_Expression: Value
Value: false
boolean <-- as is code built-in within quest is the same thing as specifically a --> "true_or_false" flag
booleans~flags is just the *specific* use of "true~false" (which is a type of "dualism~opposites" ~ 2 options) String Values to choose results
----
other types of CONCEPTUAL (*NOT* using the actual Attribute Type: boolean) flags~booleans (2 options for results):
binary ("0~1"): if "0" then do "this", if "1" then do "that"
numbers (any 2 numbers, except 0 and 1): if "5" then do "this", if "23", then do "that"
physics charges: if "-" then do "this", if "+" then do "that"
"on~off": if "on", then do "this", if "off", then do "that"
"yes~no": if "yes", then do "this", if "no", then do "that"
"in~out": ...
"hot~cold": ...
"up~down": ....
"left~right": ....
"male~female": ...
"tall~short": ...
"fat~skinny": ...
...you get the idea...
and we can expand this beyond dualism~opposites (ie: 3 and more options) to choose results:
if "1", then do "this_1"
if "2", then do "this_2"
if "3", then do "this_3"
if "4", ....
etc etc etc
if "red", then do "this_1"
if "blue", then do "this_2"
if "yellow", then do "this_3"
if "purple", ....
etc etc etc
--------------
so, actually (CONCEPTUALLY ONLY: booleans~flags) are just:
(IF)
object.attribute = Value
(THEN...)
(result~action~"whatever_you_want" Script)
object.(Type: Boolean)attribute = (String) Value
Strings ~ String Values:
0, 1, 5, 23, +, -, on, off, yes, no, true, false, in, out, hot, cold, male, female, left, right, up, down, -5, hhh23_888#$%ffss, a, b, c, z, and etc...
-----------
Object (Name): player
Attribute (Name): strength
Attribute (Type): int
Value_or_Expression: Value
Value: 0
int is used as a short form of integer, so if you were coding this, you'd not have to write out "integer"
----------------
and if you want to do (computation ~ adjusting attributes):
Old player.strength Value: 10
(In Code: player.strength = 10)
Object (Name): player
Attribute (Name): strength
Attribute (Type): int
Value_or_Expression: Expression
Computational Operators: + (addition), - (subtraction), * (multiplication), and / (division)
Expression: player.strength Operator 10
conceptually, it's algebraic substitution:
Old: player.strength = 10
player.strength (New) = player.strength (Old) + 10 (Value)
player.strength (New) = 10 (Old player.strength Value) + 10 (Value)
player.strength (New) = 10 + 10
New: player.strength = 20
The "set a variable or attribute" (and just remember in its drop-down-box to select "EXPRESSION", don't leave it selected on "???") and "If..." Scripts enables you to do most of whatever you may want to do, they're very powerful~useful Scripts.
In Code, it's syntax~format is this:
object.attribute = value_or_expression
~OR~
variable = value_or_expression
which is exactly the same thing as what you do in the GUI~Editor's "set a variable or attribute" Script:
Set variable "object.attribute" = [EXPRESSION] "value_or_expression"
~OR~
Set variable "variable" = [EXPRESSION] "value_or_expression"
so here's some examples:
Object (Name): player
Attribute (Name): alias
Attribute (Type): string
Value_or_Expression: Value
Value: "HK"
Set variable player.alias = [EXPRESSION] "HK"
(the quotes are required for when your Attribute Type is a: string)
(but, the quote usage is more complicated when you're doing an Expression, and not just merely a single Value)
(the built-in "alias" Attribute's Type is a: string, so it needs the quotes)
-------------------------------------
Variable: you_go_first
Value_or_Expression: Value
Value: true_or_false
If... -> Print a message [EXPRESSION] player.speed > monster.speed
-> then -> Set variable you_go_first = [EXPRESSION] true
else -> If... -> Print a message [EXPRESSION] player.speed < monster.speed
-> then -> Set variable you_go_first = [EXPRESSION] false
else -> If... -> Print a message [EXPRESSION] player.speed = monster.speed
-> then -> If... -> Print a message [EXPRESSION] RandomChance (50) = true
->-> then -> Set variable you_go_first = [EXPRESSION] true
If... -> Set variable you_go_first = [EXPRESSION] true
-> then -> Set variable monster.hit_points = [EXPRESSION] monster.hit_points - player.damage
-> then -> Print a message [MESSAGE] You get to go first and damage the monster!
else -> If... Set variable you_go_first = [EXPRESSION] false
-> then -> Set variable player.hit_points = [EXPRESSION] player.hit_points - monster.damage
-> then -> Print a message [EXPRESSION] "The " + monster.alias + "gets to go first and damages " + player.alias + " for " + monster.damage + " damage, leaving " + player.article + " now with only " + player.hit_points + " HP."
-----------
Object (Name): monster
Attribute (Name): dead
Attribute (Type): boolean
Value_or_Expression: Value
Value: false
boolean <-- as is code built-in within quest is the same thing as specifically a --> "true_or_false" flag
Set variable monster.dead = [EXPRESSION] false
you then kill the monster:
Set variable monster.dead = [EXPRESSION] true
booleans~flags is just the *specific* use of "true~false" (which is a type of "dualism~opposites" ~ 2 options) String Values to choose results
----
other types of CONCEPTUAL (*NOT* using the actual Attribute Type: boolean) flags~booleans (2 options for results):
binary ("0~1"): if "0" then do "this", if "1" then do "that"
numbers (any 2 numbers, except 0 and 1): if "5" then do "this", if "23", then do "that"
physics charges: if "-" then do "this", if "+" then do "that"
"on~off": if "on", then do "this", if "off", then do "that"
"yes~no": if "yes", then do "this", if "no", then do "that"
"in~out": ...
"hot~cold": ...
"up~down": ....
"left~right": ....
"male~female": ...
"tall~short": ...
"fat~skinny": ...
...you get the idea...
and we can expand this beyond dualism~opposites (ie: 3 and more options) to choose results:
if "1", then do "this_1"
if "2", then do "this_2"
if "3", then do "this_3"
if "4", ....
etc etc etc
if "red", then do "this_1"
if "blue", then do "this_2"
if "yellow", then do "this_3"
if "purple", ....
etc etc etc
--------------
so, actually (CONCEPTUALLY ONLY: booleans~flags) are just:
(IF)
object.attribute = Value
(THEN...)
(result~action~"whatever_you_want" Script)
object.(Type: Boolean)attribute = (String) Value
Strings ~ String Values:
0, 1, 5, 23, +, -, on, off, yes, no, true, false, in, out, hot, cold, male, female, left, right, up, down, -5, hhh23_888#$%ffss, a, b, c, z, and etc...
-----------
Object (Name): player
Attribute (Name): strength
Attribute (Type): int
Value_or_Expression: Value
Value: 0
int is used as a short form of integer, so if you were coding this, you'd not have to write out "integer"
Set variable player.strength = [EXPRESSION] 100
----------------
and if you want to do (computation ~ adjusting attributes):
Old player.strength Value: 10
(In Code: player.strength = 10)
Object (Name): player
Attribute (Name): strength
Attribute (Type): int
Value_or_Expression: Expression
Computational Operators: + (addition), - (subtraction), * (multiplication), and / (division)
Expression: player.strength Operator 10
Set variable player.strength = [EXPRESSION] player.strength - 10
New player.strength Value: 0
Set variable player.strength = [EXPRESSION] player.strength + 10
New player.strength Value: 20
Set variable player.strength = [EXPRESSION] player.strength * 10
New player.strength Value: 100
Set variable player.strength = [EXPRESSION] player.strength / 10
New player.strength Value: 1
conceptually, it's algebraic substitution:
Old: player.strength = 10
player.strength (New) = player.strength (Old) + 10 (Value)
player.strength (New) = 10 (Old player.strength Value) + 10 (Value)
player.strength (New) = 10 + 10
New: player.strength = 20
Krammy
12 Jan 2014, 09:04tlk wrote:I believe what you want in your script is "set a variable or attribute", and you want it to say:
Set variable [object.alias] = [expression] ["newalias"]
Where "object" is whatever object whose alias you want to change, and "newalias" is whatever you want the new alias to be (make sure to include the quotes). In code it would look like this:object.alias = "newalias"
Thank you! This is the code I needed.
