Channel Timer

Runes of Magic/Radiant Arcana (http://www.runesofmagic.com)
Post Reply
Message
Author
zephir
Posts: 8
Joined: Fri Sep 02, 2011 7:43 pm

Channel Timer

#1 Post by zephir » 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

Code: Select all

	<onLoad>		
		createTimer();
	</onLoad>

	<onLeaveCombat>	
		activateTimer();
	</onLeaveCombat>
in the user functions

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;
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.
Last edited by zephir on Sun Sep 04, 2011 4:25 am, edited 1 time in total.

User avatar
lisa
Posts: 8332
Joined: Tue Nov 09, 2010 11:46 pm
Location: Australia

Re: Channel Timer

#2 Post by lisa » Sat Sep 03, 2011 10:03 pm

well first thing I notice is you get stuck in the loop of createTimer() waiting for the keypress, so it won't do anything else unless you press F.

Second you call for a few functions but I don't see the code for it anywhere.

I don't really understand exactly what you are trying to do, so not sure i can be much more help.
Remember no matter you do in life to always have a little fun while you are at it ;)

wiki here http://www.solarstrike.net/wiki/index.php?title=Manual

zephir
Posts: 8
Joined: Fri Sep 02, 2011 7:43 pm

Re: Channel Timer

#3 Post by zephir » Sun Sep 04, 2011 4:33 am

yea, chaged some function names before posting but now I think is good.

in onLoad it will create a code that will supposedly run a function if I press a key, and when I press it it will run a timer.

and in onLeaveCombat it will check if the timer is triggered and if it is, it will run the function that will change the channel.

Post Reply

Who is online

Users browsing this forum: Google [Bot] and 1 guest