Advertisement
Guest User

Code to make MEGA work with Event Scripting

a guest
Nov 26th, 2017
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.78 KB | None | 0 0
  1. package mctwist
  2. {
  3.     function EventScriptClient_save()
  4.     {
  5.         %list = new ScriptObject();
  6.         %events = WrenchEvents_Box.highestOrder;
  7.         if(%events < 2)
  8.             return;
  9.         %list.count = 0;
  10.         for(%a=0;%a<%events;%a++)
  11.         {
  12.             %swatch = WrenchEvents_Box.order[%a];
  13.             if(!isObject(%swatch.outputButton))
  14.                 continue;
  15.             %list.count++;
  16.  
  17.             %list.value[%a, "line"] = %a;
  18.             %list.value[%a, "enabled"] = %swatch.enabledBox.getValue();
  19.             %list.value[%a, "delay"] = %swatch.delayBox.getValue();
  20.             %list.value[%a, "inputEventName"] = %swatch.inputButton.getValue();
  21.             %list.value[%a, "targetName"] = %swatch.targetButton.getValue();
  22.             if(%swatch.targetButton.getValue() $= "Named Brick")
  23.             {
  24.                 %list.value[%a, "targetName"] = "";
  25.                 %list.value[%a, "NTName"] = %swatch.namedBrickButton.getValue();
  26.             }
  27.             %list.value[%a, "outputEventName"] = %swatch.outputButton.getValue();
  28.             for(%b=0;%b<%swatch.params;%b++)
  29.                 %list.value[%a, "params"] = %list.value[%a, "params"] @ getParam(%swatch.param[%b],true) @ "\t";
  30.         }
  31.         return EventScript_toScript(%list);
  32.     }
  33.  
  34.     function EventScriptClient_load(%script)
  35.     {
  36.         %list = EventScript_fromScript(%script);
  37.  
  38.         clearWrenchEventsBox();
  39.         WrenchEventsDlg.newEvent();
  40.        
  41.         for(%a = 0; %a<%list.count; %a++)
  42.         {
  43.             %bottomSwatch = WrenchEvents_Box.order[WrenchEvents_Box.highestOrder-1];
  44.        
  45.             %bottomSwatch.enabledBox.setValue(%list.value[%a,"enabled"]);
  46.             %bottomSwatch.delayBox.setValue(%list.value[%a,"delay"]);
  47.             %bottomSwatch.inputButton.noFocus = true;
  48.             for(%b=0;%b<$InputEvent_CountfxDTSBrick;%b++)
  49.                 if($InputEvent_NamefxDTSBrick_[%b] $= %list.value[%a,"inputEventName"])
  50.                     %bottomSwatch.inputButton.setSelected(%b);
  51.             %targets = $InputEvent_TargetListfxDTSBrick_[%bottomSwatch.inputButton.getSelected()];
  52.             %bottomSwatch.targetButton.noFocus = true;
  53.             if(%list.value[%a,"targetName"] $= "" || %list.value[%a,"targetName"] $= " ")
  54.             {
  55.                 %bottomSwatch.targetButton.setSelected(999);
  56.  
  57.                 %nameID = -1;
  58.                 for(%b=0;%b<ServerConnection.NTNameCount;%b++)
  59.                 {
  60.                     if(ServerConnection.NTName[%b] $= ("_" @ %list.value[%a,"NTName"]))
  61.                     {
  62.                         %nameID = %b;
  63.                         break;
  64.                     }
  65.                 }
  66.                 if(isObject(%bottomSwatch.namedBrickButton))
  67.                     %bottomSwatch.namedBrickButton.setSelected(%nameID);
  68.             }
  69.             else
  70.             {
  71.                 for(%b = 0; %b<getFieldCount(%targets); %b++)
  72.                 {
  73.                     %target = getField(%targets,%b);
  74.                     if(getWord(%target,0) $= %list.value[%a,"targetName"])
  75.                         %bottomSwatch.targetButton.setSelected(%b);
  76.                 }
  77.             }
  78.             %tar = %bottomSwatch.targetButton.getSelected();
  79.             if(%tar == 999)
  80.                 %tar = 0;
  81.             %className = getWord(getField(%targets,%tar),1);
  82.             for(%b=0;%b<$OutputEvent_Count[%className];%b++)
  83.                 if($OutputEvent_Name[%className,%b] $= %list.value[%a,"outputEventName"])
  84.                     %bottomSwatch.outputButton.setSelected(%b);
  85.  
  86.             %params = getFieldCount(%list.value[%a,"params"]);
  87.             for(%b=0;%b<%params;%b++)
  88.             {
  89.                 %element = %bottomSwatch.param[%b];
  90.                 %param = getField(%list.value[%a,"params"],%b);
  91.                 if(%element.paramType $= "intlist" || %element.paramType $= "string" || %element.paramType $= "int" || %element.paramType $= "float" || %element.paramType $= "bool")
  92.                     %element.setValue(%param);
  93.                 else if(%element.paramType $= "vector")
  94.                 {
  95.                     %element.getObject(0).setValue(getWord(%param,0));
  96.                     %element.getObject(1).setValue(getWord(%param,1));
  97.                     %element.getObject(2).setValue(getWord(%param,2));
  98.                 }
  99.                 else if(%element.paramType $= "list" || %element.paramType $= "datablock")
  100.                     %element.setSelected(%element.entryID[%param]);
  101.                 else if(%element.paramType $= "paintColor")
  102.                 {
  103.                     %element.picked = %param;
  104.                     %element.color = getColorI(getColorIDTable(%param));
  105.                 }
  106.             }
  107.  
  108.             %lastCreatedSwatch = %bottomSwatch;
  109.         }
  110.     }
  111. };
  112. activatePackage(mctwist);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement