I think it's time for me to ask for help. After figuring it was about time I start trying to get into plugins, rather than keep making my macros.txt even more huge and convoluted than it already is; I decided to start simple and just try and convert one of my macros. In macro terms it couldn't be more simple; it waits a random amount of time between x number and y number and then sets a new random lockMap. Considering it is not doing anything that kore doesn't do in other functions, I thought the building blocks would be there for my to just build from other code in the source, and to a point that is true, except I have no idea what I'm doing.
Here is what I have thrown together so far:
Code: Select all
package autoMapChange;
use Plugins;
Plugins::register("autoMapChange", \&on_unload, \&on_reload);
my $hooks = Plugins::addHooks(
['mainLoop_pre', \&on_mainLoop]
);
sub on_unload {
Plugins::delHooks($hooks);
}
sub on_reload {
&on_unload;
}
sub on_mainLoop {
if ($config{'autoMapChange'} && time - $KoreStartTime > $config{'autoMapChange'} {
my @lockMapList = split(/,/, $config{autoMapChange_list});
my $lockMapNew = $lockMapList[rand @lockMapList];
my $lockMapPrev = $config{'lockMap'};
configModify("lockMap", $lockMapNew);
$timeout_ex{'master'}{'time'} = time;
$KoreStartTime = time + $timeout_ex{'master'}{'timeout'};
initChangeMap();
}
}
sub initChangeMap {
if ($config{'autoMapChange'}) {
$changeTime = $config{'autoMapChange_time'} + int(rand $config{'autoMapChange_timeSeed'});
configModify("autoMapChange", $changeTime, 1);
}
}
return 1
For a first plugin I'm sure this is wrong in more places than I have noticed right now, but I'm trying to figure it out piece by piece. This syntax error problem has just had me stumped for about two hours however.
Any help is appreciated,
Thanks.