123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687 |
- function stage.increase(player) {
- $stage++;
- quest.display(player, $quest_name, $stage, $all_stages);
- sound = sound.get("entity.experience_orb.pickup");
- category = sound.getCategory("master");
- sound.spawnForPlayer(player, sound, category);
- }
- function quest.start(player, path) {
- modTimer(-5);
- script = script.start(path, "utils/u_quest", "utils/u_general");
- if(script == null) {
- msg("dev", "quest not started");
- return;
- }
- quest.addPlayer(script, player);
- script.setVar(script, "player", player);
- script.setVar(script, "script", script);
- script.callEvent("quest_start", script);
- inv.close(player);
- }
- function player.getShipProgress(player_or_id) {
- config = playerdata.getStory(player_or_id);
- return config.getDouble(config, "ship.progress", 0);
- }
- function player.setShipProgress(player_or_id, progress) {
- config = playerdata.getStory(player_or_id);
- old_progress = config.getDouble(config, "ship.progress", 0);
- if(progress > old_progress) {
- config.set(config, "ship.progress", progress);
- config.saveAsync(config);
- }
- }
- function human.giveItem(human_name, player, needed_type_or_tag, needed_amount) {
- if(needed_amount == 0) {
- return -1;
- }
- item = living.getEquip(player, "hand");
- item_type = item.getType(item);
- if(item_type == "minecraft:air") {
- return needed_amount;
- }
- human_name = concat("§d", human_name);
- needed = false;
- tag_check = false;
- if(text.class(needed_type_or_tag) == "String") {
- if(item_type == needed_type_or_tag) {
- needed = true;
- }
- } else {
- if(item.hasTag(needed_type_or_tag, item)) {
- needed = true;
- tag_check = true;
- }
- }
- if(needed) {
- rest_item = player.removeItem(player, read.item(item_type, needed_amount));
- rest_item_amount = item.getAmount(rest_item);
- if(rest_item_amount > 0) {
- rest_item = player.removeItemNbt(player, rest_item);
- rest_item_amount = item.getAmount(rest_item);
- if(rest_item_amount > 0) {
- if(tag_check) {
- rest_item = player.removeItemTag(player, needed_type_or_tag, rest_item_amount);
- rest_item_amount = item.getAmount(rest_item);
- if(rest_item_amount > 0) {
- msg.prefix(player, human_name, concat("Ich brauche bitte noch ", text.number(rest_item_amount), " Stück davon."));
- }
- } else {
- msg.prefix(player, human_name, concat("Ich brauche bitte noch ", text.number(rest_item_amount), " Stück davon."));
- }
- }
- }
- return rest_item_amount;
- }
- msg.prefix(player, human_name, "Das kann ich nicht gebrauchen.");
- return needed_amount;
- }
- function quest.callShowShop(player, shop_type) {
- setScriptVar("player", player);
- setScriptVar("shop_type", shop_type);
- script.callEvent("skill_showshop");
- }
|