Author Topic: GUI star temp not seeming to work  (Read 887 times)

ibanix

  • Newbie
  • *
  • Posts: 30
  • Karma: +0/-0
    • View Profile
GUI star temp not seeming to work
« on: March 26, 2013, 07:07:23 PM »
I wanted to have the mouseover show the star's temp, so I added this inside gui.as ...

Code: [Select]
// Star Temp ... I hope
if (star !is null) {
float starTemp = 0.f, temp = 0.f;
if (obj.getStateVals("Temp K", starTemp, temp, temp, temp)) {
mo_text +=  combine("\n", "Tempature: ", "#c:c69c6d#", standardize_nice(starTemp), "K#c#");
}

}


And no joy. What am I doing wrong here?

Thy Reaper

  • BMS Lead Developer
  • BMS Administrator
  • Hopeless
  • *
  • Posts: 3237
  • Karma: +397/-8
    • View Profile
    • Blind Mind Studios
Re: GUI star temp not seeming to work
« Reply #1 on: March 26, 2013, 09:15:27 PM »
Is the variable "TempK" rather than "Temp K"?

ibanix

  • Newbie
  • *
  • Posts: 30
  • Karma: +0/-0
    • View Profile
Re: GUI star temp not seeming to work
« Reply #2 on: March 26, 2013, 10:15:08 PM »
If I use getStateName(int) and run through the numbers, it comes back as "Temp K".


ibanix

  • Newbie
  • *
  • Posts: 30
  • Karma: +0/-0
    • View Profile
Re: GUI star temp not seeming to work
« Reply #3 on: March 26, 2013, 10:30:10 PM »
If I run the following code:

Code: [Select]
if (star !is null) {
uint numStates = obj.getStateCount();
for (uint i = 0; i < numStates; ++i) {
     string@ somestate = obj.getStateName(i);
     string@ output = combine("Statename: ", "\"", somestate, "\"");
       warning(output);
}
}


I get this output:

Code: [Select]
Statename: "Damage"
Statename: "H3"
Statename: "Temp K"

ibanix

  • Newbie
  • *
  • Posts: 30
  • Karma: +0/-0
    • View Profile
Re: GUI star temp not seeming to work
« Reply #4 on: March 26, 2013, 11:06:45 PM »
Wow, this is annoying. Assuming that "Temp K" wasn't being set, I tried to set it myself in map_generation.as:


Code: [Select]
float placeholder = 0.f;
Object@ objStar = star.toObject();
objStar.setStateVals("Temp K", starDesc.Temperature, placeholder, placeholder, placeholder);

Still no go. How does this s*ht work?

Thy Reaper

  • BMS Lead Developer
  • BMS Administrator
  • Hopeless
  • *
  • Posts: 3237
  • Karma: +397/-8
    • View Profile
    • Blind Mind Studios
Re: GUI star temp not seeming to work
« Reply #5 on: March 26, 2013, 11:38:42 PM »
The GUI is not allowed to access state values of objects you don't own and aren't marked as being always visible in resources.xml. You would need to add an entry for "Temp K" in resources.xml and give it <alwaysVisible/>, like for Damage.

ibanix

  • Newbie
  • *
  • Posts: 30
  • Karma: +0/-0
    • View Profile
Re: GUI star temp not seeming to work
« Reply #6 on: March 27, 2013, 12:08:29 AM »
Doh!

Ok, so I added this to resources.xml:

Code: [Select]
<resource name="StarTempK">
<alwaysVisible/>
</resource>

I have this in map_generation.as:

Code: [Select]
// Star Tempature in K
// Stored as State@ for later GUI use
State@ tempK = obj.getState("StarTempK");
tempK.max = starDesc.Temperature;
tempK.val = tempK.max;

and finally this in gui.as:

Code: [Select]
// Star Temp ... I hope
if (star !is null) {
  float starTemp = 0.f, starMax = 0.f, temp = 0.f;
if (obj.getStateVals("StarTempK", starTemp, starMax, temp, temp)) {
   mo_text += combine("\n", "Temperature: ", "#c:c69c6d#", standardize_nice(starTemp), "K#c#");
  }

}

... and I still fail to init the map on some sort of map prep error.
« Last Edit: March 27, 2013, 12:10:14 AM by ibanix »

ibanix

  • Newbie
  • *
  • Posts: 30
  • Karma: +0/-0
    • View Profile
Re: GUI star temp not seeming to work
« Reply #7 on: March 27, 2013, 12:11:51 AM »
Strike that last. I have no idea what I did, but it works now.

Jon Micheelsen

  • Contributor
  • Sentient
  • *
  • Posts: 76
  • Karma: +19/-0
    • View Profile
Re: GUI star temp not seeming to work
« Reply #8 on: March 27, 2013, 07:21:01 PM »
Would you like to elaborate on that?  ;)

ibanix

  • Newbie
  • *
  • Posts: 30
  • Karma: +0/-0
    • View Profile
Re: GUI star temp not seeming to work
« Reply #9 on: March 28, 2013, 12:34:55 AM »
The code in the previous post now works. I think I forgot to hit 'save' on one of the files in my editor.  :P