| Blockland Forums > Modification Help |
| Using variables as functions in schedules. |
| (1/1) |
| ZSNO:
Lets say I have a something I want to do, but the ID of the object can change. So I do like --- Code: --- %client.player.setScale("1 1 1"); --- End code --- But what if I want to delay it? Using --- Code: ---schedule(1000,0,%client.player.setScale,"1 1 1"); --- End code --- Doesn't work. Is there a way you can do this without making a whole new function to call instead of the variable? |
| Kalphiter:
%client.player.schedule(1000,setScale,"1 1 1"); |
| ZSNO:
Thanks, I never had to use that before :P |
| Chrono:
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: ---%client.schedule(1000,setNormalScale); --- End code --- And as a separate function: --- Code: ---function GameConnection::setNormalScale(%this) { if(isObject(%this.player)) %this.player.setScale("1 1 1"); } --- End code --- |
| Navigation |
| Message Index |