Check which property is the highest

I have 10 properties, and I want the game to check which one is the highest. Any simple way of doing this?

6 Likes

??? Sorry I canā€™t help you

2 Likes

Get a button(or anything) and get text.
Wire the button to the text (when button pressedā€“run wire pulse back)
Now make a when receving wire pulse block in the text.
In the block: Set text to:get property:(your property)
Copy the text 9 more times one by one (because then the block will also copy)
Dont forget to change the properties in each text block.
Now wire the button (or whatever you chose) to the other 9 texts with when button pressedā€“run wire pulse back.
So when you press the button you should see all the numbers (if they are number properties) and see which one is the highest
This should work

4 Likes

Sadly, using the checker with properties doesnā€™t work, as it is bugged, so you will have to use block code.

Create two properties, highestValue, and highestName. These will store the value of the highest property, and the name of the highest property.

Place a trigger, and go to block code. Write:
if (get_property(highestValue) < get_property(myproperty1):
set_property(highestValue, get_property(highestValue)
set_property(highestName, myproperty1)

This checks if my property is greater than the highest property checked so far. To check all 10 properties, copy paste this code over and over, changing the name of the property you are comparing each time.

If you run out of space in the block code of this trigger, add a broadcast on channel button to the code. Setup another trigger to trigger when receiving on that channel, and then put the rest of the if statements in that trigger.

Sorry for the lack of screenshots, Iā€™m on mobile right now.

7 Likes

Thanks! I was trying to make a voting system for Among Us.

1 Like

I should probably say- there is a more optimal solution, but itā€™s more complex and involves lists. Do you want it?

1 Like

Yes.

2 Likes

So, first, read this if you havenā€™t already:

Then, make sure your voting properties all have a naming scheme like ā€œp1votesā€, ā€œp2votesā€, ā€œp3votesā€ etc.

Place a repeater, and wire it to a trigger. Then place a property and name it 'ā€˜iā€™ or something like that.
Make the repeater repeat 10 times, and then go to the trigger and enter block code.

Then write the following code:

#store the property name in a varible called name
name = create_text("p1", get_property(i), "votes")

#check if the value of name is greater than the highest votes so far
if (get_property(name) > get_property("highest")):
    #if so, update the highestName and highestValue properties.
    set_property("highestName", name)
    set_property("highestValue", get_property(name))

#increase i to check the next property
set_property("i", get_property("i")+1)

#A check to reset the "i" property when all properties have been checked.
if (get_property("i") == 10):
    set_property("i", 0)

I hope this makes sense lol

5 Likes

you should make a guide!

1 Like

Iā€™m procrastinating it lol
Iā€™m working on my next big project in gimkit :smiley:

1 Like

Whatā€™s it going to be? Just a hint would be fine lol.

Iā€™m also working on a huge rpg project called Farmersā€™ Quest.

2 Likes

i am still working on monopoly, but i did add to my guide today :}

1 Like

Donā€™t even know where to start on CCC lol

1 Like

Farmersā€™ Quest has 72% memory and a merchant system lol.

4 Likes

the terrain

1 Like

Well, its not gonna be something boring that gimkit intended for people to make in creative :slight_smile:
But other than that, i prefer not to give spoilers, since I usually fail to meet my goals and dont want to raise expectations only to drop them.

4 Likes

Thatā€™s okay. I think I want to create a bossfight first to get feels for the boss fight at the end of Farmersā€™ Quest, so I might make a guide on those.

2 Likes

What kind of bossfight? Like a sentry one or with custom attacks?

3 Likes

Both, probably. Iā€™m making a fake one.

2 Likes

so you are just getting comfortable before you make the real thing?

1 Like