Fractal Softworks Forum

Please login or register.

Login with username, password and session length

Author Topic: getEntityByName()  (Read 3661 times)

DeathSG

  • Lieutenant
  • **
  • Posts: 54
    • View Profile
getEntityByName()
« on: March 09, 2012, 03:24:16 AM »

hey i would just like to point out that the getEntityByName is not fixed yet.
Logged

Apophis

  • Captain
  • ****
  • Posts: 466
    • View Profile
Re: getEntityByName()
« Reply #1 on: March 09, 2012, 08:17:25 AM »

i think i have found the problem with the minimash, maybe getEntityByName() is not broken
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24128
    • View Profile
Re: getEntityByName()
« Reply #2 on: March 09, 2012, 08:44:50 AM »

Hmm. Just did some testing, and it appears to be working fine. Certainly possible that it won't work under some circumstances, but I tried spawning a fleet at a planet (the token for which I got using getEntityByName()), inside a custom SectorGeneratorPlugin.generate(), and that worked.

@Apophis: can you let me know what the issue turned out to be? Looking at DeathSG's Corvus.java, I'm not seeing anything that jump out - beyond overwriting Corvus.java, which isn't the right thing to do.

@DeathSG: if you can link to a broken copy of the mod (in case Apophis's fix doesn't work), I'll take a look at it.
Logged

Apophis

  • Captain
  • ****
  • Posts: 466
    • View Profile
Re: getEntityByName()
« Reply #3 on: March 09, 2012, 08:58:34 AM »

The problem was a generator.csv in Minimash\data\world.

But in my mod i have found that if you use getEntityByName() in a generator it will not work at the start. In my case i used getEntityByName inside the spawnfleet method of my custom spawn point. If i manually call spawnfleet from my generator getEntityByName don't work, but in the next "automatic"(after daysInterval time) calls to the method everything work
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24128
    • View Profile
Re: getEntityByName()
« Reply #4 on: March 09, 2012, 10:43:10 AM »

Can you post a copy of the mod somewhere? I tested exactly what you're describing (spawnFleet from the generator) and it worked.
Logged

Apophis

  • Captain
  • ****
  • Posts: 466
    • View Profile
Re: getEntityByName()
« Reply #5 on: March 09, 2012, 01:18:16 PM »

here the mod that crash
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24128
    • View Profile
Re: getEntityByName()
« Reply #6 on: March 09, 2012, 01:35:48 PM »

Thanks!

I think I see the problem - unless I'm missing something, doesn't look like you're actually adding the stations to the game (using system.addOrbitalStation).
Logged

Apophis

  • Captain
  • ****
  • Posts: 466
    • View Profile
Re: getEntityByName()
« Reply #7 on: March 09, 2012, 01:48:20 PM »

Yes, i am using stations already present
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24128
    • View Profile
Re: getEntityByName()
« Reply #8 on: March 09, 2012, 01:54:05 PM »

Are they created by another mod? The order in which the generator scripts are run isn't guaranteed, aside from the base game's SectorGen running first.
Logged

Apophis

  • Captain
  • ****
  • Posts: 466
    • View Profile
Re: getEntityByName()
« Reply #9 on: March 09, 2012, 01:58:16 PM »

I use the 3 default stations
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24128
    • View Profile
Re: getEntityByName()
« Reply #10 on: March 09, 2012, 02:31:59 PM »

Ahh, I was misreading your code (saw the last station not being a default one, didn't read the rest in enough detail).

So - it'll break if using a station only, before the game has started running (now fixed). It'll correctly get planets, though - and, actually, any stations that were added before another planet will work too.

Thank you for helping!
« Last Edit: March 09, 2012, 02:33:36 PM by Alex »
Logged