MpEncode.nas 875 B

1234567891011121314151617181920212223
  1. #MP payload transfer via string by Tomaskom
  2. var stringIndex = 0; #index of sim/multiplay/generic/string[i] which is used for transfer
  3. var intProp = "payload-int"; #expects existence of this property carrying int identifier of the payload option in every /sim/weight[i]/ - set this according to your payload management script
  4. var weightsNode = props.globals.getNode("/sim");
  5. #loop that assembles the string, values are delimited with comma
  6. var transmitString = func {
  7. var string = "";
  8. forindex(var i; weightsNode.getChildren("weight")) {
  9. string = string~(string==""?"":",")~int(getprop("/sim/weight["~i~"]/"~intProp));
  10. }
  11. setprop("sim/multiplay/generic/string["~stringIndex~"]", string);
  12. print(string);
  13. }
  14. forindex(var i; weightsNode.getChildren("weight")) {
  15. setlistener("/sim/weight["~i~"]/"~intProp, transmitString);
  16. }
  17. transmitString();
  18. print("Inited MpEncode");