Jump to content

[LE] Testing GetLightLevel in a script...not sure what's going wrong?


Recommended Posts

Just playing around trying to make a quick and dirty script to return the player's current Light Level in a messagebox. I attached it to a ring that grabs the value when equipped, then is supposed to display it when the ring is unequipped....

Scriptname SamHellsLightDetectTestScript extends ObjectReference
{Script to detect the light level of the player.}

float lLevel
int EquipCount

;--------------------------------------------------------------------------

Event OnEquipped(Actor akActor)

   EquipCount = EquipCount + 1
   lLevel = akActor.GetLightLevel()

EndEvent


Event OnUnequipped(Actor akActor)

   debug.messagebox("Your Light Level is currently " + lLevel + " and you have equipped this ring " + EquipCount + " times.")

EndEvent

The result is that the Light Level always returns 0.000 no matter where I'm at. I tested it in caves, houses, out in direct sunlight, day or night. It always returns 0.000.

The other variable (EquipCount) I just threw in as a backup to double check that things are firing correctly. It returns the correct value, counting up the times I equip and unequip the ring. Is there something else I should know or do to return the correct Player light level?

Link to comment
Share on other sites

I actually tried Game.GetPlayer() first and was getting the same result so switched to akActor. Neither seem to work.

 

I've had an issue before where a simple script like this acts in an unexpected way, and no amount of editing seems to fix it. Yet if I copy and paste it into a new script with a new name, it will suddenly start working. Same thing with objects I've attached scripts to....the script won't work as expected on the object, but if I delete the object's reference from the cell and drag a new reference of the same object into the cell, then add the same script onto that new reference, suddenly the script will work.

 

Is there some way scripts and variables get "baked" into a mod? It's been a few years since I've modded Skyrim, but I don't recall having this kind of petty trouble simply editing/updating my scripts/mods before.

Edited by SamHe11
Link to comment
Share on other sites

Are you sure you're testing this on a clean save that has never seen the mod. As in you are always going back to a save pre-mod when you test.

From the errors you described It sounds like you may be saving while the mod is installed and continuing to edit and test after that.

 

For me, when I create a mod all game play/saving stops until the mod is completed. I never save while my mod is installed until it is done.

I actually start a new game, try to avoid quests, head to the spot my mod is (mostly do home mods) and save. After all that I add my mod to the

load order then use that save for all my testing. Never saving again until the mod is complete.

You could also use a different save ... but, that never seems to work out :wallbash:

Saving once the mod is installed in the load order will "bake" the mods current state into the save.

Any test to edited changes after that is void. Yielding false positive and false negatives ...

Edited by NexusComa2
Link to comment
Share on other sites

Saving once the mod is installed in the load order will "bake" the mods current state into the save.

Any test to edited changes after that is void. Yielding false positive and false negatives ...

Thanks. That's something I'd never considered before and will utilize in the future.

 

Unfortunately, I'm nowhere closer to solving this. I've removed all mods, going back to vanilla SSE with a brand new save, created a completely new mod with a brand new script and brand new objects and it still won't work. It always returns 0.0000 no matter where I'm standing. I've tried it on items, on activators, quest scripts, etc...I've tried different conditionals in the script in case I wasn't calling the variable's value in the messagebox correctly....no luck. I'm at a complete loss. It should be such a simple thing to pull off.

 

EDIT: Interestingly, I tried THIS MOD, and it doesn't work either. The result always comes back as 0 light level. So wtf?? Are graphic settings coming into play here or something?

 

EDIT 2: Tried loading it up on an install on a different rig of mine and it actually works. So......something wrong with the install on my original setup? Would Game/ini settings have an impact on this? I'm scratching a bald spot on my head over this.

Edited by SamHe11
Link to comment
Share on other sites

Hmmm, that's really strange. Glad you got it working. Were you using an enb on one of your tests? If you find out why it didn't work before let us know so we can account for the problem.

 

Oh, and to find out if it requires SKSE, you can open the source .psc file and search for the function. In this case, open Actor.psc and search for GetLightLevel(). If the function is there and SKSE isn't installed it doesn't require SKSE.

Link to comment
Share on other sites

Confirmed it's not SKSE dependent.

I couldn't fix it on the old install so wiped it out and reinstalled to a pathway similar to the one on my other PC and now it works. I'll have to pay closer attention to that in the future. Still not sure why though. I'm sticking with my game/ini settings theory.

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...