test2.txt 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. event.load("projectile_hit");
  2. event.load("block_break");
  3. event.load("block_spread");
  4. event.load("block_fade");
  5. event.load("block_burn");
  6. fire_locs = list.new();
  7. msg("dev", text.new("Fire simulator started"));
  8. @wait
  9. wait();
  10. if(event == "block_fade") {
  11. block_loc = block.getLocation(block);
  12. list.remove(fire_locs, block_loc);
  13. }
  14. if(event == "block_spread") {
  15. block_loc = block.getLocation(block);
  16. list.add(fire_locs, block_loc);
  17. }
  18. if(event == "block_break") {
  19. block_loc = block.getLocation(block);
  20. list.remove(fire_locs, block_loc);
  21. }
  22. if(event == "projectile_hit") {
  23. block_loc = block.getLocation(block_hit);
  24. list.remove(fire_locs, block_loc);
  25. sgoto(20, "checkFireLocs");
  26. }
  27. if(event == "block_burn") {
  28. sgoto(20, "checkFireLocs");
  29. }
  30. x = list.getSize(fire_locs);
  31. msg("dev", text.new(string.concat(event, ": ", x, " fires left")));
  32. goto("wait");
  33. @checkFireLocs
  34. checkFireLocs();
  35. goto("wait");
  36. function checkFireLocs() {
  37. toRemove = getExtFireLocs();
  38. removeExtFireLocs(toRemove);
  39. x = list.getSize($fire_locs);
  40. msg("dev", text.new(string.concat("checkFireLocs: ", x, " fires left")));
  41. }
  42. function getExtFireLocs() {
  43. toRemove = list.new();
  44. iter = iterator($fire_locs);
  45. while(hasNext(iter)) {
  46. loc = next(iter);
  47. if(block.getType(block.get(loc)) != material.get("FIRE")) {
  48. list.add(toRemove, loc);
  49. }
  50. }
  51. return toRemove;
  52. }
  53. function removeExtFireLocs(toRemove) {
  54. iter = iterator(toRemove);
  55. while(hasNext(iter)) {
  56. loc = next(iter);
  57. list.remove($fire_locs, loc);
  58. }
  59. }