Files
@ e713ba125275
Branch filter:
Location: games/Awakening/utils.lua - annotation
e713ba125275
17.9 KiB
text/x-lua
Prologue Bugfixes
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 | fda22c203ad5 fda22c203ad5 fda22c203ad5 fda22c203ad5 fda22c203ad5 fda22c203ad5 fda22c203ad5 fda22c203ad5 fda22c203ad5 fda22c203ad5 fda22c203ad5 fda22c203ad5 fda22c203ad5 fda22c203ad5 fda22c203ad5 fda22c203ad5 fda22c203ad5 fda22c203ad5 fda22c203ad5 fda22c203ad5 fda22c203ad5 fda22c203ad5 fda22c203ad5 fda22c203ad5 fda22c203ad5 fda22c203ad5 fda22c203ad5 fda22c203ad5 fda22c203ad5 77aa01170934 77aa01170934 77aa01170934 b01351c0d220 77aa01170934 77aa01170934 b01351c0d220 b01351c0d220 b01351c0d220 b01351c0d220 b01351c0d220 b01351c0d220 b01351c0d220 b01351c0d220 b01351c0d220 b01351c0d220 b01351c0d220 b01351c0d220 b01351c0d220 b01351c0d220 b01351c0d220 b01351c0d220 b01351c0d220 b01351c0d220 b01351c0d220 b01351c0d220 b01351c0d220 77aa01170934 77aa01170934 77aa01170934 77aa01170934 77aa01170934 77aa01170934 77aa01170934 38255c2dc001 38255c2dc001 38255c2dc001 38255c2dc001 38255c2dc001 38255c2dc001 77aa01170934 77aa01170934 77aa01170934 77aa01170934 77aa01170934 77aa01170934 77aa01170934 77aa01170934 77aa01170934 77aa01170934 77aa01170934 77aa01170934 af3387eae943 af3387eae943 af3387eae943 af3387eae943 af3387eae943 af3387eae943 af3387eae943 af3387eae943 af3387eae943 6e7519136e47 6e7519136e47 6e7519136e47 6e7519136e47 6e7519136e47 6e7519136e47 77aa01170934 77aa01170934 77aa01170934 b03c40a64562 b03c40a64562 b03c40a64562 b03c40a64562 b03c40a64562 b03c40a64562 b03c40a64562 b03c40a64562 6e7519136e47 b03c40a64562 77aa01170934 77aa01170934 77aa01170934 6e7519136e47 77aa01170934 77aa01170934 77aa01170934 6e7519136e47 6e7519136e47 24a46a8a6715 95c7d8d4730c 95c7d8d4730c 24a46a8a6715 24a46a8a6715 269aeef63080 24a46a8a6715 24a46a8a6715 95c7d8d4730c 95c7d8d4730c 6e7519136e47 6e7519136e47 6e7519136e47 6e7519136e47 6e7519136e47 6e7519136e47 6e7519136e47 6e7519136e47 6e7519136e47 6e7519136e47 6e7519136e47 6e7519136e47 6e7519136e47 6e7519136e47 6e7519136e47 6e7519136e47 6e7519136e47 6e7519136e47 6e7519136e47 6e7519136e47 6e7519136e47 6e7519136e47 6e7519136e47 6e7519136e47 6e7519136e47 6e7519136e47 6e7519136e47 6e7519136e47 6e7519136e47 6e7519136e47 6e7519136e47 6e7519136e47 6e7519136e47 6e7519136e47 6e7519136e47 6e7519136e47 f02901977ca4 6e7519136e47 6e7519136e47 6e7519136e47 6e7519136e47 6e7519136e47 6e7519136e47 6e7519136e47 6e7519136e47 6e7519136e47 6e7519136e47 6e7519136e47 6e7519136e47 6e7519136e47 6e7519136e47 6e7519136e47 6e7519136e47 6e7519136e47 6e7519136e47 6e7519136e47 6e7519136e47 6e7519136e47 6e7519136e47 6e7519136e47 6e7519136e47 6e7519136e47 6e7519136e47 6e7519136e47 6e7519136e47 6e7519136e47 6e7519136e47 6e7519136e47 6e7519136e47 6e7519136e47 6e7519136e47 6e7519136e47 6e7519136e47 6e7519136e47 6e7519136e47 6e7519136e47 6e7519136e47 6e7519136e47 6e7519136e47 1dca24259b66 1dca24259b66 1dca24259b66 6e7519136e47 6e7519136e47 6e7519136e47 6e7519136e47 6e7519136e47 6e7519136e47 6e7519136e47 1dca24259b66 6e7519136e47 6e7519136e47 6e7519136e47 6e7519136e47 6e7519136e47 6e7519136e47 6e7519136e47 6e7519136e47 6e7519136e47 6e7519136e47 6e7519136e47 6e7519136e47 6e7519136e47 6e7519136e47 6e7519136e47 6e7519136e47 6e7519136e47 6e7519136e47 6e7519136e47 6e7519136e47 6e7519136e47 6e7519136e47 6e7519136e47 6e7519136e47 6e7519136e47 6e7519136e47 6e7519136e47 6e7519136e47 6e7519136e47 6e7519136e47 6e7519136e47 6e7519136e47 6e7519136e47 6e7519136e47 6e7519136e47 6e7519136e47 6e7519136e47 6e7519136e47 6e7519136e47 4dea9ce5157f 1dca24259b66 1dca24259b66 1dca24259b66 4dea9ce5157f 1dca24259b66 4dea9ce5157f 6e7519136e47 4dea9ce5157f 6e7519136e47 4dea9ce5157f 6e7519136e47 6e7519136e47 6e7519136e47 6e7519136e47 9c3e0fecdb92 9c3e0fecdb92 ac0b2d6f5c08 ac0b2d6f5c08 ac0b2d6f5c08 ac0b2d6f5c08 ac0b2d6f5c08 ac0b2d6f5c08 ac0b2d6f5c08 ac0b2d6f5c08 ac0b2d6f5c08 19188a8a8dbe a2b2af954b81 a2b2af954b81 a2b2af954b81 19188a8a8dbe a2b2af954b81 9715b7dd6763 a2b2af954b81 a2b2af954b81 a2b2af954b81 a2b2af954b81 a2b2af954b81 a2b2af954b81 a2b2af954b81 9c3e0fecdb92 9c3e0fecdb92 9c3e0fecdb92 9c3e0fecdb92 9c3e0fecdb92 9c3e0fecdb92 9c3e0fecdb92 9c3e0fecdb92 9c3e0fecdb92 9c3e0fecdb92 9c3e0fecdb92 9c3e0fecdb92 9c3e0fecdb92 9c3e0fecdb92 9c3e0fecdb92 9c3e0fecdb92 9c3e0fecdb92 9c3e0fecdb92 9c3e0fecdb92 e8d1e9d9d258 cd509c6d111e 9c3e0fecdb92 9c3e0fecdb92 cd509c6d111e 9c3e0fecdb92 9c3e0fecdb92 9c3e0fecdb92 cd509c6d111e cd509c6d111e cd509c6d111e 9c3e0fecdb92 38255c2dc001 9c3e0fecdb92 9c3e0fecdb92 9c3e0fecdb92 9c3e0fecdb92 9c3e0fecdb92 9c3e0fecdb92 9c3e0fecdb92 9c3e0fecdb92 9c3e0fecdb92 9c3e0fecdb92 9c3e0fecdb92 9c3e0fecdb92 9c3e0fecdb92 9c3e0fecdb92 9c3e0fecdb92 cd509c6d111e cd509c6d111e cd509c6d111e cd509c6d111e cd509c6d111e cd509c6d111e cd509c6d111e cd509c6d111e cd509c6d111e cd509c6d111e cd509c6d111e cd509c6d111e cd509c6d111e 9c3e0fecdb92 9c3e0fecdb92 9c3e0fecdb92 dda2579e66e8 dda2579e66e8 95c7d8d4730c 95c7d8d4730c 95c7d8d4730c 95c7d8d4730c 95c7d8d4730c 95c7d8d4730c 95c7d8d4730c 95c7d8d4730c 95c7d8d4730c 95c7d8d4730c 95c7d8d4730c 95c7d8d4730c 95c7d8d4730c 95c7d8d4730c cd509c6d111e 95c7d8d4730c 95c7d8d4730c cd509c6d111e 95c7d8d4730c 95c7d8d4730c 95c7d8d4730c cd509c6d111e cd509c6d111e cd509c6d111e 95c7d8d4730c 95c7d8d4730c 95c7d8d4730c 95c7d8d4730c 95c7d8d4730c 95c7d8d4730c 95c7d8d4730c 95c7d8d4730c 95c7d8d4730c 95c7d8d4730c 95c7d8d4730c 95c7d8d4730c 95c7d8d4730c 95c7d8d4730c 95c7d8d4730c 95c7d8d4730c 95c7d8d4730c cd509c6d111e cd509c6d111e cd509c6d111e cd509c6d111e cd509c6d111e cd509c6d111e cd509c6d111e cd509c6d111e cd509c6d111e 95c7d8d4730c 95c7d8d4730c 95c7d8d4730c 95c7d8d4730c 95c7d8d4730c cd509c6d111e cd509c6d111e cd509c6d111e cd509c6d111e cd509c6d111e cd509c6d111e cd509c6d111e cd509c6d111e cd509c6d111e cd509c6d111e cd509c6d111e cd509c6d111e cd509c6d111e cd509c6d111e cd509c6d111e cd509c6d111e cd509c6d111e cd509c6d111e cd509c6d111e cd509c6d111e cd509c6d111e cd509c6d111e cd509c6d111e cd509c6d111e cd509c6d111e cd509c6d111e cd509c6d111e cd509c6d111e cd509c6d111e cd509c6d111e cd509c6d111e cd509c6d111e cd509c6d111e cd509c6d111e cd509c6d111e cd509c6d111e cd509c6d111e cd509c6d111e cd509c6d111e cd509c6d111e cd509c6d111e cd509c6d111e cd509c6d111e cd509c6d111e cd509c6d111e cd509c6d111e cd509c6d111e cd509c6d111e cd509c6d111e cd509c6d111e cd509c6d111e cd509c6d111e cd509c6d111e cd509c6d111e cd509c6d111e cd509c6d111e cd509c6d111e cd509c6d111e cd509c6d111e cd509c6d111e cd509c6d111e cd509c6d111e cd509c6d111e cd509c6d111e cd509c6d111e cd509c6d111e cd509c6d111e cd509c6d111e cd509c6d111e cd509c6d111e cd509c6d111e cd509c6d111e cd509c6d111e cd509c6d111e cd509c6d111e cd509c6d111e cd509c6d111e cd509c6d111e cd509c6d111e cd509c6d111e cd509c6d111e cd509c6d111e cd509c6d111e cd509c6d111e cd509c6d111e cd509c6d111e cd509c6d111e cd509c6d111e cd509c6d111e cd509c6d111e cd509c6d111e cd509c6d111e cd509c6d111e cd509c6d111e cd509c6d111e cd509c6d111e cd509c6d111e cd509c6d111e cd509c6d111e cd509c6d111e cd509c6d111e cd509c6d111e cd509c6d111e cd509c6d111e cd509c6d111e cd509c6d111e cd509c6d111e cd509c6d111e cd509c6d111e cd509c6d111e cd509c6d111e cd509c6d111e cd509c6d111e cd509c6d111e cd509c6d111e cd509c6d111e cd509c6d111e cd509c6d111e cd509c6d111e cd509c6d111e cd509c6d111e cd509c6d111e cd509c6d111e cd509c6d111e cd509c6d111e cd509c6d111e cd509c6d111e cd509c6d111e cd509c6d111e cd509c6d111e cd509c6d111e cd509c6d111e cd509c6d111e cd509c6d111e cd509c6d111e cd509c6d111e cd509c6d111e cd509c6d111e cd509c6d111e cd509c6d111e cd509c6d111e 95c7d8d4730c dda2579e66e8 dda2579e66e8 dda2579e66e8 dda2579e66e8 dda2579e66e8 dda2579e66e8 dda2579e66e8 dda2579e66e8 dda2579e66e8 dda2579e66e8 dda2579e66e8 dda2579e66e8 dda2579e66e8 dda2579e66e8 dda2579e66e8 dda2579e66e8 dda2579e66e8 dda2579e66e8 dda2579e66e8 dda2579e66e8 dda2579e66e8 dda2579e66e8 dda2579e66e8 dda2579e66e8 dda2579e66e8 dda2579e66e8 dda2579e66e8 dda2579e66e8 dda2579e66e8 dda2579e66e8 dda2579e66e8 dda2579e66e8 dda2579e66e8 dda2579e66e8 dda2579e66e8 dda2579e66e8 eaf92b073787 eaf92b073787 f16f3ae5a5b1 f16f3ae5a5b1 f16f3ae5a5b1 f16f3ae5a5b1 f16f3ae5a5b1 f16f3ae5a5b1 f16f3ae5a5b1 f16f3ae5a5b1 f16f3ae5a5b1 f16f3ae5a5b1 f16f3ae5a5b1 f16f3ae5a5b1 f16f3ae5a5b1 f16f3ae5a5b1 f16f3ae5a5b1 f16f3ae5a5b1 f16f3ae5a5b1 f16f3ae5a5b1 f16f3ae5a5b1 f16f3ae5a5b1 f16f3ae5a5b1 f16f3ae5a5b1 f16f3ae5a5b1 f16f3ae5a5b1 f16f3ae5a5b1 f16f3ae5a5b1 f16f3ae5a5b1 f16f3ae5a5b1 f16f3ae5a5b1 f16f3ae5a5b1 f16f3ae5a5b1 f16f3ae5a5b1 f16f3ae5a5b1 f16f3ae5a5b1 eaf92b073787 eaf92b073787 f16f3ae5a5b1 f16f3ae5a5b1 eaf92b073787 eaf92b073787 eaf92b073787 eaf92b073787 eaf92b073787 eaf92b073787 eaf92b073787 eaf92b073787 eaf92b073787 b03c40a64562 b03c40a64562 b03c40a64562 3012fc249929 3012fc249929 3012fc249929 b03c40a64562 3012fc249929 3012fc249929 3012fc249929 3012fc249929 3012fc249929 3012fc249929 3012fc249929 3012fc249929 3012fc249929 3012fc249929 3012fc249929 3012fc249929 3012fc249929 3012fc249929 3012fc249929 3012fc249929 3012fc249929 3012fc249929 3012fc249929 3012fc249929 3012fc249929 3012fc249929 3012fc249929 3012fc249929 3012fc249929 3012fc249929 3012fc249929 3012fc249929 3012fc249929 3012fc249929 3012fc249929 3012fc249929 3012fc249929 3012fc249929 3012fc249929 3012fc249929 3012fc249929 3012fc249929 3012fc249929 3012fc249929 3012fc249929 b03c40a64562 3012fc249929 3012fc249929 3012fc249929 3012fc249929 3012fc249929 3012fc249929 b03c40a64562 3012fc249929 3012fc249929 3012fc249929 3012fc249929 3012fc249929 3012fc249929 3012fc249929 3012fc249929 3012fc249929 3012fc249929 3012fc249929 3012fc249929 3012fc249929 3012fc249929 3012fc249929 3012fc249929 3012fc249929 3012fc249929 3012fc249929 3012fc249929 3012fc249929 3012fc249929 3012fc249929 3012fc249929 3012fc249929 3012fc249929 3012fc249929 3012fc249929 3012fc249929 b03c40a64562 3012fc249929 3012fc249929 3012fc249929 3012fc249929 3012fc249929 3012fc249929 3012fc249929 3012fc249929 3012fc249929 b03c40a64562 77aa01170934 | --[[
Общие утилиты для игр на Instead. Скорее всего будут повторно использоваться в следующих играх, если таковые будут.
]]
--[[
]]
ArrayUtils = {
indexOf = function(array, item)
for i = 1, #array do
if (array[i] == item) then
return i;
end;
end;
return 0;
end;
};
--[[
]]
PartyUtils = {
addToParty = function(object)
if (object.home) then
if (ArrayUtils.indexOf(pl.party, object.nam) == 0) then
move(object, object.home);
table.insert(pl.party, object.nam);
end;
end;
end;
};
--[[
functions, design to simplify some typical actions while developing Instead game
]]
EngineUtils = {
getStringValue = function(source, param)
local value = "";
if (type(source) == "function") then
value = source(param);
else
value = source;
end;
return value;
end;
getValue = function(source, param)
local value = nil;
if (type(source) == "function") then
value = source(param);
else
value = source;
end;
return value;
end;
};
--[[
internal space
]]
_kh = {
vroom_enter = function(s)
local v = EngineUtils.getValue(s.where);
if (v) then
walk(v);
else
return false;
end;
end;
vroom_save = function(s)
if need then
local t = stead.string.format("%s = kh_vroom(%s, %q, %s);\n",
name, stead.tostring(self.disp),
stead.deref(self.where), stead.deref(self.nam));
h:write(t);
end
stead.savemembers(h, self, name,false);
end;
};
function kh_vobj(nam, dsc, act, used)
return obj {
nam = nam;
dsc = dsc;
act = act;
used = used;
};
end;
function kh_vway(disp, dsc, target, seen_level)
local temp = vway(disp, dsc, target);
temp.seen_level = seen_level;
return temp;
end;
--[[
vroom with additional functionality
]]
function kh_vroom(disp, target, nam, seen_level)
if (type(nam) == "number") then
seen_level = nam;
nam = disp;
end;
if (not nam) then
nam = disp;
end;
return room {
nam = nam;
disp = disp;
where = target;
enter = _kh.vroom_enter;
seen_level = seen_level;
--enter = _kh.vroom_enter;
--save = _kh.vroom_save;
};
end;
--[[room = inherit(room, function(v)
v.forcedsc = true;
return v;
end);]]
dlg = inherit(dlg, function(v)
v.hideinv = true;
return v;
end);
obj = inherit(obj, function(v)
v.disable_implicit = hook(v.disable, function(f, s, ...)
s._disabled_implicit = true;
return f(s, unpack(arg));
end);
v.disable = hook(v.disable, function(f, s, ...)
s._disabled_explicit = true;
return f(s, unpack(arg));
end);
v.enable_implicit = hook(v.enable, function(f, s, ...)
s._disabled_implicit = false;
if (s._disabled_explicit) then
return s; --mimic original enable() behavior
else
return f(s, unpack(arg));
end;
end);
v.enable = hook(v.enable, function(f, s, ...)
s._disabled_explicit = false;
if (s._disabled_implicit) then
return s; --mimic original enable() behavior
else
return f(s, unpack(arg));
end;
end);
return v;
end);
--[[
character object
represents character, with whom you can interact
]]
function npc(tab)
if (not tab.act) then
tab.act = function(s)
if (s.dlg) then
walkin(s.dlg);
else
return s.phrases[rnd(#s.phrases)];
end;
end;
end;
return obj(tab);
end;
function darkroom(tab)
local life;
local entered;
local left;
if (not tab.has_light) then
tab.has_light = false;
end;
if (tab.life) then
life = tab.life;
end;
if (tab.entered) then
entered = tab.entered;
end;
if (tab.left) then
left = tab.left;
end;
tab.entered = function(s)
lifeon(s);
if (entered) then
entered(s);
end;
end;
tab.left = function(s)
lifeoff(s);
if (left) then
left(s);
end;
end;
tab.life = function(s)
local hasLight = EngineUtils.getValue(s.has_light, s);
local plLight = EngineUtils.getValue(pl.has_light, pl);
if (hasLight) then
-- show all objects that were not explicitly disabled(any seen_level)
for i = 1, #objs(s) do
objs(s)[i]:enable_implicit();
end;
for i = 1, #ways(s) do
ways(s)[i]:enable_implicit();
end;
elseif (plLight) then
-- show all objects that were not explicitly disabled and marked as seen in halflight (seen_level = 1 or higher)
for i = 1, #objs(s) do
if (type(objs(s)[i].seen_level) == "number" and objs(s)[i].seen_level >= 1) then
objs(s)[i]:enable_implicit();
else
objs(s)[i]:disable_implicit();
end;
end;
for i = 1, #ways(s) do
if (type(ways(s)[i].seen_level) == "number" and ways(s)[i].seen_level >= 1) then
ways(s)[i]:enable_implicit();
else
ways(s)[i]:disable_implicit();
end;
end;
else
-- show all objects that were not explicitly disabled and marked as seen in darkness (seen_level = 2 or higher)
for i = 1, #objs(s) do
if (type(objs(s)[i].seen_level) == "number" and objs(s)[i].seen_level >= 2) then
objs(s)[i]:enable_implicit();
else
objs(s)[i]:disable_implicit();
end;
end;
for i = 1, #ways(s) do
if (type(ways(s)[i].seen_level) == "number" and ways(s)[i].seen_level >= 2) then
ways(s)[i]:enable_implicit();
else
ways(s)[i]:disable_implicit();
end;
end;
end;
if (life) then
life(s);
end;
end;
if (not tab.dsc) then
tab.dsc = function(s)
local lt;
local hasLight = EngineUtils.getValue(s.has_light, s);
local plLight = EngineUtils.getValue(pl.has_light, pl);
if (hasLight) then
lt = EngineUtils.getValue(s.dsc_lit);
elseif (plLight) then
lt = EngineUtils.getValue(s.dsc_halflit);
else
lt = EngineUtils.getValue(s.dsc_dark);
end;
return lt;
end;
end;
return room(tab);
end;
function game_over(nam, dsc)
return room {
nam = nam;
disp = "Игра окончена";
hideinv = true;
dsc = dsc;
};
end;
function cutscene(nam, disp, dsc, nxt, entered)
return room {
nam = nam;
disp = disp;
entered = entered;
hideinv = true;
cutscene = true;
dsc = dsc;
obj = {
vway("continue", "{Продолжить}", nxt);
};
};
end;
--[[
Создает комнату с полем для ввода числа длиной не более tab.maxlen
По нажатии enter вызывает метод tab.сheck
Приглашение для ввода: tab.label
Вводимый текст: tab.input
]]
function input_number(tab)
if (not tab.maxlen) then
tab.maxlen = 2;
end;
tab.forcedsc = true;
tab.noinv = true;
tab.input = "";
tab.dsc = function(s)
pr(tab.label .. tab.input .. "_");
return false;
--return tab.label .. tab.input .. "_";
end;
tab.entered = function(s)
s.input = "";
hook_keys('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'backspace', 'return', 'escape');
end;
tab.left = function(s)
unhook_keys('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'backspace', 'return', 'escape');
end;
tab.kbd = function(s, down, key)
if (not down) then
if (key == "escape") then
back();
elseif (key == "return") then
if (s.input) then
s:check(s.input);
end;
elseif (key == "backspace") then
if (s.input:len() > 0) then
s.input = s.input:sub(1, s.input:len() - 1);
end;
else
if (string.len(s.input) < s.maxlen) then
s.input = s.input .. key;
-- hide buttons :)
end;
end;
end;
pr("");
end;
tab.obj = {
"_kh_input1",
"_kh_input2",
"_kh_input3",
"_kh_input4",
"_kh_input5",
"_kh_input6",
"_kh_input7",
"_kh_input8",
"_kh_input9",
"_kh_input0",
"_kh_backspace",
"_kh_cancel",
"_kh_enter"
};
return room(tab);
end;
function input_number_nav(tab)
if (not tab.maxlen) then
tab.maxlen = 2;
end;
tab.forcedsc = true;
tab.noinv = true;
tab.input = "";
tab.dsc = function(s)
pr(tab.label .. tab.input .. "_");
return false;
--return tab.label .. tab.input .. "_";
end;
tab.entered = function(s)
s.input = "";
hook_keys('0', '1', '2', '3', '4', '5', 'backspace', 'return', 'escape');
end;
tab.left = function(s)
unhook_keys('0', '1', '2', '3', '4', '5', 'backspace', 'return', 'escape');
end;
tab.kbd = function(s, down, key)
if (not down) then
if (key == "escape") then
back();
elseif (key == "return") then
if (s.input) then
s:check(s.input);
end;
elseif (key == "backspace") then
if (s.input:len() > 0) then
s.input = s.input:sub(1, s.input:len() - 1);
end;
else
if (string.len(s.input) < s.maxlen) then
s.input = s.input .. key;
-- hide buttons :)
end;
end;
end;
pr("");
end;
tab.obj = {
"_kh_input1",
"_kh_input2",
"_kh_input3",
"_kh_input4",
"_kh_input5",
"_kh_input0",
"_kh_backspace",
"_kh_cancel",
"_kh_enter"
};
return room(tab);
end;
_kh_input1 = obj {
nam = "_kh_input1";
dsc = "{1}";
act = function(s)
if (here().input:len() < here().maxlen) then
here().input = here().input .. "1";
end;
return "";
end;
};
_kh_input2 = obj {
nam = "_kh_input2";
dsc = "{2}";
act = function(s)
if (here().input:len() < here().maxlen) then
here().input = here().input .. "2";
end;
return "";
end;
};
_kh_input3 = obj {
nam = "_kh_input3";
dsc = "{3}";
act = function(s)
if (here().input:len() < here().maxlen) then
here().input = here().input .. "3";
end;
return "";
end;
};
_kh_input4 = obj {
nam = "_kh_input4";
dsc = "{4}";
act = function(s)
if (here().input:len() < here().maxlen) then
here().input = here().input .. "4";
end;
return "";
end;
};
_kh_input5 = obj {
nam = "_kh_input5";
dsc = "{5}";
act = function(s)
if (here().input:len() < here().maxlen) then
here().input = here().input .. "5";
end;
return "";
end;
};
_kh_input6 = obj {
nam = "_kh_input6";
dsc = "{6}";
act = function(s)
if (here().input:len() < here().maxlen) then
here().input = here().input .. "6";
end;
return "";
end;
};
_kh_input7 = obj {
nam = "_kh_input7";
dsc = "{7}";
act = function(s)
if (here().input:len() < here().maxlen) then
here().input = here().input .. "7";
end;
return "";
end;
};
_kh_input8 = obj {
nam = "_kh_input8";
dsc = "{8}";
act = function(s)
if (here().input:len() < here().maxlen) then
here().input = here().input .. "8";
end;
return "";
end;
};
_kh_input9 = obj {
nam = "_kh_input9";
dsc = "{9}";
act = function(s)
if (here().input:len() < here().maxlen) then
here().input = here().input .. "9";
end;
return "";
end;
};
_kh_input0 = obj {
nam = "_kh_input0";
dsc = "{0}";
act = function(s)
if (here().input:len() < here().maxlen) then
here().input = here().input .. "0";
end;
return "";
end;
};
_kh_backspace = obj {
nam = "_kh_back";
dsc = "{Стереть}";
act = function(s)
if (here().input:len() > 0) then
here().input = here().input:sub(1, here().input:len() - 1);
end;
return "";
end;
};
_kh_cancel = obj {
nam = "_kh_cancel";
dsc = "{Отмена}";
act = function(s)
back();
return "";
end;
};
_kh_enter = obj {
nam = "_kh_enter";
dsc = "{Ввод}";
act = function(s)
if (here().input) then
here():check(s.input);
end;
return "";
end;
};
--[[
Создает obj, который добавляет другой obj на сцену при активации и становится неинтерактивным
nam - имя объекта
dsc_a - описание до активации
dsc_b - описание после активации
act_a - описание взаимодействия до активации
act_b - описание взаимодействия после активации
o2 - obj, добавляемый на сцену
r - удаляет объект после активации
]]
function obscured_obj(nam, dsc_a, act_a, o2, r, dsc_b, act_b)
return obj {
var {
activated = false;
};
nam = nam;
dsc = function(s)
if (s.activated) then
return dsc_b;
else
return dsc_a;
end;
end;
act = function(s)
if (s.activated) then
return act_b;
else
s.activated = true;
put(o2, here());
if (r) then
remove(r, here());
end;
return act_a;
end;
end;
};
end;
_atlantis_suit_menu = dlg {
nam = "Скафандр";
_item = nil;
dsc = [[
Что вы хотите сделать?
]];
phr = {
{1, always = "true", "Использовать рацию", function(s)
local val = EngineUtils.getValue(_atlantis.suit_menu._item.dlg, _atlantis.suit_menu._item);
if (val) then
walkin(val);
stead.ref(val).__from__ = _atlantis.suit_menu.__from__;
else
back();
return "Никто не отвечает";
end;
end};
{2, always = "true", "Снять скафандр", function(s)
if (EngineUtils.getValue(_atlantis_suit_menu._item.cantakeoff, _atlantis_suit_menu._item)) then
drop(_atlantis._uit_menu._item);
back();
return "Вы снимаете скафандр";
else
back();
return "Вы не можете снять скафандр сейчас";
end;
end};
{3, always = "true", "Отмена", function(s)
back();
return "";
end};
};
};
_atlantis = {
suit_inv = function(s)
_atlantis_suit_menu._item = s;
walkin(_atlantis_suit_menu);
end;
};
suit = function(tab)
if (not tab.inv) then
tab.inv = _atlantis.suit_inv;
end;
return obj(tab);
end;
labyrinth = function(tab)
local enter = tab.enter;
local exit = tab.exit;
local dsc = tab.dsc;
local lab;
tab.enter = function(s)
path('e1'):disable();
path('e2'):disable();
path('e3'):disable();
path('e4'):disable();
path('ex'):disable();
local e1open = s.map[s.position].e1 and not EngineUtils.getValue(s.map[s.position].e1lock, s);
local e2open = s.map[s.position].e2 and not EngineUtils.getValue(s.map[s.position].e2lock, s);
local e3open = s.map[s.position].e3 and not EngineUtils.getValue(s.map[s.position].e3lock, s);
local e4open = s.map[s.position].e4 and not EngineUtils.getValue(s.map[s.position].e4lock, s);
local exopen = s.map[s.position].ex and not EngineUtils.getValue(s.map[s.position].exlock, s);
if (e1open) then
path('e1'):enable();
end;
if (e2open) then
path('e2'):enable();
end;
if (e3open) then
path('e3'):enable();
end;
if (e4open) then
path('e4'):enable();
end;
if (exopen) then
path('ex'):enable();
end;
if (type(enter) == 'function') then
enter(s);
end;
if (type(s.map[s.position].enter) == 'function') then
s.map[s.position].enter(s);
end;
end;
tab.exit = function(s)
if (type(exit) == 'function') then
exit(s);
end;
if (type(s.map[s.position].exit) == 'function') then
s.map[s.position].exit(s);
end;
end;
tab.dsc = function(s)
if (type(dsc) == "function") then
return dsc(s);
else
return dsc .. s.map[s.position].name;
end;
end;
tab.way = {
kh_vroom(tab.dir1, function()
lab.oldposition = lab.position;
lab.position = lab.map[lab.position].e1;
return lab;
end, "e1");
kh_vroom(tab.dir2, function()
lab.oldposition = lab.position;
lab.position = lab.map[lab.position].e2;
return lab;
end, "e2");
kh_vroom(tab.dir3, function()
lab.oldposition = lab.position;
lab.position = lab.map[lab.position].e3;
return lab;
end, "e3");
kh_vroom(tab.dir4, function()
lab.oldposition = lab.position;
lab.position = lab.map[lab.position].e4;
return lab;
end, "e4");
kh_vroom(tab.ex, function()
return lab.map[lab.position].ex;
end, "ex");
kh_vroom("Ждать", function()
lab.oldposition = lab.position;
return lab;
end, "wt");
};
lab = room(tab);
print(tab);
print(lab);
if (not tab.position) then
stead.add_var(tab, { position = "00"; });
end;
stead.add_var(tab, { oldposition = tab.position; });
return lab;
end;
|