u_quest.txt 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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. script = script.start(path, "utils/u_quest", "utils/u_general");
  10. if(script == null) {
  11. msg("dev", "quest not started");
  12. return;
  13. }
  14. quest.addPlayer(script, player);
  15. script.setVar(script, "player", player);
  16. script.setVar(script, "script", script);
  17. script.callEvent("quest_start", script);
  18. inv.close(player);
  19. }
  20. function player.getShipProgress(player_or_id) {
  21. config = playerdata.getStory(player_or_id);
  22. return config.getDouble(config, "ship.progress", 0);
  23. }
  24. function player.setShipProgress(player_or_id, progress) {
  25. config = playerdata.getStory(player_or_id);
  26. old_progress = config.getDouble(config, "ship.progress", 0);
  27. if(progress > old_progress) {
  28. config.set(config, "ship.progress", progress);
  29. config.saveAsync(config);
  30. }
  31. }
  32. function human.giveItem(human_name, player, needed_type, needed_amount) {
  33. item = entity.getEquip(player, "hand");
  34. item_type = item.getType(item);
  35. if(item_type == "minecraft:air") {
  36. return null;
  37. }
  38. if(item_type == needed_type) {
  39. rest_item = player.removeItem(player, read.item(item_type, needed_amount));
  40. rest_item_amount = item.getAmount(rest_item);
  41. if(rest_item_amount > 0) {
  42. msg.prefix(player, human_name, concat("Ich brauche bitte noch ", text.number(rest_item_amount), " Stück davon."));
  43. }
  44. return rest_item_amount;
  45. }
  46. msg.prefix(player, human_name, "Das kann ich nicht gebrauchen.");
  47. return null;
  48. }