Get Playable Area of Map
-
Is there a function to get the playable area of a map? I've looked before, but never found one.
Would like to keep Support Bases from spawning in non-playable sections of maps, where players can't reach them.
-
@rama
I use this Function below in my Mods several times.
Mostly for my callable Reinforcements and Air Strikes.function GetPlayableArea() if ScenarioInfo.MapData.PlayableRect then return ScenarioInfo.MapData.PlayableRect end return {0, 0, ScenarioInfo.size[1], ScenarioInfo.size[2]} end -
Awesome! Much appreciated.
-
For anyone working on the UI side you can get the playable area with
SessionGetScenarioInfo().PlayableRect. There is also a user sync event with the keyNewPlayableAreawhen the sim updates the playable area.
Though this was added in March 2024 so you have to fall back tosize[1]andsize[2]for old replays. -
Oh my god...
I didn't realize I needed to copy the entire function CDRMV provided. I thought it was a built-in function like GetMapSize().
When it didn't work, I headed over to Github to look at more examples. Of course, they all used getPlayableArea(), which I copied.
Then, it finally occurred to me CDRMV meant for me to copy the entire function. Except, I forgot I'd switch my syntax to getPlayableArea(). Only took an hour of troubleshooting to see it.
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login