Author Topic: Event Input Parameters  (Read 2858 times)

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.

Code: [Select]
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:

Code: [Select]
registerInputParameter(String InputEvent,String Parameters,String CallbackFunction);
Where the parameters can be:

Code: [Select]
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:
Code: [Select]
registerInputEvent("fxDTSBrick", "onProjectileHit",
                                     "Self fxDTSBrick" TAB
                                     "Player Player" TAB
                                     "Projectile Projectile" TAB
                                     "Client GameConnection" TAB
                                     "MiniGame MiniGame",
                                 "datablock ProjectileData");
Code: [Select]
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.
« Last Edit: December 31, 2009, 03:27:42 PM by Truce »

 Alright one question.. What did you do to that GUI

I found the Replacement pictures but Wheres M's Script?
« Last Edit: December 30, 2009, 06:33:28 PM by Flying Ace »



Alright one question.. What did you do to that GUI/what OS is that

That's the Blockland Aero mod by Svenne (GUI) and Clockturn (scripts).

will all members of the server see this or only the ones having the mod?

will all members of the server see this or only the ones having the mod?

Being a GUI edit, clients will have to download the script to have access to setting the input parameters.

I'm not sure I get exactly what the parameters will DO.  I understand how to make them, but not how to use them.  Also, link to the epic Gui would be nice ;P

Where about in ney york were you?

I'm not sure I get exactly what the parameters will DO.  I understand how to make them, but not how to use them.

http://forum.blockland.us/index.php?topic=41851.0


Yes, but what's with the text boxes on onActivate and onBotTouch?

The three below it, onActivate, onPlayerTouch, and onBotTouch are just things I slapped in there to make sure strings, lists, and ints worked.

An event might require a string to be compared, such as a custom event like onChatMessage (if that exists).

An event might require a string to be compared, such as a custom event like onChatMessage (if that exists).
Oooo.  Didn't think of that.  Useful.

EDIT:
Also, link to the epic Gui would be nice ;P
Found
« Last Edit: December 30, 2009, 07:21:30 PM by Gadgethm »


the replacements on RTB? or the transparency scripts by M (Clockturn)
Just Aero.  But if you have the trans script, I would like it :D

Edit:  I've been looking into the craftsmen history and it seems like the clan died for no reason other than Spock deleted the main post.  What WAS the reason?  And also, I never found a record of Clockturn giving the script to the clan, but Truce seems to have it...
« Last Edit: December 30, 2009, 08:00:17 PM by Gadgethm »