How to make country name display like hoi4

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    I want to create a TextLabel that expands or gets larger if the player’s nation gets larger example:
    image
    `


    the name thingy
    and even something as simple as this would be great

  2. What is the issue? Include screenshots / videos if possible!
    I have no idea how to create it.

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    Haven’t really seen any solutions or how to create it, the dev creating World Of Revolution said it took him 6 hrs to make and some other stuff he made so i would expect this would require alot of math

4 Likes

I know this post is old, but I have been spending the past 4 - 5 days working on something similar to this, and my results were horrid. I am curious if you found a solution for it.

2 Likes

I did eventually find a way, sadly it was too laggy, I’m currently trying to revamp the script

3 Likes

I recommend not to worry for now, I’ll try to send you the script If i am able to optimize it better.

2 Likes

Maybe you can send the code over and I can try to optimize it?

1 Like

I don’t know if this would be the most optimal way, but perhaps you could find the two furthest bordering regions, and then get the center point of those two, from there you can put your label down, and associate the font / text size with the distance between the two points?

It may have some weird edge cases if you have strangely shaped countries, but it’s definitely seems to be a viable solution, especially if you put in some more solutions to fix the given edge cases.

1 Like

This wouldnt work well. There are multiple islands and multiple divided areas in each country. And you would need to curve the text alot.

1 Like

I assume you have a dataset for individual islands, etc… In which case it seems like this is more-so a problem as to how you would find the centroid of a polygon.

function Polygon:get_centroid()
  local sum_x, sum_y = 0, 0
  for i = 1, #self.vertices, 2 do
    sum_x = sum_x + self.vertices[i]
    sum_y = sum_y + self.vertices[i+1]
  end
  self.cx, self.cy = sum_x/(#self.vertices/2), sum_y/(#self.vertices/2)
  return self.cx, self.cy
end
2 Likes

Curvy_Text.rbxm (19.2 KB)
here’s the old code, it seems like I won’t be able to revamp the script this summer
results of the code:


you can optimize it yourself if you so like it, though it may not be laggy at first, it might be if too many nations are created since I created too many For, I loops.

The code is also used by Nations Rising Simulator, though I wasn’t given credit, but they did optimize it themselves.

you can just use it as a foundation because the results are also very wonky, like, very.

3 Likes

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