How do you set timeouts or delay on plugins [.pl]

Wrote new code? Fixed a bug? Want to discuss technical stuff? Feel free to post it here.

Moderator: Moderators

einbroch
Human
Human
Posts: 21
Joined: 14 May 2011, 10:22
Noob?: Yes

How do you set timeouts or delay on plugins [.pl]

#1 Post by einbroch »

Here is an example

Code: Select all

	Commands::cmdStand();
	Commands::cmdUseSkill('sp', '29 "'.$payloadName.'"');
	sleep 2;
	# Cast Blessing to player
	Commands::cmdUseSkill('sp', '34 "'.$payloadName.'"');
	sleep 2;
	Commands::run("c hello'");
sleep this doesn't seem to work well
EternalHarvest
Developers
Developers
Posts: 1798
Joined: 05 Dec 2008, 05:42
Noob?: Yes

Re: How do you set timeouts or delay on plugins [.pl]

#2 Post by EternalHarvest »

Maybe Task::Chained or Task::Timeout can be used for that - create the task you need and add it to $taskManager.
einbroch
Human
Human
Posts: 21
Joined: 14 May 2011, 10:22
Noob?: Yes

Re: How do you set timeouts or delay on plugins [.pl]

#3 Post by einbroch »

@Eternal Harvest

Thank you, could you give me a quick example. If not, does openkore have a wiki for plugin development, I would definitely appreciate that.
EternalHarvest
Developers
Developers
Posts: 1798
Joined: 05 Dec 2008, 05:42
Noob?: Yes

Re: How do you set timeouts or delay on plugins [.pl]

#4 Post by EternalHarvest »

Just search for these names in OpenKore's sources and you'll find all the usage examples available.
einbroch
Human
Human
Posts: 21
Joined: 14 May 2011, 10:22
Noob?: Yes

Re: How do you set timeouts or delay on plugins [.pl]

#5 Post by einbroch »

Hi

Here is what I came up with:

Code: Select all

	my $buffAndSay = new Task::Chained(
		tasks => [
			new Task::SitStand(mode => 'stand'),
			new Task::Wait(seconds => 1),
			new Task::Function(function => sub {
				 # $task is the Task::Function object.
				 my ($task) = @_;
				 # Cast Increase Agi to Player
				 Commands::cmdUseSkill('sp', '29 "'.$payloadName.'"');
				 $task->setDone();
			}),
			new Task::Wait(seconds => 3),
			new Task::Function(function => sub {
				 # $task is the Task::Function object.
				 my ($task) = @_;
				 # Cast Blessing Agi to Player
				 Commands::cmdUseSkill('sp', '34 "'.$payloadName.'"');
				 $task->setDone();
			}),
			new Task::Wait(seconds => 1),
						new Task::Function(function => sub {
				 # $task is the Task::Function object.
				 my ($task) = @_;
				 # Ecxecute autowarp
				 Commands::run("c hello'");
				 $task->setDone();
			}),
		]
	);
	$taskManager->add($buffAndSay );
I get this error:

Code: Select all

Can't call method "isa" on an undefined value at src/Task/SitStand.pm line 55.
EternalHarvest
Developers
Developers
Posts: 1798
Joined: 05 Dec 2008, 05:42
Noob?: Yes

Re: How do you set timeouts or delay on plugins [.pl]

#6 Post by EternalHarvest »

Code: Select all

new Task::SitStand(actor => $char, mode => 'stand')
einbroch
Human
Human
Posts: 21
Joined: 14 May 2011, 10:22
Noob?: Yes

Re: How do you set timeouts or delay on plugins [.pl]

#7 Post by einbroch »

@EternalHarvest

I get this error:

Code: Select all

Can't locate object "new" via package "Task::SitStand"
my bad, I forgot:

Code: Select all

use Task::SitStand;