更新啦!
This commit is contained in:
commit
bcee791238
@ -24,6 +24,7 @@
|
||||
|
||||
- 添加`census`地毯脚本
|
||||
- `census`脚本**不稳定**,请谨慎使用,本版本无release
|
||||
- 在 readme 里添加了一些badge
|
||||
|
||||
### v2.1.2 & 2.0.10
|
||||
|
||||
|
20
README.md
20
README.md
@ -2,6 +2,9 @@
|
||||
|
||||
A Minecraft Datapack
|
||||
|
||||
[](https://minecraft.net/)
|
||||
[](https://fabricmc.net/)
|
||||
|
||||
#### @Author: Harvey_Husky
|
||||
|
||||
#### This project is licensed under the terms of the GNU General Public License v3.0
|
||||
@ -10,8 +13,21 @@ A Minecraft Datapack
|
||||
|
||||
[B站链接](https://www.bilibili.com/read/cv4267319)
|
||||
|
||||
## 说明太长不想看·直接安装教程
|
||||
|
||||
- 1.前往 [发行页面](https://gitee.com/harvey-husky/FZ-sDatapack/releases) 下载此数据包
|
||||
- 2.从zip文件中提取出几个`.sc`文件
|
||||
- 3.在`world`文件夹中创建`datapacks`和`scripts`两个文件夹
|
||||
- 4.将主体`zip`文件放入 `world/datapacks` 中(在客户端位于 `.minecraft/saves/<存档名>/datapacks`)
|
||||
- 5.将提取出来的`.sc`文件放到 `world/scripts` 中(在客户端位于 `.minecraft/saves/<存档名>/scripts`)
|
||||
- 6.在控制台输入`/reload`(客户端则是重新进入世界)
|
||||
|
||||
## 总览
|
||||
|
||||

|
||||
|
||||

|
||||
|
||||

|
||||
|
||||
- 抬头并按一下 `Shift` 来打开设置界面
|
||||
@ -69,7 +85,7 @@ A Minecraft Datapack
|
||||
|
||||
>请下载以 `FZ'sDatapack` 开头的 `.zip` 文件
|
||||
|
||||
- 将其放入 `world/datapacks` 中(在客户端位于 `.minecraft/saves/<存档名>/datapacks`)
|
||||
- **将其放入 `world/datapacks` 中(在客户端位于 `.minecraft/saves/<存档名>/datapacks`)**
|
||||
|
||||
- 载入数据包
|
||||
|
||||
@ -83,7 +99,7 @@ A Minecraft Datapack
|
||||
|
||||
## 地毯脚本
|
||||
|
||||
- 以下脚本皆在数据包(`.zip` 文件)中,请将其(`.sc` 文件)提取,并将其放入 `world/scripts` (在客户端位于 `.minecraft/saves/<存档名>/scripts`)
|
||||
- **以下脚本皆在数据包(`.zip` 文件)中,请将其(`.sc` 文件)提取,并将其放入 `world/scripts` (在客户端位于 `.minecraft/saves/<存档名>/scripts`) **
|
||||
- 可使用 `/reload` 指令或重启服务器以载入脚本(或使用 Carpet Mod 的指令 `/script load <脚本名>` 载入)
|
||||
|
||||
### `here.sc`
|
||||
|
193
census.sc
Normal file
193
census.sc
Normal file
@ -0,0 +1,193 @@
|
||||
// by shenjack
|
||||
// write at carpet 1.16.5 1.4.31 v210407
|
||||
// with carpet-extra-1.16.5-1.4.30
|
||||
// with carpet-tis-addition-mc1.16.4-1.15.0+build.492
|
||||
// with fabric-api-0.26.0+1.16 (because on server Api Version > 0.26 will cause bug)
|
||||
|
||||
global_version = '1.2.0';
|
||||
global_carpet_version = split('\\+v',system_info('scarpet_version'));
|
||||
global_require_carpet_version = ['1.4.30', 210407];
|
||||
global_filename = system_info('app_name');
|
||||
global_score_path = 'census/';
|
||||
|
||||
// debug级别
|
||||
global_debug_level = 2;
|
||||
// 0 -> show all message
|
||||
// 1 -> show most debug
|
||||
// 2 -> show all info
|
||||
// 3 -> show all warn
|
||||
// 4 -> show all error
|
||||
|
||||
global_score = {};
|
||||
global_player_name = [];
|
||||
// 分数相关初始化
|
||||
|
||||
__config() -> {
|
||||
'stay_loaded' -> true,
|
||||
'scope' -> 'global',
|
||||
// 'allow_command_conflicts' -> true,
|
||||
'legacy_command_type_support' -> true,
|
||||
'requires' -> {
|
||||
'minecraft' -> '>=1.16', // best at 1.16+ haven't test in 1.15.2 and 1.14.4
|
||||
'fabric-api' -> '>=0.26.0', // for some reason api left in 0.26.0
|
||||
'carpet' -> '>=1.4.31' // best at 1.4.31 because fix issue of read_file()
|
||||
},
|
||||
'commands' -> {
|
||||
'' -> 'help',
|
||||
'help' -> 'help',
|
||||
'reload' -> 'reload_script',
|
||||
'score load' -> 'load_scores',
|
||||
'score save' -> 'save_scores',
|
||||
'score print' -> 'print_scores',
|
||||
'debug level' -> ['debug_level', null],
|
||||
'debug level <debug_level>' -> 'debug_level',
|
||||
'debug add_mine <player> <block>' -> 'add_mine',
|
||||
},
|
||||
'arguments' -> {
|
||||
'player' -> {
|
||||
'type' -> 'players'
|
||||
},
|
||||
'block' -> {
|
||||
'type' -> 'string',
|
||||
},
|
||||
'debug_level' -> {
|
||||
'type' -> 'int',
|
||||
'min' -> 0,
|
||||
'max' -> 4,
|
||||
'suggest' -> [0, 1, 2, 3, 4]
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
__on_close() -> (
|
||||
// 保存一些debug信息
|
||||
debug_info = {'debug_level' -> global_debug_level};
|
||||
write_file('main', 'json', debug_info);
|
||||
// 保存分数
|
||||
save_scores();
|
||||
);
|
||||
|
||||
printl(message, level = 2, say = false, reply = true) -> (
|
||||
if(global_debug_level <= level,
|
||||
if(reply, print(message));
|
||||
if(say, run('say' + message)));
|
||||
);
|
||||
|
||||
debug_level(level) -> (
|
||||
if(level == null,
|
||||
print('目前DEBUG等级为: ' + global_debug_level);
|
||||
return(0));
|
||||
global_debug_level = level;
|
||||
print('DEBUG等级已经设置为: ' + global_debug_level);
|
||||
logger(type = 'info', 'DEBUG等级已经设置为: ' + global_debug_level);
|
||||
);
|
||||
|
||||
help() -> (
|
||||
print(format('y ' + '-'*10 + '帮助信息' + '-'*10));
|
||||
print(format('m 提醒:大部分信息都可以点击来执行相对应的命令,所以请小心点击', '^g 包括我! 点我来执行 /' + global_filename, '! /' + global_filename));
|
||||
print(format('e /' + global_filename + ' -> ', 'c 同 /' + global_filename + ' help'));
|
||||
print(format('e /' + global_filename + ' help -> ', 'c 显示这条帮助信息', '^g 你就在看着我呢!', '! /' + global_filename + ' help'));
|
||||
print(format('e /' + global_filename + ' reload -> ', 'c 重新加载script', '^g 获得成就:我重载我自己', '! /' + global_filename + ' reload'));
|
||||
print(format('e /' + global_filename + ' score load -> ', 'c 加载各项榜单', '^rub 警告:这会覆盖游戏内的现有数据(所以请自行输入命令)'));
|
||||
print(format('e /' + global_filename + ' score save -> ', 'c 保存各项榜单', '^ub 提醒:这会覆盖文件数据', '! /' + global_filename + ' score save'));
|
||||
print(format('e /' + global_filename + ' score print -> ', 'c 输出各项榜单数据', '^gs 吐槽一下,scarpet的字符串处理真的麻烦死了', '! /' + global_filename + ' score print'));
|
||||
print(format('e /' + global_filename + ' debug level -> ', 'c 显示DEBUG信息等级', '^g (没啥可吐槽的)', '! /' + global_filename + ' debug level'));
|
||||
print(format('e /' + global_filename + ' debug level <debug_level> -> ', 'c 设置DEBUG信息等级为<debug_level> ', '^g <debug_level> 为 0-4的正整数,默认为2', '?/' + global_filename + ' debug level '));
|
||||
// print(format('e /' + global_filename + ' xxx -> ', 'c xxx', '^g xxx', '! /' + global_filename + ' xxx'));
|
||||
print(format('y [系统信息]' + global_filename + ' 版本: ' + global_version));
|
||||
print(format('y [系统信息]' + global_filename + ' 文件名: ' + global_filename));
|
||||
print(format('y [插件信息]' + global_filename + ' 数据存储路径: ' + global_score_path));
|
||||
print(format('e 感谢 @Harvey_Husky 延皓 的支持! script中一部分源码就来自哈姥姥!', '^g 哈姥姥真好用(', '?https://gitee.com/harvey-husky/FZ-sDatapack'));
|
||||
);
|
||||
|
||||
reload_script() -> (
|
||||
print('script ' + global_filename + ' 重载中···');
|
||||
run(str('script load ' + global_filename));
|
||||
);
|
||||
|
||||
load_scores() -> (
|
||||
print('重新加载计分数据中···');
|
||||
global_score = {}; // 重置分数
|
||||
files = list_files(global_score_path, 'shared_json'); // 列出所有文件
|
||||
printl(files, 1, true, true); // DEBUG 输出
|
||||
for(files,
|
||||
data = read_file(_, 'shared_json'); // 获取文件内json
|
||||
name = split('/', _):1; // 获取文件名(玩家名称
|
||||
global_score:name = data; // 存储进计分表
|
||||
printl(data + '\n\n' + _, 1, false, true)); // DEBUG 输出
|
||||
);
|
||||
|
||||
print_scores() -> (
|
||||
// 目前只会输出挖掘榜
|
||||
printl(global_score, 0, false, true);
|
||||
print('§7' + '-'*10 + '挖掘榜' + '-'*10); // 输出标题
|
||||
mine = [];
|
||||
max_len = 1;
|
||||
// 初始化两个数据
|
||||
for(global_score,
|
||||
max_len = max(max_len, length(_));
|
||||
// 如果这个名字的长度大于之前的,就把最大长度换成这个名字的
|
||||
put(mine, 0, [_, global_score:_:'mine':'total'], 'insert'));
|
||||
// 把所有的数据加到mine里备用,等待排序
|
||||
mine = sort_key(mine, -_:1); // 根据每个挖掘数据的挖掘量进行排序(排序用的分数是挖掘量的倒数,这样可以倒序排列)
|
||||
printl(mine, 1, false, true);
|
||||
for(mine,
|
||||
print(format(' ' + _:0 + ': ' + ' '*(max_len-length(_:0))+ _:1 + ' block')));
|
||||
// 依次输出数据
|
||||
|
||||
);
|
||||
|
||||
save_scores() -> (
|
||||
print('计分数据保存中');
|
||||
for(global_score,
|
||||
write_file(global_score_path + _, 'shared_json', global_score:_);
|
||||
printl(_ + '\n' + global_score_path + _, 1, false, true));
|
||||
print('计分数据保存完毕');
|
||||
);
|
||||
|
||||
make_player_score(player) -> (
|
||||
score = {'mine'-> {'total'-> 0},
|
||||
'kill'-> {}}; // 基本信息
|
||||
put(global_score, player, score); // 加到列表里
|
||||
);
|
||||
|
||||
__on_player_dies(player) -> (
|
||||
pos = query(player, 'pos');
|
||||
dim = query(player, 'dimension');
|
||||
die_pos = str('[x: %d, y:%d, z:%d]', pos);
|
||||
if(dim == 'the_nether', dim = '地狱');
|
||||
if(dim == 'overworld', dim = '主世界');
|
||||
run(str('say ' + str(player) + '在' + dim + ' ' + die_pos + '死亡'));
|
||||
);
|
||||
|
||||
__on_player_breaks_block(player, block) -> (
|
||||
add_mine(player, block);
|
||||
);
|
||||
|
||||
add_mine(player, block) -> (
|
||||
block = str(block);
|
||||
splayer = player ~ 'name';
|
||||
if(!player(splayer),
|
||||
return());
|
||||
// 如果玩家列表里没有输入的玩家就返回
|
||||
if(!has(global_score:splayer),
|
||||
make_player_score(splayer));
|
||||
// 如果榜单里没有玩家就加入玩家的榜单
|
||||
if(!has(global_score:splayer:'mine', block),
|
||||
put(global_score:splayer:'mine':block, 1),
|
||||
// 如果玩家的记录里没有这个方块就把这个方块加到挖掘列表里
|
||||
score = get(global_score:splayer:'mine':block);
|
||||
put(global_score:splayer:'mine':block, score + 1));
|
||||
// 如果记录里有就 += 1
|
||||
full_score = get(global_score:splayer:'mine':'total');
|
||||
put(global_score:splayer:'mine':'total', full_score + 1);
|
||||
// print(global_score);
|
||||
);
|
||||
|
||||
// 加载debug信息
|
||||
debug_info = read_file('main', 'json');
|
||||
if(debug_info,
|
||||
global_debug_level = debug_info:'debug_level');
|
||||
// 基本信息初始化
|
||||
// 加载分数
|
||||
load_scores();
|
Loading…
Reference in New Issue
Block a user