Author Topic: onMinigameReset Event  (Read 1778 times)

An OnMinigameReset Event.

I don't think this has been made. Searching yielded no results.

One things for sure, It'd be useful...

I have one, but I made it myself.  It does a loop for all bricks though, since it doesn't actually serve as input alone.


Do want.

Though, you could make it (sort of) by eventing a player spawn with an OnPlayerTouch event.

would you like it to reset the minigame, then trigger the event, or trigger event first, then complete the minigame reset?

would you like it to reset the minigame, then trigger the event, or trigger event first, then complete the minigame reset?

It should be an event that's activated by an existing minigame being re-set. It shouldn't re-set the minigame itself.

Do want.

Though, you could make it (sort of) by eventing a player spawn with an OnPlayerTouch event.

Problem is, if someone unknowingly stands, walks over, or becomes AFK on the Player Spawn. That causes major problems looping the event...

What I mean is, when you reset the minigame, sometimes you need to reference the minigame itself, and if the minigame has already been reset, it doesn't work right.  Other times, you need to mini to finish resetting before your event will work.
Anyway, here is the event.

Code: [Select]
registerInputEvent("fxDTSBrick", "onReset", "Self fxDTSBrick" TAB "Player player" TAB "Client gameConnection");

package MinigameReset
{
function MinigameSO::reset(%this, %client)
{
for(%a=0; %a<brickGroup.getCount(); %a++)
brickGroup.getObject(%a).processInputEvent("OnReset", %client);
Parent::reset(%this, %client);
}
};
activatePackage(MinigameReset);

function fxDTSBrick::onReset(%brick, %client)
{
$inputTarget_self = %brick;
$inputTarget_client = %client;
$inputTarget_player = %client.player;
$inputTarget_miniGame = (isObject(getMiniGameFromObject(%client)))?getMiniGameFromObject(%client):0;
%brick.processInputEvent("OnReset", %client);
}

What I mean is, when you reset the minigame, sometimes you need to reference the minigame itself, and if the minigame has already been reset, it doesn't work right.  Other times, you need to mini to finish resetting before your event will work.
Anyway, here is the event.

Code: [Select]
registerInputEvent("fxDTSBrick", "onReset", "Self fxDTSBrick" TAB "Player player" TAB "Client gameConnection");

package MinigameReset
{
function MinigameSO::reset(%this, %client)
{
for(%a=0; %a<brickGroup.getCount(); %a++)
brickGroup.getObject(%a).processInputEvent("OnReset", %client);
Parent::reset(%this, %client);
}
};
activatePackage(MinigameReset);

function fxDTSBrick::onReset(%brick, %client)
{
$inputTarget_self = %brick;
$inputTarget_client = %client;
$inputTarget_player = %client.player;
$inputTarget_miniGame = (isObject(getMiniGameFromObject(%client)))?getMiniGameFromObject(%client):0;
%brick.processInputEvent("OnReset", %client);
}

Package and release?

> 128,000 bricks to loop through
> crap

Only call it on bricks whose events contain minigame events.

Perhaps minigame on RTB?

> 128,000 bricks to loop through
> crap

Only call it on bricks whose events contain minigame events.

It still would need to loop through all the bricks, and wrench events do that automatically.

Click

It still would need to loop through all the bricks, and wrench events do that automatically.

Click
http://www.youtube.com/watch?v=F3alA2_RZZY

Figure out how to detect when the event "onMinigameReset" is applied or removed from a brick, store or remove it from a list, then loop through the list when you need to.

http://www.youtube.com/watch?v=F3alA2_RZZY

Figure out how to detect when the event "onMinigameReset" is applied or removed from a brick, store or remove it from a list, then loop through the list when you need to.

I don't work with wrench events much past making the actual events,  I don't know what any of the default functions are, and I have never had the need to make a list before.  There would be plenty of loopholes too, since the function for loading wrench events is might be different from applying.  A similar event caused no lag in a server with 12.5k bricks, I think it will be fine.

DoublePost

Because I decided to do it.
I updated the download, so you can just click the link above.

At kalphiter's request, I just ripped most of this out of the OnPlayerSpawn event.

Code: [Select]
registerInputEvent("fxDTSBrick", "onReset", "Self fxDTSBrick" TAB "Player player" TAB "Client gameConnection");
$MinigameReset::List = inputEvent_GetInputEventIdx("onReset");

package MinigameReset
{
function MinigameSO::reset(%this, %client)
{
for(%i=0;%i<getWordCount($MinigameReset::List2);%i++)
{
%brick = getWord($MinigameReset::List2,%i);

if(isObject(%brick))
{
$inputTarget_self = %brick;
$inputTarget_client = %client;
$inputTarget_player = %client.player;
$inputTarget_miniGame = (isObject(getMiniGameFromObject(%client)))?getMiniGameFromObject(%client):0;
%brick.processInputEvent("OnReset", %client);
}
}
Parent::reset(%this, %client);
}

function serverCmdAddEvent(%client,%delay,%input,%target,%a,%b,%output,%para1,%para2,%para3,%para4)
{
if(%input == $MinigameReset::List)
{
$MinigameReset::List2 = addItemToList($MinigameReset::List2,%client.wrenchBrick);
}
return Parent::serverCmdAddEvent(%client,%delay,%input,%target,%a,%b,%output,%para1,%para2,%para3,%para4);
}

function serverCmdClearEvents(%client)
{
if(hasItemOnList($MinigameReset::List2,%client.wrenchBrick))
{
$MinigameReset::List2 = removeItemFromList($MinigameReset::List2,%client.wrenchBrick);
}
Parent::serverCmdClearEvents(%client);
}

function fxDtsBrick::onDeath(%brick)
{
if(hasItemOnList($MinigameReset::List2,%brick))
{
$MinigameReset::List2 = removeItemFromList($MinigameReset::List2,%brick);
}
Parent::onDeath(%brick);
}
};
activatePackage(MinigameReset);

function addItemToList(%string,%item)
{
if(hasItemOnList(%string,%item))
return %string;

if(%string $= "")
return %item;
else
return %string SPC %item;
}
function hasItemOnList(%string,%item)
{
for(%i=0;%i<getWordCount(%string);%i++)
{
if(getWord(%string,%i) $= %item)
return 1;
}
return 0;
}
function removeItemFromList(%string,%item)
{
if(!hasItemOnList(%string,%item))
return %string;

for(%i=0;%i<getWordCount(%string);%i++)
{
if(getWord(%string,%i) $= %item)
{
if(%i $= 0)
return getWords(%string,1,getWordCount(%string));
else if(%i $= getWordCount(%string)-1)
return getWords(%string,0,%i-1);
else
return getWords(%string,0,%i-1) SPC getWords(%string,%i+1,getWordCount(%string));
}
}
}

wait, what about this?
you guys love the search button...