SHOW:
|
|
- or go back to the newest paste.
| 1 | // THIS SCRIPT IS DESIGNED TO RUN INSIDE THE GAME "Red Eclipse" | |
| 2 | - | strreplace (concat ( |
| 2 | + | // IT ALSO REQUIRES THE DOWNLOAD OF SEVERAL ICONS TO RUN |
| 3 | - | div $arg1 1000 |
| 3 | + | // GET THE FULL PACKAGE HERE: http://www.mediafire.com/?ck2aweob5b19u5u |
| 4 | - | ) ( |
| 4 | + | // SCREENSHOTS: https://picasaweb.google.com/100507423399450376473/RedEclipse |
| 5 | - | padnum (padnum (mod $arg1 1000) 10) 100 |
| 5 | + | |
| 6 | - | )) " " ":" |
| 6 | + | |
| 7 | _ms_w = 9 // board width | |
| 8 | _ms_m = 10 // board mines | |
| 9 | - | padnum = [ concatword (? (< $arg1 $arg2) 0) $arg1 ] |
| 9 | + | |
| 10 | _ms_tw = 9 // temp W | |
| 11 | _ms_tm = 10 // temp M | |
| 12 | _ms_tu = 1 // temp U | |
| 13 | _ms_bt = 0 // board tiles (total) | |
| 14 | _ms_t1 = 0 // timer start (ms) | |
| 15 | _ms_t2 = 0 // timer end (ms) | |
| 16 | _ms_ua = 1 // undo toggle | |
| 17 | _ms_u = 0 // undo counter | |
| 18 | _ms_pc = 0 // completion percentage | |
| 19 | _ms_gm = 0 // game mode: 0 waiting; 1 active; 2 failure ; 3 victory | |
| 20 | ||
| 21 | _ms_mf = "" // board containing mine placement | |
| 22 | _ms_nf = "" // board containing tile numbers | |
| 23 | _ms_cf = "" // board of completion (displayed) | |
| 24 | _ms_mp = "" // supplementary list with mine positions | |
| 25 | _ms_hp = "" // supplementary list with hit mine positions | |
| 26 | _ms_fp = "" // supplementary list with flag positions | |
| 27 | _ms_tq = "" // supplementary list with tile reveal queue | |
| 28 | ||
| 29 | ||
| 30 | // ----------------------------------------- // | |
| 31 | // ---------------- Tile ID ---------------- // | |
| 32 | // ----------------------------------------- // | |
| 33 | // 0 = blank tile | |
| 34 | // 1-8 = number tiles | |
| 35 | // H = hidden tile | |
| 36 | // X = mine tile (failure) | |
| 37 | // HX = mine tile (victory) | |
| 38 | // R = hit mine tile | |
| 39 | // F = flagged tile | |
| 40 | // FX = flagged mine tile (success) | |
| 41 | // FF = flagged mine tile (failure) | |
| 42 | ||
| 43 | ||
| 44 | append = [ $arg1 = (concat (getalias $arg1) $arg2) ] | |
| 45 | ||
| 46 | _ms_clock = [ | |
| 47 | local n | |
| 48 | n = (mod $arg1 1000) | |
| 49 | format "%1:%2%3" (div $arg1 1000) (? (< $n 100) (? (< $n 10) "00" "0")) $n | |
| 50 | ] | |
| 51 | ||
| 52 | _ms_set_options = [ | |
| 53 | local n | |
| 54 | n = (* $_ms_th $_ms_tw) | |
| 55 | // calculate board sizes/mines and apply limits | |
| 56 | if $arg1 [ _ms_th = (max (min $arg1 24) 9) ] | |
| 57 | if $arg2 [ _ms_tw = (max (min $arg2 30) 9) ] | |
| 58 | _ms_tm = (max (min (div $n 3) $_ms_tm) (div $n 10)) | |
| 59 | ] | |
| 60 | ||
| 61 | _ms_set_markers = [ | |
| 62 | // in case of failure, update flag markers | |
| 63 | if (= $_ms_gm 2) [ | |
| 64 | looplist i $_ms_fp [ | |
| 65 | if (=s (at $_ms_nf $i) "X") [ | |
| 66 | _ms_tile_open "FX" $i 0 | |
| 67 | ] [ _ms_tile_open "FF" $i 0 ] | |
| 68 | ] | |
| 69 | - | if (< (indexof "R FX FF" (at $_ms_cf $i)) 0) [ |
| 69 | + | |
| 70 | - | case $_ms_gm 2 [ |
| 70 | + | |
| 71 | looplist i $_ms_mp [ | |
| 72 | - | ] 3 [ |
| 72 | + | case $_ms_gm 2 [ |
| 73 | if (< (indexof "R FX FF" (at $_ms_cf $i)) 0) [ | |
| 74 | _ms_tile_open "X" $i 0 | |
| 75 | ] | |
| 76 | ] 3 [ | |
| 77 | if (< (indexof "R F" (at $_ms_cf $i)) 0) [ | |
| 78 | _ms_tile_open "HX" $i 0 | |
| 79 | ] | |
| 80 | ] | |
| 81 | ] | |
| 82 | ] | |
| 83 | ||
| 84 | - | _ms_t2 = 0 |
| 84 | + | |
| 85 | // start the game if still in waiting phase | |
| 86 | if (= $_ms_gm 0) [ | |
| 87 | _ms_gm = 1 | |
| 88 | _ms_t1 = (getmillis) | |
| 89 | ] | |
| 90 | // reveal # tile at given position and add to completion counter if needed | |
| 91 | _ms_cf = (listsplice $_ms_cf $arg1 $arg2 1) | |
| 92 | if $arg3 [ _ms_pc = (+ $_ms_pc 1) ] | |
| 93 | ] | |
| 94 | ||
| 95 | _ms_tile_find = [ | |
| 96 | local n c1 c2 c3 c4 c5 c6 c7 c8 | |
| 97 | n = 0 | |
| 98 | c1 = (- $arg9 $_ms_w) // UP | |
| 99 | c2 = (+ $arg9 $_ms_w) // DN | |
| 100 | c3 = (- $arg9 1) // LT | |
| 101 | c4 = (+ $arg9 1) // RT | |
| 102 | c5 = (- $arg9 (+ $_ms_w 1)) // UP-LT | |
| 103 | c6 = (- $arg9 (- $_ms_w 1)) // UP-RT | |
| 104 | c7 = (+ $arg9 (- $_ms_w 1)) // DN-LT | |
| 105 | c8 = (+ $arg9 (+ $_ms_w 1)) // DN-RT | |
| 106 | if (> $c1 -1) $arg1 // UP | |
| 107 | if (< $c2 $_ms_bt) $arg2 // DN | |
| 108 | if (> (mod $arg9 $_ms_w) 0) $arg3 // LT | |
| 109 | if (< (mod $arg9 $_ms_w) (- $_ms_w 1)) $arg4 // RT | |
| 110 | if (&& [> $c5 -1] [> (mod $arg9 $_ms_w) 0]) $arg5 // UP-LT | |
| 111 | if (&& [> $c6 -1] [< (mod $arg9 $_ms_w) (- $_ms_w 1)]) $arg6 // UP-RT | |
| 112 | if (&& [< $c7 $_ms_bt] [> (mod $arg9 $_ms_w) 0]) $arg7 // DN-LT | |
| 113 | if (&& [< $c8 $_ms_bt] [< (mod $arg9 $_ms_w) (- $_ms_w 1)]) $arg8 // DN-RT | |
| 114 | arg10 | |
| 115 | ] | |
| 116 | ||
| 117 | _ms_tile_view = [ | |
| 118 | if (&& [< $_ms_gm 2] [=s (at $_ms_cf $arg1) "H"]) [ | |
| 119 | local n t | |
| 120 | n = (at $_ms_nf $arg1) | |
| 121 | cases $n "X" [ | |
| 122 | // mark the mine as hit | |
| 123 | _ms_tile_open "R" $arg1 0 | |
| 124 | append _ms_hp $arg1 | |
| 125 | // if lives are enabled, reduce by one, otherwise | |
| 126 | if (&& $_ms_ua $_ms_u) [ _ms_u = (- $_ms_u 1) ] [ | |
| 127 | // game over, board is populated by hit and undiscovered mines and flag marks | |
| 128 | _ms_gm = 2 | |
| 129 | _ms_t2 = (getmillis) | |
| 130 | _ms_set_markers | |
| 131 | ] | |
| 132 | ] "R" [ | |
| 133 | // do nothing here, simply skip | |
| 134 | ] "F" [ | |
| 135 | // do nothing here, simply skip | |
| 136 | ] "0" [ | |
| 137 | _ms_tile_open "0" $arg1 1 | |
| 138 | append _ms_tq $arg1 | |
| 139 | // explore all surrounding tiles until number border | |
| 140 | while [listlen $_ms_tq] [ | |
| 141 | do [ _ms_tile_find @( | |
| 142 | loopconcat i 8 [result [[ | |
| 143 | n = $c@@(+ $i 1) | |
| 144 | // make sure the tile is not revealed, otherwise skip tile | |
| 145 | if (=s (at $_ms_cf $n) "H") [ | |
| 146 | // ensure tile is blank and not in work queue, then add it | |
| 147 | if (&& [=s (at $_ms_nf $n) "0"] [< (indexof $_ms_tq $n) 0]) [ | |
| 148 | append _ms_tq $n | |
| 149 | ] | |
| 150 | // reveal the tile around the blank tile and add to completion percentage | |
| 151 | _ms_tile_open (at $_ms_nf $n) $n 1 | |
| 152 | ] | |
| 153 | ]]] | |
| 154 | ) (at $_ms_tq 0) ] | |
| 155 | // remove used tile from work queue | |
| 156 | _ms_tq = (sublist $_ms_tq 1) | |
| 157 | ] | |
| 158 | ] () [ _ms_tile_open $n $arg1 1 ] | |
| 159 | // in case of board completion, victory | |
| 160 | if (= $_ms_pc (- $_ms_bt $_ms_m)) [ | |
| 161 | _ms_gm = 3 ; _ms_t2 = (getmillis) | |
| 162 | _ms_set_markers | |
| 163 | ] | |
| 164 | ] | |
| 165 | ] | |
| 166 | ||
| 167 | _ms_make_board = [ | |
| 168 | local i n r | |
| 169 | i = 0 | |
| 170 | // initialise board variables | |
| 171 | _ms_th = $arg1 | |
| 172 | _ms_tw = $arg2 | |
| 173 | _ms_m = $arg3 | |
| 174 | _ms_h = $_ms_th | |
| 175 | _ms_w = $_ms_tw | |
| 176 | _ms_tm = $_ms_m | |
| 177 | // initialise game variables | |
| 178 | _ms_ua = $_ms_tu | |
| 179 | if $_ms_ua [ _ms_u = (+ (div $_ms_m 20) 1) ] | |
| 180 | _ms_bt = (* $_ms_h $_ms_w) | |
| 181 | _ms_pc = 0 | |
| 182 | _ms_t1 = 0 | |
| 183 | _ms_t2 = 0 | |
| 184 | _ms_gm = 0 | |
| 185 | // initialise boards | |
| 186 | _ms_nf = "" | |
| 187 | _ms_mf = (loopconcat i $_ms_bt [result "0"]) | |
| 188 | _ms_cf = (loopconcat i $_ms_bt [result "H"]) | |
| 189 | // initialise supplementary lists | |
| 190 | _ms_tq = "" | |
| 191 | _ms_mp = "" | |
| 192 | _ms_hp = "" | |
| 193 | _ms_fp = "" | |
| 194 | // generate the mines board | |
| 195 | while [< $i $_ms_m] [ | |
| 196 | r = (rnd $_ms_bt) | |
| 197 | // avoid writing to a previously picked spot | |
| 198 | if (! (at $_ms_mf $r)) [ | |
| 199 | _ms_mf = (listsplice $_ms_mf "1" $r 1) | |
| 200 | append _ms_mp $r | |
| 201 | i = (+ $i 1) | |
| 202 | ] | |
| 203 | ] | |
| 204 | // generate the numbers board | |
| 205 | loop y $_ms_bt [ | |
| 206 | if (at $_ms_mf $y) [ append _ms_nf "X" ] [ | |
| 207 | do [ _ms_tile_find @( | |
| 208 | loopconcat i 8 [result [[ | |
| 209 | n = (+ (at $_ms_mf $c@@(+ $i 1)) $n) | |
| 210 | ]]] | |
| 211 | ) $y [ append _ms_nf $n ] ] | |
| 212 | ] | |
| 213 | ] | |
| 214 | ] | |
| 215 | ||
| 216 | newgui minesweeper [ | |
| 217 | - | result (case $_ms_gm 0 7 1 7 2 3 3 0) |
| 217 | + | |
| 218 | guilist [ | |
| 219 | guilist [ | |
| 220 | guilist [ | |
| 221 | - | _ms_clock (case $_ms_gm 0 0 1 (- (getmillis) $_ms_t1) () (- $_ms_t2 $_ms_t1)) |
| 221 | + | |
| 222 | guititle (format "^f(textures/minesweeper/globe) ^f%1%2%%" ( | |
| 223 | case $_ms_gm 2 [ result "[0xFF1010]" ] 3 [ result "[0x4CFF00]" ] () [ result 7 ] | |
| 224 | ) (absf (precf (*f (divf $_ms_pc (- $_ms_bt $_ms_m)) 100) 1))) | |
| 225 | guispring | |
| 226 | guititle (format "^f7%1 ^f(textures/minesweeper/clock)" ( | |
| 227 | _ms_clock (case $_ms_gm 0 0 1 (- $getmillis $_ms_t1) () (- $_ms_t2 $_ms_t1)) | |
| 228 | )) | |
| 229 | guistrut 1 | |
| 230 | ] | |
| 231 | - | guibutton (format "^f(textures/minesweeper/tiles/%1)" (at $_ms_cf $n)) [ |
| 231 | + | |
| 232 | - | _ms_tile_view @n |
| 232 | + | |
| 233 | - | ] [ |
| 233 | + | |
| 234 | loop x $_ms_w [ | |
| 235 | n = (+ (* $y $_ms_w) $x) | |
| 236 | guifont "huge" [ | |
| 237 | guibutton (format "^f(textures/minesweeper/tiles/%1)" (at $_ms_cf $n)) [ _ms_tile_view @n ] [ | |
| 238 | cond (=s (at $_ms_cf @n) "H") [ | |
| 239 | _ms_tile_open "F" @@n 0 | |
| 240 | append _ms_fp @@n | |
| 241 | ] (=s (at $_ms_cf @n) "F") [ | |
| 242 | _ms_tile_open "H" @@n 0 | |
| 243 | _ms_fp = (listdel $_ms_fp @@n) | |
| 244 | ] | |
| 245 | ] | |
| 246 | ] | |
| 247 | ] | |
| 248 | ] | |
| 249 | ] | |
| 250 | - | guibutton "^f(textures/minesweeper/new) ^f7New Game" [ |
| 250 | + | |
| 251 | if (!=s $_ms_cf "") [ guistrut 2 ] | |
| 252 | - | ] [] |
| 252 | + | |
| 253 | guifont "super" [ | |
| 254 | guibutton (format "^f(textures/minesweeper/new) %1New Game" (? (> $_ms_gm 1) "^fzwo")) [ | |
| 255 | - | guitext (format "^f(textures/minesweeper/life) ^f%1%2" (? $_ms_u 5 3) $_ms_u) |
| 255 | + | |
| 256 | ] | |
| 257 | - | guitext (format "^f(textures/minesweeper/flag) ^f5%1" (- $_ms_m (listlen $_ms_fp))) |
| 257 | + | |
| 258 | guilist [ | |
| 259 | guitext (format "^f(textures/minesweeper/life) %1%2" (? $_ms_u "^f5" "^f[0xFF1010]") (? $_ms_ua $_ms_u 0)) | |
| 260 | guistrut 1.8 | |
| 261 | guitext (format "^f(textures/minesweeper/flag) ^f5%1" (- $_ms_m (listlen $_ms_fp) (listlen $_ms_hp))) | |
| 262 | ] | |
| 263 | guispring | |
| 264 | guilist [ | |
| 265 | guispring | |
| 266 | guilist [ | |
| 267 | guilist [ | |
| 268 | guitext "^f(textures/minesweeper/height)" | |
| 269 | guifield _ms_th 2 [ _ms_set_options $_ms_th 0 ] | |
| 270 | ] | |
| 271 | - | guistrut 2.5 |
| 271 | + | |
| 272 | guitext "^f(textures/minesweeper/width)" | |
| 273 | guifield _ms_tw 2 [ _ms_set_options 0 $_ms_tw ] | |
| 274 | ] | |
| 275 | ] | |
| 276 | guispring | |
| 277 | guilist [ | |
| 278 | guicenter [ guitext "^f(textures/minesweeper/mine)" ] | |
| 279 | - | guititle "^f4Difficulty" |
| 279 | + | |
| 280 | ] | |
| 281 | - | guibutton "^f7Beginner" [ _ms_make_board 9 9 10 ] [] |
| 281 | + | guispring |
| 282 | - | guibutton "^f7Intermediate" [ _ms_make_board 16 16 40 ] [] |
| 282 | + | |
| 283 | - | guibutton "^f7Expert" [ _ms_make_board 16 30 80 ] [] |
| 283 | + | |
| 284 | guistrut 1 | |
| 285 | - | guibutton (format "^f(textures/minesweeper/check_%1) Use Lives" ( |
| 285 | + | guicenter [ guititle "Difficulty" ] |
| 286 | - | ? (= (+ $_ms_tu $_ms_ua) 0) "off" (? (= (+ $_ms_tu $_ms_ua) 2) "on" "sel") |
| 286 | + | |
| 287 | - | )) [ _ms_tu = (! $_ms_tu) ] |
| 287 | + | guicenter [ guibutton "Easy" [ _ms_make_board 9 9 10 ] [] "" 0x4CFF00 ] |
| 288 | guicenter [ guibutton "Normal" [ _ms_make_board 16 16 40 ] [] "" 0xFFD800 ] | |
| 289 | guicenter [ guibutton "Hard" [ _ms_make_board 16 30 80 ] [] "" 0xFF1010 ] | |
| 290 | guistrut 1 | |
| 291 | guicenter [ guibutton (format "^f(textures/minesweeper/check_%1) Use Lives" ( | |
| 292 | case (+ $_ms_tu $_ms_ua) 0 [ result "off" ] 1 [ result "sel" ] 2 [ result "on" ] | |
| 293 | )) [ | |
| 294 | _ms_tu = (! $_ms_tu) | |
| 295 | if (! $_ms_gm) [ _ms_ua = $_ms_tu ] | |
| 296 | ] ] | |
| 297 | guistrut 0.5 | |
| 298 | ] | |
| 299 | ] | |
| 300 | ] | |
| 301 | ] [ | |
| 302 | if (= $guipasses 0) [ | |
| 303 | _ms_make_board $_ms_th $_ms_tw $_ms_tm | |
| 304 | ] | |
| 305 | ] |