The Best Resource for Minecraft
The Best Resource for Minecraft

/execute: as/at का क्रम क्यों मायने रखता है और store वास्तव में कैसे काम करता है

/execute: as/at का क्रम क्यों मायने रखता है और store वास्तव में कैसे काम करता है

ज़्यादातर टूटी हुई execute चेन्स इस भ्रम से पैदा होती हैं कि कमांड कौन चलाता है और यह कहाँ चलती है। यहाँ बताया गया है कि प्रत्येक सब-कमांड क्या बदलती है, और वह क्रम जो इसे ठीक करता है।

/execute is one command pretending to be a scripting language. Almost every failure traces to two subcommands that sound like they do the same thing and do not.

as बदलता है कौन (WHO)। at बदलता है कहाँ (WHERE)।

  • as <target> — executor को बदलता है। @s now means that entity. **The position does

हिलता नहीं है।**

  • at <target> — स्थिति, रोटेशन और आयाम को बदलता है। **executor नहीं

बदलता है।**

इसलिए यह कुछ उपयोगी नहीं करता:

execute as @e[type=zombie] run setblock ~ ~ ~ stone

यह प्रति zombie एक बार चलता है, लेकिन हमेशा आपके पैरों पर, इसलिए यह बार-बार एक ही ब्लॉक रखता है। इसका समाधान दोनों है:

execute as @e[type=zombie] at @s run setblock ~ ~ ~ stone

at @s re-anchors to the zombie that as just selected. as … at @s is the single most common pairing in the whole command, और भूल जाना at @s is the single most common bug.

क्रम बाएँ से दाएँ है, और यह संयोजित होता जाता है

सब-कमांड्स क्रम में चलती हैं, प्रत्येक उस संदर्भ को बदलती है जो अगली देखती है:

execute as @a at @s positioned ^ ^ ^3 run particle flame
  1. as @a — one pass per player
  2. at @s — move to that player
  3. positioned ^ ^ ^3 — 3 blocks in front of where they are देखना

चरण 2 और 3 को बदलें और कैरेट ऑफ़सेट उनके बजाय आपके रोटेशन से मापा जाता है।

Caret बनाम tilde

  • ~ ~ ~ — relative to स्थिति, विश्व अक्षों के साथ संरेखित
  • ^ ^ ^ — relative to दिशा: बाएँ, ऊपर, आगे

कैरेट निर्देशांक ही कारण हैं कि positioned ^ ^ ^3 means "in front of" and ~ ~ ~3 means "3 blocks south". Mixing the two notations in one coordinate triple is a syntax error.

store एक रिटर्न मान है, वेरिएबल नहीं

store captures what the command रिटर्न करता है — आमतौर पर सफलता की गिनती या परिणाम मान:

execute store result score @s Count run data get entity @s Inventory

दो चीजें जो लोग गलत समझ लेते हैं:

  • result versus success. result is the number the command produces; success

यह 1 या 0 होता है कि यह चला या नहीं। entities की गिनती के लिए आवश्यकता होती है result.

  • store goes before run, और यह इसके बाद वाले कमांड पर लागू होता है run, not to the

सब-कमांड चेन।

if बनाम unless शॉर्ट-सर्किट

if and unless filter — the chain stops there when the test fails. Multiple if clauses are an AND. There is no OR; that needs two separate commands or a predicate.

execute as @a if entity @s[gamemode=survival] if score @s Lives matches 1.. run ...

एक बार में एक सब-कमांड के साथ चेन बनाएँ, प्रत्येक चरण में संदर्भ प्रदर्शित होने के साथ, इसमें: Advanced Command Builder — यह एक ही फॉर्म से data, item, loot, schedule, particle और playsound को भी कवर करता है।

टूल आज़माएं: Advanced Command Builder — Execute & Data →