Set float to Agentmap

Hey there!
I’m working on a UI Level bar & already set up a color_block. Now I want to change the Width of the color_block based on the agentmap of a player.
How do I do that?
this is my color_block widget:
LevelBlock : color_block = color_block{DefaultColor := NamedColors.DarkCyan, DefaultDesiredSize := vector2{X:= Width, Y:= 100.0}}

Also, here is the agentmap that should be the width:
var LevelBar: [agent]float = map{}

Anytime aplayer completes a level, you could simply do


    
 LevelBlock.SetDesiredSize(vector2{X := Width * AgentLevel, Y := 100.0})

Of course here, I’m assuming you have acces to the Agent’s current level AgentLevel , and that Width is defined as a single bar width for a level.

1 Like

Thanks!!
I had to modify the script a little bit, but now it works! :slight_smile:

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.