Can someone simplify this mess:
Use and & or logic blocks
You need to use the āset options idxā variable block before using it in an if statement. Also variables are only made to hold numbers (so Iāve been told for a very long time).
Give me a few more details and explain what Iām looking at and I bet I can make a much simpler mess.
Itās a voting system where the host tallys up the votes for 2 options. If it finds a tally hogher than the other options, then it sets the highest option to that and saves it to a text property. To make the length of the string always 2, if the length of it is 1, then you join a 0 onto the front of it. If you find one thatās equal to the highest option, then you add it to the property.
Whatās the setup outside of the block code (how are people voting?)
No, you can store anything in variables.
Iāve experienced a lot of trouble (not to mention all of the others Iāve helped that have suffered from the same problem) with text strings in variables, mainly when checking in if/else statements. Iām pretty sure it has something with the way gimkit itself is made, as normally this wouldnāt be an issue.
Thereās a similar problem in Java with strings. Basically, thereās things that are objects, and each object is treated separately. Strings are objects that encode the text, and in Java, the equals sign checks if the 2 things are the same exact thing. So if you have 2 different strings that have the same contents, but are different objects, then the equals operator treats them as different and returns false. It could be the same problem here, but Iām not sure.
You walk into a zone which increases a counter which sets a property named āOption (#)ā
I went ahead and found a way to simplify it. If anyone can find any more ways to simplify it, let me know.
I donāt think this is going to be possible, but if anyone could get this down to 42 or lower, that would be great! Iām at 60 right now.
Instead of adding 1 to the property at the top, why donāt you just set the variable to the property +1? It would save 4 blocks and I donāt think it would ruin anything (not sure what the āvote finalizeā is though).
You can save the first if block by making the trigger be player scope, default inactive and activating it with a game start lifecycle. (-3)
Change the last if statement to (-3)
Instead of setting the most votes property and options idx property to 0 using blocks, broadcast on a channel to use a counter to set them to 0 (-4)
You might want to think about shifting the Beginning variable up by 1 to save 2 blocks. Youāll have to shift reference to options string though, so I donāt know if you want to do that.
If you do all of this, youāll have 6 blocks left. Following slimās advice, you only need 5 more blocks. If you tell me more about the logic that these blocks run in, I may be able to get it down to fit into a single block.
Thanks a ton for the help. I modified a few things, and here was the final result:
Used some counters, as you suggested, to update the properties.
This topic was automatically closed 3 hours after the last reply. New replies are no longer allowed.






