Author Topic: Trying to get a list of planet names?  (Read 9318 times)

kevinminion

  • Global Moderator
  • Full Member
  • *****
  • Posts: 147
  • Karma: +15/-0
    • View Profile
  • IGN: Kevin Minion
Trying to get a list of planet names?
« on: November 14, 2016, 10:58:44 pm »

It's late, so maybe I'm just missing something...

I'm trying to use PlanetName = MyEntity:sbEnvName() to grab a list of all planet names in a map, but most everything I've tried to plug in for MyEntity returns an empty string.

PlanetName = owner():sbEnvName() returns the expected string

I've tried creating holos at the planet centers and then using PlanetName = Holo:sbEnvName() but that also returns an empty string.

Is there another way to get all of the planet names?

bloxgate

  • Supreme Forum Overlord
  • Administrator
  • Hero Member
  • ******
  • Posts: 546
  • Karma: +50/-4
    • View Profile
    • Bloxgate's Website
  • IGN: bloxgate
Re: Trying to get a list of planet names?
« Reply #1 on: November 15, 2016, 12:05:21 am »
Look in E2Helper for getPlanetName. Just target the planet's entity, and give that to the function.

kevinminion

  • Global Moderator
  • Full Member
  • *****
  • Posts: 147
  • Karma: +15/-0
    • View Profile
  • IGN: Kevin Minion
Re: Trying to get a list of planet names?
« Reply #2 on: November 15, 2016, 09:06:25 pm »
@bloxgate Thank you for the nudge in the right direction, the code snippet below is working for me now.

Code: [Select]
        findByClass("logic_case")
        Planets = findToArray() # returns array of entities
       
        for(K=1,Planets:count()) {
            ThisPlanet = Planets[K,entity]
            print(K + ": " + getPlanetName(ThisPlanet) + " : " + ThisPlanet:pos())
        }