Advertisement
Guest User

Touhou Henkaden V1.2 Replay Screen Context Fix

a guest
Dec 20th, 2015
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ++ Initial error output
  2.  
  3. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  4. Variables of different types are being compared
  5. (型が違う値同士を比較しようとしました)
  6. Z:/home/nassim/Documents/game/danmakufu/PancakeGame/Touhou Henkaden ~ Highly Responsive to Pancakes/script/Highly Responsive to Pancakes/Package.dnh
  7. Package.dnh line()=920
  8.  
  9.         if(info[0] == "StagePackMode"){SetCommonData("StagePackPath", info[2]);}
  10.        
  11.         TStageScene(GetReplayInfo(result, REPLAY_FILE_PATH));
  12.     }
  13. }
  14.  
  15. task TStagePackSelectScene {
  16.     SetSkipModeKey(KEY_INVALID);
  17.  
  18.     let idScript = LoadScript(GetCurrentScriptDir
  19. ~~~
  20. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  21.  
  22. ++ Fix
  23.  
  24. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  25. // File: Package.dnh
  26. //
  27. // starts line 904
  28. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  29.  
  30. task TReplaySelectScene {
  31.     SetSkipModeKey(KEY_INVALID);
  32.  
  33.     let idScript = LoadScript(GetCurrentScriptDirectory ~ "System/ReplaySelectScene.dnh");
  34.     StartScript(idScript);
  35.    
  36.     while(!IsCloseScript(idScript)) {
  37.         yield;
  38.     }
  39.    
  40.     let result = GetScriptResult(idScript);
  41.     if(result == -1) {
  42.         TTitleScene;
  43.     } else {
  44.        
  45.         let info = GetReplayInfo(result, REPLAY_COMMENT);
  46.         let len = length(info);
  47.         WriteLog("GETREPLAYINFO =========== length " ~ vtos("1d", len) ~ " == info " ~ ToString(info));
  48.  
  49.         // GetReplayInfo(result, RELAY_COMMENT) does not return an array but a string
  50.         // I have not test if it's SetReplayInfo which converts the array to a string
  51.         info = serializedArrayToArray(info);
  52.         len = length(info);
  53.         WriteLog("GETREPLAYINFO =========== length " ~ vtos("1d", len) ~ " == info " ~ ToString(info));
  54.  
  55.         //RaiseError("muujah!");
  56.  
  57.  
  58.         SetCommonData("PLAYER", info[0]);
  59.         SetCommonData("Mode", info[1]);
  60.         //if(info[0] == "StagePackMode"){SetCommonData("StagePackPath", info[2]);}
  61.         if(isSameString("StagePackMode", info[1])){SetCommonData("StagePackPath", info[2]);}
  62.        
  63.         TStageScene(GetReplayInfo(result, REPLAY_FILE_PATH));
  64.     }
  65. }
  66.  
  67. /* =========================================================================
  68. isSameString
  69.  
  70. Checks if the two input strings are identical
  71.  
  72. @param   string    ref      reference string
  73. @param   string    string   string to test
  74.  
  75. @return  boolean   true if strings are identical, false otherwise
  76. ========================================================================= */
  77. function isSameString(let ref, let string) {
  78.     if(length(string) != length(ref)) { return false; }
  79.     ascent(i in 0..length(ref)) {
  80.         if(string[i]!=ref[i]) { return false; }
  81.     }
  82.     return true;
  83. }
  84.  
  85. /* =========================================================================
  86. serializedArrayToArray
  87.  
  88. Converts a serialized array (string value) to a regular array
  89.  
  90. @param    string    stringArray    the serialized array to convert
  91.  
  92. @return   array
  93. ========================================================================= */
  94. function serializedArrayToArray(let stringArray) {
  95.     let separator = ",";
  96.     let len = length(stringArray);
  97.     //let separatorCount = 0;
  98.     let results = [];
  99.     let temp = "";
  100.     // range is 1..len-1 in order to get rid of "[" and "]" characters
  101.     ascent(i in 1..len-1) {
  102.         if(ToString(stringArray[i])!=separator) {
  103.             temp = temp ~ ToString(stringArray[i]);
  104.         }
  105.         else {
  106.             results = results ~ [ temp ];
  107.             temp = "";
  108.         }
  109.     }
  110.     // last result
  111.     results = results ~ [ temp ];
  112.  
  113.     return results;
  114. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement