#Are there more efficient if-else statements?
1 messages · Page 1 of 1 (latest)
<@&1201956957406109788>
💬 While you wait, take this time to provide more context and details.
🙇 After a while, hit the Summon Helpers button to ping the helper team. They'll be happy to help you
✅ Once your question has been resolved (or you no longer need it), please click Resolve Question or run /resolve
execute store success score button_pressed temp run clear @s *[minecraft:custom_data~{Button:"static"}]
execute if score button_pressed temp matches 1 run function pa:menu/update with storage minecraft:guis
execute store success score button_pressed temp run clear @s *[minecraft:custom_data~{Button:"back"}]
execute if score button_pressed temp matches 1 run function pa:menu/buttons/back with storage minecraft:guis
execute store success score button_pressed temp run clear @s *[minecraft:custom_data~{Button:"w1"}]
execute if score button_pressed temp matches 1 run function pa:menu/buttons/w1 with storage minecraft:guis
execute store success score button_pressed temp run clear @s *[minecraft:custom_data~{Button:"w1e"}]
execute if score button_pressed temp matches 1 run function pa:menu/buttons/w1e with storage minecraft:guis
execute store success score button_pressed temp run clear @s *[minecraft:custom_data~{Button:"w2"}]
execute if score button_pressed temp matches 1 run function pa:menu/buttons/w2 with storage minecraft:guis
execute store success score button_pressed temp run clear @s *[minecraft:custom_data~{Button:"w2e"}]
execute if score button_pressed temp matches 1 run function pa:menu/buttons/w2e with storage minecraft:guis
execute store success score button_pressed temp run clear @s *[minecraft:custom_data~{Button:"item1"}]
execute if score button_pressed temp matches 1 run function pa:menu/buttons/item1 with storage minecraft:guis
execute store success score button_pressed temp run clear @s *[minecraft:custom_data~{Button:"item2"}]
execute if score button_pressed temp matches 1 run function pa:menu/buttons/item2 with storage minecraft:guis
execute store success score button_pressed temp run clear @s *[minecraft:custom_data~{Button:"item3"}]
execute if score button_pressed temp matches 1 run function pa:menu/buttons/item3 with storage minecraft:guis
(there are more, but discord character limit)
Forgot to mention: I am on 1.20.6
temp matches 1 run return run function
You could just do execute if items a bunch of times, probably
For that you have to specify a slot
then better
execute if funtion <clear> run function pa:menu/buttons/item3 with storage minecraft:guis
function <clear>
return run clear @s *[minecraft:custom_data~{Button:"item3"}]
I thought the slot could just be *
They would all return the same number and you can't know which one returned
functions ccan only return ints
Yes it can be
Well, container.*
I didn't say there should be one function.. functions for each clear command
This doesn't cover the cursor
True
Item will be in the cursor, or if shift clicked in the inventory
Added that, thanks!
This would result in the same code as rn but more complicated and over multiple functions
execute if items entity @s container.* *[minecraft:custom_data~{Button:"w2e"}] run function … a bunch of times or whatever is what I would do. But yeah it doesn’t cover the cursor
If you do want to cover the cursor you can do that easily
Or at least I think you can
You can by copying the code for the container check and change it for the cursor (this doubles the cheks though)
If it's only the cursor slot, you can still use execute if items