Channel Timer
Posted: Sat Sep 03, 2011 9:24 pm
Hello, I'm creating a channel timer, that will make the character change to the next channel every 2 hours, and I dont always need to change channel, so I need to activate the code with a keyboard press
the code is the following:
in the profile
in the user functions
There are somethings that need to be improved, like
detecting if the channel to wich is about to go is available, otherwise it could just end in the same channel
and probably intead of using newTimer, 'startTimer', 'removeTimer'. Just use 'registerTimer'
But the real problem is that the createTimer function, the loops that i've been trying to use like 'repeat' or 'registerTimer' just don't seem to work the way I want, and they stop the code execution with the loop.
the code is the following:
in the profile
Code: Select all
<onLoad>
createTimer();
</onLoad>
<onLeaveCombat>
activateTimer();
</onLeaveCombat>Code: Select all
function changeChannel()
id = RoMScript("GetCurrentParallelID()");
if ( id == 1 ) then
RoMScript("ChangeParallelID(2)");
printf("Current Channel: 1 \n");
printf("Changing to Channel: 2 \n");
elseif ( id == 2 ) then
RoMScript("ChangeParallelID(3)");
printf("Current Channel: 2 \n");
printf("Changing to Channel 3 \n");
elseif ( id == 3 ) then
RoMScript("ChangeParallelID(1)");
printf("Current Channel: 3 \n");
printf("Changing to Channel 1 \n");
end;
yrest(10000);
end;
function activateTimer()
if( isTriggered("channelTimer") ) then
removeTimer("channelTimer");
newTimer("channelTimer");
startTimer("channelTimer", 7200000);
printf("Channel Timer loaded \n");
changeChannel();
end;
end;
function createTimer()
repeat
if( keyPressed( key.VK_F ) ) then
newTimer("channelTimer");
startTimer( "channelTimer", 7200000);
printf("Channel Timer loaded \n");
end;
until keyPressed( key.VK_F )
end;
detecting if the channel to wich is about to go is available, otherwise it could just end in the same channel
and probably intead of using newTimer, 'startTimer', 'removeTimer'. Just use 'registerTimer'
But the real problem is that the createTimer function, the loops that i've been trying to use like 'repeat' or 'registerTimer' just don't seem to work the way I want, and they stop the code execution with the loop.