simon816 / Command-Block-Assembly

Compile high-level code into Minecraft commands
https://www.simon816.com/minecraft/assembler
MIT License
271 stars 29 forks source link

Potential feature: Dynamic dispatch without a tick delay #7

Closed sarahzrf closed 4 years ago

sarahzrf commented 5 years ago

A series of chain command blocks that loops back on itself (most compactly, just two facing each other) will continue to run to the chain limit if both have the tag UpdateLastExecution set to 0. This allows dynamic dispatch to be done without a tick delay by updating one of the command blocks in such a chain while a previous one is executing, which seems like a potentially desirable feature.

simon816 commented 5 years ago

I'll check it out. I was under the impression that command blocks only triggered once per tick.

Another strategy for dynamic dispatch is to create a lookup table and give each function an ID. This was what I previously did (see add_lookup_table and function_id) maybe I could add that as an option too.

sarahzrf commented 5 years ago

They do, if UpdateLastExecution is set to 1, which is the default and cannot be changed directly in the UI.

simon816 commented 4 years ago

I've implemented this at a low level, and exposed it in Command IR with these instructions:

clear_zero_tick

clear_zero_tick

Remove any function from the special zero-tick command block and clear the zero-tick flag.


set_zero_tick_from_stack

set_zero_tick_from_stack

Sets the special zero-tick command block to execute the function at the top of the global stack. The function will execute in the same tick once control is returned to the command block.


zero_tick_set

zero_tick_set <ref>

Sets the special zero-tick command block to the given function or function reference. The function will execute in the same tick once control is returned to the command block.

ref: (Variable|FunctionLike) Function reference

sarahzrf commented 4 years ago

cool :)

On Fri, Sep 20, 2019 at 3:40 PM Simon816 notifications@github.com wrote:

Closed #7 https://github.com/simon816/Command-Block-Assembly/issues/7 via 1f5eb4d https://github.com/simon816/Command-Block-Assembly/commit/1f5eb4d205eb2827b4c2c458263006e906e79454 .

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/simon816/Command-Block-Assembly/issues/7?email_source=notifications&email_token=AACKV6TMD6UA5V43DFW35ZTQKURLDA5CNFSM4HZDYFG2YY3PNVWWK3TUL52HS4DFWZEXG43VMVCXMZLOORHG65DJMZUWGYLUNFXW5KTDN5WW2ZLOORPWSZGOTYEFBBI#event-2651345029, or mute the thread https://github.com/notifications/unsubscribe-auth/AACKV6TD2FCBWNGIV64L3QTQKURLDANCNFSM4HZDYFGQ .