@@ -1,7 +1,7 @@
/ / 计分板模块扩展插件
/ / 忽略假人分数
/ / * * 请勿修改文件名 ! ! * *
global_app_version = ' 1.0-beta.4 ' ;
global_app_version = ' 1.0-beta.5 ' ;
__config ( ) - > {
' scope ' - > ' global ' ,
@@ -13,148 +13,174 @@ __config() -> {
' commands ' - > {
' ' - > ' help ' ,
' help ' - > ' help ' ,
' delete_old ' - > ' delete_old ' ,
' merge_old ' - > ' restore_merge_old ' ,
' delete_old <fzsd_version> ' - > ' delete_old ' ,
' update_from <fzsd_version> ' - > ' update_from ' ,
' restore_from_stats ' - > ' restore_from_stats ' ,
' recalculate_total ' - > ' recalculate_total_scores '
' recalculate_total ' - > ' recalculate_total_scores ' ,
' commandPlayer <boolean> ' - > ' command_player '
} ,
' arguments ' - > {
' boolean ' - > {
' type ' - > ' bool '
} ,
' fzsd_version ' - > {
' type ' - > ' term ' ,
' suggest ' - > [
' 2.x ' ,
' 3.0-beta.4 '
]
}
}
} ;
__on_start ( ) - > (
global_team_cache = read_file ( ' team_cache ' , ' json ' ) ;
debug ( global_team_cache ) ;
if ( global_team_cache == null , / / carpet 1.4 .69 兼容
global_team_cache = { } ;
) ;
print ( player ( ' all ' ) , ' fzsd_score.sc已加载! ' ) ;
) ;
__on_close ( ) - > (
debug ( global_team_cache ) ;
delete_file ( ' team_cache ' , ' json ' ) ;
write_file ( ' team_cache ' , ' json ' , global_team_cache ) ;
) ;
__on_player_connects ( player ) - > (
debug ( player ~ ' name ' ) ;
debug ( player ~ ' player_type ' ) ;
debug ( player ~ ' team ' ) ;
debug ( global_team_cache ) ;
if ( player ~ ' player_type ' == ' fake ' & & player ~ ' team ' != ' fz.module.scoreboard.fake ' ,
player_type = player ~ ' player_type ' ;
player_team = player ~ ' team ' ;
player_name = player ~ ' name ' ;
if ( player_type == ' fake ' & & player_team != ' fzsd.module.scoreboard.fake ' ,
(
debug ( ' 1~ ' ) ;
global_team_cache : ( player ~ ' name ' ) = player ~ ' team ' ;
debug ( global_team_cache ) ;
team_add ( ' fz.module.scoreboard.fake ' , player ) ;
global_team_cache : player_name = player_team ;
team_add ( ' fzsd.module.scoreboard.fake ' , player ) ;
) ,
player ~ ' player_type ' == ' shadow ' & & player ~ ' team ' != ' fz.module.scoreboard.shadow ' ,
player_type == ' shadow ' & & player_team != ' fzsd.module.scoreboard.shadow ' ,
(
debug ( ' 2~ ' ) ;
global_team_cache : ( player ~ ' name ' ) = player ~ ' team ' ;
team_add ( ' fz.module.scoreboard.shadow ' , player ) ;
global_team_cache : player_name = player_team ;
team_add ( ' fzsd.module.scoreboard.shadow ' , player ) ;
) ,
try_restore_team_from_cache ( player ) ;
) ;
debug ( global_team_cache ) ;
) ;
__on_player_disconnects ( player , reason ) - > (
debug ( player ~ ' name ' ) ;
debug ( player ~ ' player_type ' ) ;
debug ( player ~ ' team ' ) ;
debug ( global_team_cache ) ;
try_restore_team_from_cache ( player ) ;
) ;
try_restore_team_from_cache ( player ) - > (
player_team = player ~ ' team ' ;
player_name = player ~ ' name ' ;
debug ( ' restore_team_from_cache ' ) ;
if ( player ~ ' team ' == ' fz.module.scoreboard.fake '
| | player ~ ' team ' == ' fz.module.scoreboard.shadow ' ,
debug ( global_team_cache ) ;
if ( global_team_cache : ( player ~ ' name ' ) == null ,
if ( player_team == ' fzsd.module.scoreboard.fake '
| | player_team == ' fzsd.module.scoreboard.shadow ' ,
if ( global_team_cache : player_name == null ,
(
debug ( ' global_team_cache:(player ~ \' name \' ) == null ' ) ;
team_leave ( player ) ;
) ,
debug ( ' global_team_cache:(player ~ \' name \' ) != null ' ) ;
team_add ( global_team_cache : ( player ~ ' name ' ) , player ) ;
delete ( global_team_cache : ( player ~ ' name ' ) ) ;
team_add ( global_team_cache : player_name , player ) ;
delete ( global_team_cache : player_name ) ;
) ;
) ;
) ;
help ( ) - > (
print ( ' 这是一条帮助 ' ) ;
print ( ' 暂未开发 ' ) ;
return ( 0 ) ;
) ;
delete_old ( ) - > (
old_scoreboards = [
' usedDiaAxe ' , ' usedDiaPickaxe ' , ' usedDiaShovel ' , ' usedDiaHoe ' , ' usedIroAxe ' , ' usedIroPickaxe ' ,
' usedIroShovel ' , ' usedIroHoe ' , ' usedStoAxe ' , ' usedStoPickaxe ' , ' usedStoShovel ' , ' usedStoHoe ' ,
' usedWooAxe ' , ' usedWooPickaxe ' , ' usedWooShovel ' , ' usedWooHoe ' , ' usedGolAxe ' , ' usedGolPickaxe ' ,
' usedGolShovel ' , ' usedGolHoe ' , ' usedNetAxe ' , ' usedNetPickaxe ' , ' usedNetShovel ' , ' usedNetHoe ' ,
' usedShears ' , ' damageTaken ' , ' 10xDamageTaken ' , ' deathCounter ' , ' deathTester ' , ' digCounter ' ,
' fishingCounter ' , ' fishingTester ' , ' killCounter ' , ' tradingCounter ' , ' totalList ' ,
' bedrockBreaked ' , ' fz.bbl ' , ' fz.aviate1m ' , ' fz.aviateCounter ' , ' fz.aviateOneTime ' , ' Health ' ,
' carpetBot ' , ' parameter '
] ;
delete_old ( fzsd_version ) - > (
old_scoreboards = [ ] ;
if ( fzsd_version == ' 2.x ' ,
(
old_scoreboards = [ ' usedDiaAxe ' , ' usedDiaPickaxe ' , ' usedDiaShovel ' , ' usedDiaHoe ' , ' usedIroAxe ' , ' usedIroPickaxe ' , ' usedIroShovel ' , ' usedIroHoe ' , ' usedStoAxe ' , ' usedStoPickaxe ' , ' usedStoShovel ' , ' usedStoHoe ' , ' usedWooAxe ' , ' usedWooPickaxe ' , ' usedWooShovel ' , ' usedWooHoe ' , ' usedGolAxe ' , ' usedGolPickaxe ' , ' usedGolShovel ' , ' usedGolHoe ' , ' usedNetAxe ' , ' usedNetPickaxe ' , ' usedNetShovel ' , ' usedNetHoe ' , ' usedShears ' , ' damageTaken ' , ' 10xDamageTaken ' , ' deathCounter ' , ' deathTester ' , ' digCounter ' , ' fishingCounter ' , ' fishingTester ' , ' killCounter ' , ' tradingCounter ' , ' totalList ' , ' bedrockBreaked ' , ' fz.bbl ' , ' fz.aviate1m ' , ' fz.aviateCounter ' , ' fz.aviateOneTime ' , ' Health ' , ' carpetBot ' , ' parameter ' ] ;
team_remove ( ' carpetBot ' ) ;
team_remove ( ' shadowedPlayer ' ) ;
) ,
fzsd_version == ' 3.0-beta.4 ' ,
(
old_scoreboards = [ ' fz.module.scoreboard.display.activation ' , ' fz.module.scoreboard.display.damage_taken ' , ' fz.module.scoreboard.display.death_count ' , ' fz.module.scoreboard.display.dig_count ' , ' fz.module.scoreboard.display.fishing_count ' , ' fz.module.scoreboard.display.kill_count ' , ' fz.module.scoreboard.display.trade_count ' , ' fz.module.scoreboard.display.bedrock_broke_count ' , ' fz.module.scoreboard.display.aviating_distance ' , ' fz.module.scoreboard.display.placement_count ' , ' fz.module.scoreboard.assign.general ' , ' fz.module.scoreboard.display.general ' , ' fz.module.scoreboard.interactor ' ] ;
team_remove ( ' fz.module.scoreboard.fake ' ) ;
team_remove ( ' fz.module.scoreboard.shadow ' ) ;
)
) ;
for ( old_scoreboards , scoreboard_remove ( _ ) ) ;
team_remove ( ' carpetBot ' ) ;
team_remove ( ' shadowedPlayer ' ) ;
print ( ' 已清除旧版计分板! ' ) ;
return ( 0 ) ;
) ;
restore_merge_old ( ) - > (
merge_score ( ' activation ' , ' fz.module.scoreboard.display.activation ' ) ;
merge_score ( ' damageTaken ' , ' fz.module.scoreboard.display.damage_taken ' ) ;
merge_score ( ' deathCounter ' , ' fz.module.scoreboard.display.death_count ' ) ;
merge_score ( ' digCounter ' , ' fz.module.scoreboard.display.dig_count ' ) ;
merge_score ( ' fishingCounter ' , ' fz.module.scoreboard.display.fishing_count ' ) ;
merge_score ( ' killCounter ' , ' fz.module.scoreboard.display.kill_count ' ) ;
merge_score ( ' tradingCounter ' , ' fz.module.scoreboard.display.trade_count ' ) ;
merge_score ( ' bedrockBreaked ' , ' fz.module.scoreboard.display.bedrock_broke_count ' ) ;
merge_score ( ' fz.aviate1m ' , ' fz.module.scoreboard.display.aviating_distance ' ) ;
/ / restore_score ( ' fz.module.scoreboard.display.placement_count ' , ) ;
update_from ( fzsd_version ) - > (
params = [ ] ;
if ( fzsd_version == ' 2.x ' ,
(
params = [
[ ' activation ' , ' fzsd.module.scoreboard.display.activation ' ] ,
[ ' damageTaken ' , ' fzsd.module.scoreboard.display.damage_taken ' ] ,
[ ' deathCounter ' , ' fzsd.module.scoreboard.display.death_count ' ] ,
[ ' digCounter ' , ' fzsd.module.scoreboard.display.dig_count ' ] ,
[ ' fishingCounter ' , ' fzsd.module.scoreboard.display.fishing_count ' ] ,
[ ' killCounter ' , ' fzsd.module.scoreboard.display.kill_count ' ] ,
[ ' tradingCounter ' , ' fzsd.module.scoreboard.display.trade_count ' ] ,
[ ' bedrockBreaked ' , ' fzsd.module.scoreboard.display.bedrock_broke_count ' ] ,
[ ' fz.aviate1m ' , ' fzsd.module.scoreboard.display.aviating_distance ' ]
]
) ,
fzsd_version == ' 3.0-beta.4 ' ,
(
params = [
[ ' fz.module.scoreboard.display.activation ' , ' fzsd.module.scoreboard.display.activation ' ] ,
[ ' fz.module.scoreboard.display.damage_taken ' , ' fzsd.module.scoreboard.display.damage_taken ' ] ,
[ ' fz.module.scoreboard.display.death_count ' , ' fzsd.module.scoreboard.display.death_count ' ] ,
[ ' fz.module.scoreboard.display.dig_count ' , ' fzsd.module.scoreboard.display.dig_count ' ] ,
[ ' fz.module.scoreboard.display.fishing_count ' , ' fzsd.module.scoreboard.display.fishing_count ' ] ,
[ ' fz.module.scoreboard.display.kill_count ' , ' fzsd.module.scoreboard.display.kill_count ' ] ,
[ ' fz.module.scoreboard.display.trade_count ' , ' fzsd.module.scoreboard.display.trade_count ' ] ,
[ ' fz.module.scoreboard.display.bedrock_broke_count ' , ' fzsd.module.scoreboard.display.bedrock_broke_count ' ] ,
[ ' fz.module.scoreboard.display.aviating_distance ' , ' fzsd.module.scoreboard.display.aviating_distance ' ] ,
[ ' fz.module.scoreboard.display.placement_count ' , ' fzsd.module.scoreboard.display.placement_count ' ]
]
)
) ;
for ( params , merge_score ( . . . _ , fzsd_version ) ) ;
/ / 清除旧计分板
delete_old ( ) ;
delete_old ( fzsd_version ) ;
print ( ' 完成! ' ) ;
return ( 0 ) ;
) ;
merge_score ( from , to ) - > (
merge_score ( from , to , fzsd_version ) - > (
/ / 如果目标计分板不存在则创建
if ( scoreboard ( ) ~ to == null , scoreboard_add ( to ) ) ;
/ / 旧版数据包的假人列表
fake_players = team_list ( ' carpetBot ' ) ;
if ( fzsd_version == ' 2.x ' ,
(
/ / 2. x数据包的假人列表
fake_players = team_list ( ' carpetBot ' ) ;
/ / 新数据包的计分板中存储的玩家列表
new_players = scoreboard ( ' fzsd.module.interactor.trigger ' ) ;
for ( fake_players , delete ( new_players , _ ) ) ;
) ,
fzsd_version == ' 3.0-beta.4 ' ,
(
new_players = scoreboard ( ' fz.module.interactor.trigger ' ) ;
)
) ;
/ / 新数据包的计分板中存储的玩家列表
new_players = scoreboard ( ' fz.module.interactor.trigger ' ) ;
debug ( ' 2 ' + new_players ) ;
for ( scoreboard ( from ) ,
debug ( ' 3 ' + _ ) ;
debug ( ' 3.1 ' + contains ( fake_players , _ ) ) ;
debug ( ' 3.2 ' + contains ( new_players , _ ) ) ;
debug ( ' 3.3 ' + str ( _ != total_name_old ) ) ;
debug ( ' 3.4 ' + str ( ( ! contains ( fake_players , _ )
| | contains ( new_players , _ )
) & & ! ( _ ~ ' \\ W ' ) ) ) ;
if ( ( ! contains ( fake_players , _ )
| | contains ( new_players , _ )
) & & ! ( _ ~ ' \\ W ' ) ,
debug ( ' 4 ' + _ ) ;
debug ( ' from ' + scoreboard ( from , _ ) ) ;
debug ( ' to ' + scoreboard ( to , _ ) ) ;
if ( contains ( new_players , _ ) & & ! ( _ ~ ' \\ W ' ) ,
scoreboard ( to , _ , scoreboard ( to , _ ) + scoreboard ( from , _ ) ) ;
) ;
) ;
print ( ' 已合并: ' + to ) ;
/ / 重新计算总分
recalculate_total_score ( to , get_total_score_name_new ( to ) ) ;
print ( ' 已合并: ' + to ) ;
return ( 0 ) ;
) ;
@@ -167,10 +193,10 @@ get_total_score_name_new(scoreboard) -> (
/ / 将系统总榜分数加上最小int值 , 使其成为最低分
scoreboard (
' fz.module.scoreboard.assign.general ' ,
' fzsd.module.scoreboard.assign.general ' ,
system_total_name ,
scoreboard (
' fz.module.scoreboard.assign.general ' ,
' fzsd.module.scoreboard.assign.general ' ,
system_total_name
) + INT_MIN
) ;
@@ -189,15 +215,14 @@ get_total_score_name_new(scoreboard) -> (
last_min_player = _ ;
)
) ;
debug ( _ ) ;
) ;
/ / 恢复总榜分数
scoreboard (
' fz.module.scoreboard.assign.general ' ,
' fzsd.module.scoreboard.assign.general ' ,
system_total_name ,
scoreboard (
' fz.module.scoreboard.assign.general ' ,
' fzsd.module.scoreboard.assign.general ' ,
system_total_name
) - INT_MIN
) ;
@@ -209,15 +234,15 @@ get_total_score_name_new(scoreboard) -> (
recalculate_total_scores ( ) - > (
scoreboards = [
' fz.module.scoreboard.display.activation ' ,
' fz.module.scoreboard.display.damage_taken ' ,
' fz.module.scoreboard.display.death_count ' ,
' fz.module.scoreboard.display.dig_count ' ,
' fz.module.scoreboard.display.fishing_count ' ,
' fz.module.scoreboard.display.kill_count ' ,
' fz.module.scoreboard.display.trade_count ' ,
' fz.module.scoreboard.display.bedrock_broke_count ' ,
' fz.module.scoreboard.display.aviating_distance '
' fzsd.module.scoreboard.display.activation ' ,
' fzsd.module.scoreboard.display.damage_taken ' ,
' fzsd.module.scoreboard.display.death_count ' ,
' fzsd.module.scoreboard.display.dig_count ' ,
' fzsd.module.scoreboard.display.fishing_count ' ,
' fzsd.module.scoreboard.display.kill_count ' ,
' fzsd.module.scoreboard.display.trade_count ' ,
' fzsd.module.scoreboard.display.bedrock_broke_count ' ,
' fzsd.module.scoreboard.display.aviating_distance '
] ;
for ( scoreboards , recalculate_total_score ( _ , get_total_score_name_new ( _ ) ) ) ;
print ( ' 完成! ' ) ;
@@ -234,7 +259,7 @@ recalculate_total_score(scoreboard, total_score_name_new) -> (
) ;
/ / 赋值总分到系统总分计分板
scoreboard (
' fz.module.scoreboard.assign.general ' ,
' fzsd.module.scoreboard.assign.general ' ,
replace ( scoreboard , ' display ' , ' total ' ) ,
total_score
) ;
@@ -248,12 +273,11 @@ display_total_score(scoreboard) -> (
str_1 = split ( ' \\ . ' , scoreboard ) ;
function_name = str_1 : ( length ( str_1 ) - 1 ) ;
/ / 运行函数 , 将分数赋值到显示计分板上
run ( ' function #fz:module/scoreboard/assign/scoreboard/general/ ' + function_name ) ;
run ( ' function #fzsd :module/scoreboard/assign/scoreboard/general/ ' + function_name ) ;
return ( 0 ) ;
) ;
restore_from_stats ( ) - > (
print ( ' 暂未开发 ' ) ;
return ( 0 ) ;
) ;
@@ -263,6 +287,12 @@ merge_stat(scoreboard, ...stats) -> (
return ( 0 ) ;
) ;
command_player ( boolean ) - > (
print ( run ( ' carpet setDefault commandPlayer ' + str ( boolean ) ) : 1 : 0 ) ;
) ;
/ / 工具函数
contains ( list , value ) - > (
return ( list ~ value != null ) ;
) ;