u_quest.txt 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. function stage.increase(player) {
  2. $stage++;
  3. quest.display(player, $quest_name, $stage, $all_stages);
  4. sound = sound.get("entity.experience_orb.pickup");
  5. category = sound.getCategory("master");
  6. sound.spawnForPlayer(player, sound, category);
  7. }
  8. function quest.start(player, path) {
  9. modTimer(-5);
  10. script = script.start(path, "utils/u_quest", "utils/u_general");
  11. if(script == null) {
  12. msg("dev", "quest not started");
  13. return;
  14. }
  15. quest.addPlayer(script, player);
  16. script.setVar(script, "player", player);
  17. script.setVar(script, "script", script);
  18. script.callEvent("quest_start", script);
  19. inv.close(player);
  20. }
  21. function player.getShipProgress(player_or_id) {
  22. config = playerdata.getStory(player_or_id);
  23. return config.getDouble(config, "ship.progress", 0);
  24. }
  25. function player.setShipProgress(player_or_id, progress) {
  26. config = playerdata.getStory(player_or_id);
  27. old_progress = config.getDouble(config, "ship.progress", 0);
  28. if(progress > old_progress) {
  29. config.set(config, "ship.progress", progress);
  30. config.saveAsync(config);
  31. }
  32. }
  33. function human.giveItem(human_name, player, needed_type_or_tag, needed_amount) {
  34. if(needed_amount == 0) {
  35. return -1;
  36. }
  37. item = living.getEquip(player, "hand");
  38. item_type = item.getType(item);
  39. if(item_type == "minecraft:air") {
  40. return needed_amount;
  41. }
  42. human_name = concat("§d", human_name);
  43. needed = false;
  44. tag_check = false;
  45. if(text.class(needed_type_or_tag) == "String") {
  46. if(item_type == needed_type_or_tag) {
  47. needed = true;
  48. }
  49. } else {
  50. if(item.hasTag(needed_type_or_tag, item)) {
  51. needed = true;
  52. tag_check = true;
  53. }
  54. }
  55. if(needed) {
  56. rest_item = player.removeItem(player, read.item(item_type, needed_amount));
  57. rest_item_amount = item.getAmount(rest_item);
  58. if(rest_item_amount > 0) {
  59. rest_item = player.removeItemNbt(player, rest_item);
  60. rest_item_amount = item.getAmount(rest_item);
  61. if(rest_item_amount > 0) {
  62. if(tag_check) {
  63. rest_item = player.removeItemTag(player, needed_type_or_tag, rest_item_amount);
  64. rest_item_amount = item.getAmount(rest_item);
  65. if(rest_item_amount > 0) {
  66. msg.prefix(player, human_name, concat("Ich brauche bitte noch ", text.number(rest_item_amount), " Stück davon."));
  67. }
  68. } else {
  69. msg.prefix(player, human_name, concat("Ich brauche bitte noch ", text.number(rest_item_amount), " Stück davon."));
  70. }
  71. }
  72. }
  73. return rest_item_amount;
  74. }
  75. msg.prefix(player, human_name, "Das kann ich nicht gebrauchen.");
  76. return needed_amount;
  77. }
  78. function quest.callShowShop(player, shop_type) {
  79. setScriptVar("player", player);
  80. setScriptVar("shop_type", shop_type);
  81. script.callEvent("skill_showshop");
  82. }