Author Topic: Using variables as functions in schedules.  (Read 662 times)

Lets say I have a something I want to do, but the ID of the object can change. So I do like
Code: [Select]
%client.player.setScale("1 1 1");But what if I want to delay it? Using
Code: [Select]
schedule(1000,0,%client.player.setScale,"1 1 1");Doesn't work. Is there a way you can do this without making a whole new function to call instead of the variable?

%client.player.schedule(1000,setScale,"1 1 1");

Thanks, I never had to use that before :P

1. an object's ID cannot change. However, the value of a reference can change to point to another object's ID.
2. Even if you schedule it, the schedule will still cling to the older object's ID.
%client.player.schedule(... will convert within the engine, to: objectID.schedule, which means the schedule is bound to that object, rather than the .player value.

If you want this to happen to .player after a certain time even if it changes, you'd do something like this:

Code: [Select]
%client.schedule(1000,setNormalScale);

And as a separate function:
Code: [Select]
function GameConnection::setNormalScale(%this)
{
if(isObject(%this.player))
%this.player.setScale("1 1 1");
}