1. // (C) 2008 Leben Schnabel - not for commercial purposes without written consent
  2. integer Line;
  3. string NCName;
  4. list Datas;
  5. vector TempScale;
  6. default
  7. {
  8. on_rez(integer Dummy)
  9. {llResetScript();}
  10. state_entry()
  11. {
  12. llWhisper(0, "Maya Sculpt Importer");
  13. llWhisper(0, "Please drop a notecard with the Maya script in me and the textures i need. Click me to start.");
  14. }
  15. touch_start(integer total_number)
  16. {
  17. if (llDetectedKey(0) == llGetOwner())
  18. {
  19. NCName = llGetInventoryName(INVENTORY_NOTECARD, 0);
  20. if (NCName == "")
  21. {llWhisper(0, "Cannot start import, missing Maya script in notecard.");}
  22. else
  23. {state Start;}
  24. }
  25. }
  26. }
  27. state Start
  28. {
  29. on_rez(integer Dummy)
  30. {llResetScript();}
  31. state_entry()
  32. {
  33. llWhisper(0, "Beginning...");
  34. llGetNotecardLine(NCName, Line);
  35. }
  36. dataserver(key Dummy, string Data)
  37. {
  38. if (Data != EOF)
  39. {
  40. if (llToLower(Data) == "newprim")
  41. {
  42. if (llGetListLength(Datas) > 0)
  43. {
  44. integer TempChan = llRound(llFrand(100000)) + 100;
  45. llRezAtRoot(llGetInventoryName(INVENTORY_OBJECT, 0), llGetPos() + <1, 0, 1>, ZERO_VECTOR, ZERO_ROTATION,
  46. TempChan);
  47. llSay(TempChan, llDumpList2String(Datas, "^"));
  48. Datas = [];
  49. }
  50. }
  51. else
  52. {
  53. list Temp = llParseString2List(Data, [" "], []);
  54. integer i;
  55. for (i = 0; i < llGetListLength(Temp); ++i)
  56. {
  57. if (llList2String(Temp, i) == "-setObjectName")
  58. {
  59. Datas = (Datas=[]) + Datas + [".Name;" + llList2String(Temp, i + 1)];
  60. i = i + 1;
  61. }
  62. if (llList2String(Temp, i) == "-setSculpt")
  63. {
  64. key TextureKey = llGetInventoryKey(llList2String(Temp, i + 1));
  65. if (TextureKey == NULL_KEY)
  66. {llWhisper(0, "WARNING: Missing texture " + llList2String(Temp, i + 1));}
  67. else
  68. {
  69. string SculptType = "Spheric";
  70. if (llSubStringIndex(llToLower(llList2String(Temp, i + 1)), "planesculpt") != -1)
  71. {SculptType = "Plane";}
  72. if (llSubStringIndex(llToLower(llList2String(Temp, i + 1)), "cylindersculpt") != -1)
  73. {SculptType = "Cylinder";}
  74. Datas = (Datas=[]) + Datas + [".Sculpt;" + (string)TextureKey + ";" + SculptType];
  75. i = i + 1;
  76. }
  77. }
  78. if (llList2String(Temp, i) == "-setTexture")
  79. {
  80. key TextureKey = llGetInventoryKey(llList2String(Temp, i + 1));
  81. if (TextureKey == NULL_KEY)
  82. {llWhisper(0, "WARNING: Missing texture " + llList2String(Temp, i + 1));}
  83. else
  84. {
  85. Datas = (Datas=[]) + Datas + [".Texture;" + (string)TextureKey];
  86. i = i + 1;
  87. }
  88. }
  89. if (llList2String(Temp, i) == "-setScale")
  90. {
  91. TempScale = <llList2Float(Temp, i + 1), llList2Float(Temp, i + 2), llList2Float(Temp, i + 3)>;
  92. Datas = (Datas=[]) + Datas + [".Scale;<" + llList2String(Temp, i + 1) + "," +
  93. llList2String(Temp, i + 2) + "," +
  94. llList2String(Temp, i + 3) + ">"];
  95. i = i + 3;
  96. }
  97. if (llList2String(Temp, i) == "-gotoRelativePos")
  98. {
  99. Datas = (Datas=[]) + Datas + [".Pos;<" + (string)(llList2Float(Temp, i + 1) * TempScale.x) + "," +
  100. (string)(llList2Float(Temp, i + 2) * TempScale.y) + "," +
  101. (string)(llList2Float(Temp, i + 3) * TempScale.z) + ">"];
  102. i = i + 3;
  103. }
  104. }
  105. }
  106. Line = Line + 1;
  107. llGetNotecardLine(NCName, Line);
  108. }
  109. else
  110. {
  111. if (llGetListLength(Datas) > 0)
  112. {
  113. integer TempChan = llRound(llFrand(100000)) + 100;
  114. llRezAtRoot(llGetInventoryName(INVENTORY_OBJECT, 0), llGetPos() + <1, 0, 1>, ZERO_VECTOR, ZERO_ROTATION,
  115. TempChan);
  116. llSay(TempChan, llDumpList2String(Datas, "^"));
  117. }
  118. llWhisper(0, "Done.");
  119. llResetScript();
  120. }
  121. }
  122. }