日本免费全黄少妇一区二区三区-高清无码一区二区三区四区-欧美中文字幕日韩在线观看-国产福利诱惑在线网站-国产中文字幕一区在线-亚洲欧美精品日韩一区-久久国产精品国产精品国产-国产精久久久久久一区二区三区-欧美亚洲国产精品久久久久

我的世界1.12版函數(shù)命令系統(tǒng)教學(xué)詳解 函數(shù)命令系統(tǒng)教程( 六 )


scoreboard players tag @s[tag=!HelloTitle] add HelloTitle
scoreboard players reset @s[score_helloTitle_min=1] helloTitle
這個(gè)進(jìn)度會(huì)在下一個(gè)游戲刻達(dá)成,對(duì)象是全體在線玩家,達(dá)成進(jìn)度后會(huì)執(zhí)行HelloTitle.mcfunction中的指令 。其實(shí)現(xiàn)的效果是,當(dāng)玩家進(jìn)入這個(gè)世界時(shí),會(huì)在聊天框看見問候語(其他人看不到) 。
可以看到,相比于以前命令方塊高頻,這里采用了進(jìn)度系統(tǒng)的 tick 觸發(fā)器和@s選擇器 。如果單純用命令方塊高頻或者函數(shù)系統(tǒng),那么只需要這樣
scoreboard objectives add helloTitle stat.leaveGame
scoreboard players tag @a[tag=HelloTitle,score_helloTitle_min=1] remove HelloTitle
execute @a[tag=!HelloTitle] ~ ~ ~ tellraw @s ["",{"text":"Hello ","color":"yellow"},{"selector":"@s"},{"text":"! Welcome to Minecraft!","color":"yellow"}]
scoreboard players tag @a[tag=!HelloTitle] add HelloTitle
scoreboard players reset @a[score_helloTitle_min=1] helloTitle
區(qū)別就是選擇器上的不一樣 。如果大家覺得進(jìn)度系統(tǒng)很麻煩,可以不去使用,但是接下來我們會(huì)看到一個(gè)使用進(jìn)度系統(tǒng)的其他觸發(fā)器來調(diào)用函數(shù)的例子 。例如,要讓所有冒險(xiǎn)模式玩家入水即死 。
rules:DieInWater.json
{
"criteria":{
"1":{
"trigger":"enter_block",
"condition":{
"block":"water"
}
}
},
"rewards":{
"function":"rules:dieinwater"
}
}
rules:DieInWater.mcfunction
#revoke
advancement revoke @s only rules:dieinwater
#commands
scoreboard players tag @p[m=2,r=0] add waterKill
execute @s[tag=waterKill] ~ ~ ~ tellraw @a [{"selector":"@s"},{"color":"white","text":" 被水淹沒了"}]
execute @s[tag=waterKill] ~ ~ ~ gamerule showDeathMessages false
kill @s[tag=waterKill]
execute @s[tag=waterKill] ~ ~ ~ gamerule showDeathMessages true
scoreboard players tag @s[tag=waterKill] remove waterKill
當(dāng)玩家踏入水中時(shí),我們要給玩家加上一個(gè)tag,然后殺掉他 。至于為什么用@p而不用@s呢?因?yàn)锧p不能選中死人,而@s可以,如果不想看到聊天框刷屏,就不要選擇用@s 。
以上是利用進(jìn)度系統(tǒng)的 enter_block(玩家進(jìn)入方塊) 這一觸發(fā)器來實(shí)現(xiàn)落水即死功能的,如果單純依靠函數(shù),不依靠進(jìn)度系統(tǒng)去實(shí)現(xiàn)的話,可以這樣寫
rules:DieInWater_FUNCONLY.mcfunction
execute @a[m=2] ~ ~ ~ detect ~ ~ ~ water -1 scoreboard players tag @p[r=0] add waterKill
execute @a[tag=waterKill] ~ ~ ~ tellraw @a [{"selector":"@s"},{"color":"white","text":" 被水淹沒了"}]
execute @a[tag=waterKill] ~ ~ ~ gamerule showDeathMessages false
kill @a[tag=waterKill]
execute @a[tag=waterKill] ~ ~ ~ gamerule showDeathMessages true
scoreboard players tag @a[tag=waterKill] remove waterKill
然后將這個(gè)函數(shù)扔進(jìn)主進(jìn)程中高頻執(zhí)行即可 。
我們講完了函數(shù)系統(tǒng)與進(jìn)度系統(tǒng)的聯(lián)動(dòng)部分 。道理而言已經(jīng)講完了函數(shù)系統(tǒng)的基礎(chǔ)使用,那么在最后,我們來聊聊函數(shù)系統(tǒng)與命令方塊系統(tǒng)的對(duì)比吧,看看它們各自的優(yōu)缺點(diǎn) 。

我的世界1.12版函數(shù)命令系統(tǒng)教學(xué)詳解 函數(shù)命令系統(tǒng)教程


函數(shù)系統(tǒng)與命令方塊的對(duì)比
如果你看上面的看得有點(diǎn)迷糊,那我們來簡(jiǎn)單講講函數(shù)系統(tǒng)和命令方塊(CB)系統(tǒng)的對(duì)比吧,進(jìn)度作為函數(shù)的聯(lián)動(dòng)觸發(fā)形式,就不作過多講解了 。
前面講到的三種模塊中,對(duì)執(zhí)行順序無要求的高頻模塊無論是用函數(shù)還是CB都沒有什么問題,而那些需要嚴(yán)格保證執(zhí)行順序的模塊,以前我會(huì)將他們?nèi)窟B在一起,只用一個(gè) RCB(循環(huán)型命令方塊,即高頻CB源)作為“信號(hào)源” 。

推薦閱讀