Hey all
do (object, string attribute name, dictionary parameters)
Explanation:
Runs an object’s script attribute, passing in parameters via dictionary. The key/value pairs in the dictionary will be turned into local variables for the script. The special variable “this” can be used in the script to reference the object.
What's the practical use of this? Why not just use object.attribute instead?
Is it like the parameter for functions? (i.e. Attack (5) )
Hello.
This is silly, but it might help.
The do_do
script attribute on the do_hickey
cannot accept arguments, but I have the variables due
and dew
in the script as undefined
.
In the do_test
command's script, I use QuickParams ("due", room, "dew", player)
to create a dictionary to pass. do
creates those local variables within the script it calls. due
will point to the room
object, and dew
will point to the player
object. this
will be the do_hickey
object.
So, one thing do
does do is let you pass parameters to a script that doesn't take parameters.
<!--Saved by Quest 5.8.9013.8175-->
<asl version="580">
<include ref="English.aslx" />
<include ref="Core.aslx" />
<game name="What Do Does (Sometimes)">
<gameid>86dd9900-ad72-4339-a345-e35add7cb402</gameid>
<version>1.0</version>
<firstpublished>2024</firstpublished>
</game>
<object name="room">
<inherit name="editor_room" />
<isroom />
<object name="player">
<inherit name="editor_object" />
<inherit name="editor_player" />
</object>
<object name="do_hickey">
<inherit name="editor_object" />
<alias>do hickey</alias>
<take />
<attr name="do_do" type="script">
msg ("this.name: " + this.name)
msg ("due.name: " + due.name)
msg ("dew.name: " + dew.name)
</attr>
</object>
</object>
<command name="do_test_cmd">
<pattern>do test</pattern>
<script>
do (do_hickey, "do_do", QuickParams("due", room, "dew", player))
</script>
</command>
</asl>
You are in a room.
You can see a do hickey.
> do test
this.name: do_hickey
due.name: room
dew.name: player
I see. Thank you for the explanation and demonstration!
You even made a game for this :)
No problem at all!
I usually learn more by example, and sharing a small example game is easier than trying to explain everything.
I just found this, too: https://docs.textadventures.co.uk/quest/functions/quickparams.html
It's less confusing than my example with all the variations of "do", haha.