Confused about action and type commands...
MerryCo
13 Dec 2006, 19:36If I'm reading it right, I should be able to add a type to an object at runtime (dynamically) using the type command. This should copy all of the properties and actions of type into the object. Thus far I've been unable to get this to work.
Also, the action command allows me to specify an action for an object at runtime (dynamically). I've not been able to get this to work, either.
The documentation for both of these commands is really slim. Here's an example of what I'm trying to do for the type command:
Now, this should add the burnrate property to #object#, but it's not. Any ideas? And can anyone better explain the action command to me? Thanks so much!
Also, the action command allows me to specify an action for an object at runtime (dynamically). I've not been able to get this to work, either.
The documentation for both of these commands is really slim. Here's an example of what I'm trying to do for the type command:
command <addflamable #object#> {
type <#object#; Flammable>
}
define type <Flammable>
Burnrate = 1
end define
Now, this should add the burnrate property to #object#, but it's not. Any ideas? And can anyone better explain the action command to me? Thanks so much!
Freak
13 Dec 2006, 20:54How exactly is dynamic type changing implemented? (Geas does not currently allow changing types at runtime; changing it to allow that would greatly complicate the implementation.)
paul_one
13 Dec 2006, 22:43Actually, to allow that sort of switching it shouldn't be too hard.
.. Out of curiosity, the fact that not only the code is very modular, but very confusing (to me), and it's better to ask the writer than guess etc.. (yeah, long line to prepare a question - I know.)
.. Geas: How does it handle the "set string <blah; 1>" and then the:
"set numeric <blah2; #blah# * 2>" ??
Does it convert the string into a numeric and then evaluate it? Does it substitute in ANY values - then parse the string equation? (and I assume you're using a standard string stream for this too).
in relation to the OP:
Have you tried
.. I'm just about to go lookup the help file, but I'm pretty sure this would require the ACTUAL object name - and not any alias you use.
.. Out of curiosity, the fact that not only the code is very modular, but very confusing (to me), and it's better to ask the writer than guess etc.. (yeah, long line to prepare a question - I know.)
.. Geas: How does it handle the "set string <blah; 1>" and then the:
"set numeric <blah2; #blah# * 2>" ??
Does it convert the string into a numeric and then evaluate it? Does it substitute in ANY values - then parse the string equation? (and I assume you're using a standard string stream for this too).
in relation to the OP:
Have you tried
command <addflamable #@object#> {
type <#object#; Flammable>
}
.. I'm just about to go lookup the help file, but I'm pretty sure this would require the ACTUAL object name - and not any alias you use.
Freak
14 Dec 2006, 01:02Tr0n wrote:Actually, to allow that sort of switching it shouldn't be too hard.
There are several ways that it can be done; some of them are workable; some violate assumptions I have made. (Although if that were so, it would probably manifest in games where saving, quitting, then restoring would not reproduce everything correctly.
.. Out of curiosity, the fact that not only the code is very modular, but very confusing (to me), and it's better to ask the writer than guess etc.. (yeah, long line to prepare a question - I know.)
I'm confused.
.. Geas: How does it handle the "set string <blah; 1>" and then the:
"set numeric <blah2; #blah# * 2>" ??
Does it convert the string into a numeric and then evaluate it? Does it substitute in ANY values - then parse the string equation? (and I assume you're using a standard string stream for this too).
Geas will handle just about any parameter that contains hashes (exceptions being commands) as follows:
First it substitutes string / numeric variables
Then it will evaluate any functions
If it is going to be assigned to a numeric variable, then it is then evaluated numerically.
So in your case, it would:
Substitute strings: <blah2; #blah# * 2> --> <blah2; 1 * 2>
Evaluate functions: (does nothing)
Evaluate numerically: 1 * 2 --> 2
Alternately
set string <blah; 1+2>
set numeric <blah2; #blah#1>
would set blah2 to 22 (1+21)
set string <blah; 1+2>
set numeric <blah2; #blah# 1> (note the space between # and 1)
would set blah2 to 3. (The surplus 1 is ignored.)
(This will give different results if/when I modify it to handle Quest 4.0; Quest 3 only allows one operation per set statement.)
Alex
14 Dec 2006, 14:47It seems the "type" script command is in fact broken - all the properties and actions within a type will get added to the wrong object (if you're looking for it, you'll find they get added to the last object defined in the game).
I've fixed this for Quest 4.0 Beta 3.
The "action" script command does work, however. For example, I modified your code like this:
Here's some example output:
The "type" script command works in a fairly simple way - it just reads the type definition, and applies all the included actions and properties to the object, including all those defined by any nested types. If there's any conflict, any existing value is over-written, so if your object already had an "eat" action but the type defines another one, it's the type's "eat" action that will overwrite the earlier one (if you don't like that, just apply the type first, before setting your own actions and properties).
I've fixed this for Quest 4.0 Beta 3.
The "action" script command does work, however. For example, I modified your code like this:
define room <room>
command <f #@object#> {
type <#object#; Flammable>
action <#object#; eat> msg <You eat the thing.>
}
command <d #@object#> if action <#object#; eat> then doaction <#object#; eat> else msg <No action defined.>
define object <book>
end define
define object <sofa>
end define
end define
define type <Flammable>
Burnrate = 1
end define
Here's some example output:
> d book
No action defined.
> f book
> d book
You eat the thing.
The "type" script command works in a fairly simple way - it just reads the type definition, and applies all the included actions and properties to the object, including all those defined by any nested types. If there's any conflict, any existing value is over-written, so if your object already had an "eat" action but the type defines another one, it's the type's "eat" action that will overwrite the earlier one (if you don't like that, just apply the type first, before setting your own actions and properties).