I needed something to do on my ride home from New York to Boston.
It's very easy to add the parameters, assuming you know the smallest bit of scripting. As you can see in the example below, I have onProjectileHit check to see if the datablock of the projectile hitting the brick is the same as the input parameter. I also made sure it wasn't -1 ("NONE", meaning no requirement), and blank, meaning the client didn't have the client-side part of this mod and couldn't set a parameter.
The three below it, onActivate, onPlayerTouch, and onBotTouch are just things I slapped in there to make sure strings, lists, and ints worked.
function Check_onProjectileHit(%brick,%parameter,%client)
{
return (%parameter $= "" || %parameter == -1 || $InputTarget_["Projectile"].getDatablock() == %parameter);
}
registerInputParameter("onProjectileHit","datablock ProjectileData","Check_onProjectileHit");
function Check_onActivate(%brick,%parameter,%client)
{
return 1;
}
registerInputParameter("onActivate","string 5 Yes","Check_onActivate");
function Check_onPlayerTouch(%brick,%parameter,%client)
{
return 1;
}
registerInputParameter("onPlayerTouch","list NONE 0 Apples 1 Bananas 2 Oranges 3","Check_onPlayerTouch");
function Check_onBotTouch(%brick,%parameter,%client)
{
return 1;
}
registerInputParameter("onBotTouch","int 0 10 5","Check_onBotTouch");
The syntax is similar to event registration:
registerInputParameter(String InputEvent,String Parameters,String CallbackFunction);
Where the parameters can be:
datablock ClassName
string MaxLength Default
list String_1 ID_1 String_2 ID_2 ...
int Minimum Maximum Default
The callback function should accept three arguments; the brick that's processing the event, the parameter that corresponds to the event line being processed, and the client who's processing the event. If it returns 1, the event line will be processed normally, but if it returns 0, it will not process the event (as if it was disabled).
I plan to bug test this all of tomorrow and release it at midnight (GMT time) for the new year.
Comments, questions, concerns?
For registering the events -
A simpler method might be this:
registerInputEvent("fxDTSBrick", "onProjectileHit",
"Self fxDTSBrick" TAB
"Player Player" TAB
"Projectile Projectile" TAB
"Client GameConnection" TAB
"MiniGame MiniGame",
"datablock ProjectileData");
function fxDTSBrick::onProjectileHit(%obj,%projectile,%client)
{
...
%obj.processInputEvent("onProjectileHit", %projectile.dataBlock, %client);
}
When you register it, you specify a type it should be, then when it's triggered you put in the value it should check that against. In this case it checks a projectiledata against the one that hits its' datablock.
Not many types of fields would fit in that space, the most you could do is two boolean or integer fields - the rest would end up being too long.
Maybe check if function fxDTSBrick::onProjectileHit_Check exists and call it like yours in that case for more advanced checks than [datablock == selected value]. For datablock checks, "NONE" should be changed to "ANY" or "ALL" or something so it's clearer.
Apart from that, it looks very nice.
I might delay the release so that I can add these in, as well as some other stuff I've thought of. I've been putting it off, because it involves me pretty much rewriting the whole thing. I doubt I can get that done + test it in a reasonable amount of time (family holding new years party, being nagged to help set up), so everyone will just have to be patient.