dim3 Forum

Full Version: Accessing the player object directly from other scripts
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
As you can see, boredom currently makes me come up with all kinds of weird ideas. :P
This is one that could actually be useful:
What about being able to modify the player object directly from different scripts? Could that be added?
Example:
I wrote a teleporter script that transports the player to a specified node or to a different map, depending on object parameters. (Very useful script, so I'm probably going to upload it as soon as it's 100% complete.)
It gets the coordinates of the specified node and saves them using data.add();, then sends a message to the player script.
The player script now reads the data and moves to the correct position.
This is very... ugly. It would be better if all this could be done in the teleporter script. Is there a way to do that? Some weird API that I forgot about?
Or maybe it would be possible to kind of... pass a reference to the player object to the teleporter like...
Code:
var player = <reference to the player object or smth?>;
player.position.place(x,z,y,ang);
(That would actually be pretty awesome.) :D
Yeah, I actually do this same trick in the long lost and not worked on for a while Scruffy, which has heavy use of teleporters and regenerating items. A move function to the map.object would solve almost all these problems, but you'd probably still want to trigger things in the script itself (for instance, teleport effects and such.)

[>] Brian
Reference URL's