Cannot call [IsSameLocation] on a None object Error

Post » Thu Jun 21, 2012 8:32 am

I have an OnUpdate event that uses the IsSameLocation function

In game, everything appears to function correctly ... However when I look in the logfiles I see a few instances of:

error: Cannot call IsSameLocation() on a None object, aborting function call stack: [alias h4vt_player on quest h4vt_ACT_MainQuest (02004001)].MeetMeHere1.OnUpdate() - "MeetMeHere1.psc" Line 32

(In an effort to rid my mod of all errors)

What is the best way to test that the PC is an object, before using a function?

(At least, I assume the error means the script is running before the PC is loaded, or just after the game is quit?? As I only have a few logfile entries and the routine would have run far more times than the number of errors produced).

I should note that a few Beth scripts - the BurialMound one, for example - using the same function, generate a few identical errors in the logfile.
  • Would IsEnabled work for the PC?
  • Is there another/better way?
  • Am I correct in assuming is it a not-loaded problem? (I can't see what else it is .. in game the script appears to function just fine ... only these few silent logfile errors exist)
Cheers for any help :)
User avatar
Susan Elizabeth
 
Posts: 3420
Joined: Sat Oct 21, 2006 4:35 pm

Post » Wed Jun 20, 2012 9:30 pm

It would help if you post your script. But that error would be expected if one of the locations you're testing is undefined, i.e., None. Not all areas in the game have a location defined, so if you are using a function like GetCurrentLocation or an event like OnLocationChange, you should test to ensure the location returned is not None before using IsSameLocation.
User avatar
Sabrina Schwarz
 
Posts: 3538
Joined: Fri Jul 14, 2006 10:02 am

Post » Thu Jun 21, 2012 12:47 pm

But the error is saying that it is a ReferenceAlias (which is the Player, in this case) that is not an object - Not a location.

The rest of the script does nothing special - and the functionality works ... it just leaves a couple of error lines in the logfile and I'm trying to figure out why, at some point, just for a few seconds, the Player is not an object.
User avatar
Devin Sluis
 
Posts: 3389
Joined: Wed Oct 24, 2007 4:22 am

Post » Wed Jun 20, 2012 11:22 pm

Doing a check to see if your variable/property is set to 'none' is the solution. I do this with an if-endif loop; checking "if yourRef != none" then your command.

I explain this in detail at the thread I made just for this kind of issue...
http://www.gamesas.com/topic/1370110-impact-of-system-stress-scripting-errors-on-game-performance/

Spread the word! As OTHER people's buggily scripted mods WILL affect your script if you rely on precise timing... generally only on low-mid end computers though. (but this depends entirely on all detail level, amount of mods, number of errors, size of timing increments, etc etc.. so should be evaluated on a case-by-case basis)
User avatar
Kevin S
 
Posts: 3457
Joined: Sat Aug 11, 2007 12:50 pm

Post » Wed Jun 20, 2012 11:59 pm

But the error is saying that it is a ReferenceAlias (which is the Player, in this case) that is not an object - Not a location.

The rest of the script does nothing special - and the functionality works ... it just leaves a couple of error lines in the logfile and I'm trying to figure out why, at some point, just for a few seconds, the Player is not an object.

It depends on how you interpret the error message--IsSameLocation is a function called on a location, so I take it to mean that's what the None object is. This is where seeing your code would be helpful. Are you calling something like GetCurrentLocation on the alias you have for the player, and then doing IsSameLocation on that?

You can probably tell something about the error by when it happens. Does it happen right when the game loads? Then perhaps it is an issue where the alias isn't filled yet. Does it happen only at certain points when the player is moving? Then more likely it is what I said, that the PC is exiting a location and entering a cell without a defined location.

If it's an alias-not-being-filled error, can you replace the alias for the player in your code at that point with Game.GetPlayer()? I don't think that is ever None.
User avatar
rebecca moody
 
Posts: 3430
Joined: Mon Mar 05, 2007 3:01 pm

Post » Thu Jun 21, 2012 2:06 am

It doesn't matter when or what command its used. It doesn't matter what the property is... location, spell, actor, static, whatever. It's a basic mechanism in the language that affects everything relating to all types of properties. The errors happen anytime any line of code runs a command on a property that has never been assigned anything (ie: still set to 'none'.. the default).

You can replace the alias property with a 'regular' one pointing directly to Player, or do as you say... just call the game.getPlayer(); but I think some commands require you to assign it to a property. Instead of doing an if-endif loop (or while, or whatever other type of check), you can simply FORCE something into the ref, so that you know for SURE it will never be 'none'. This also has it's drawbacks, as I think if properties are left filled, those refs stay active/persistent until emptied... which would be done at the end of your script should this be true.

You should also be aware that there are issues in mods which fill properties in scripts,assign those scripts to bases or references, then remove those properties from the script. The CK doesn't remove the now-deleted properties' data from the ESP... you have to do it manually or you will cause WORSE errors than the one above. Amethyst Deceiver knows more about how to truly fix this than I do, she explains it better in that other thread.
User avatar
Josh Lozier
 
Posts: 3490
Joined: Tue Nov 27, 2007 5:20 pm

Post » Thu Jun 21, 2012 1:48 am

Now let's not fall out :wink:

Scriptname MeetMeHere1 extends ReferenceAlias  ReferenceAlias Property h4vt_player  Auto  ReferenceAlias Property h4vt_MaZay  Auto  .....Event OnUpdate()ObjectReference h4vt_MaZay_Actor = h4vt_MaZay.GetReference()if (h4vt_MaZay_Actor.GetCurrentLocation().IsSameLocation(Game.GetPlayer().GetCurrentLocation()))	if (h4vt_MaZay_Actor.GetDistance(Game.GetPlayer())) < 1024.....;do some stuff.....end ifend ifend event

The FIRST of the IF statements is the one producing the error - That is Line 32 ...

The script itself is on an ALIAS that is set to Unique Actor (the Player).

Note that I DO USE Game.GetPlayer() in my script


So I am wondering whether the other Alias (an NPC) is the one that is returning "None"

OR I am also wondering whether if EITHER the Player or the NPC are not in a location, that would return "None" as the Error message in the first post proclaims


And now, I have to point out that all of this may be me not understanding what a location is - rather than one of my aliases being unfilled.

So, let me do a bit more testing before anyone worries any more over this

(I'll give you a hint ... Is a "Wilderness" Cell a location?!)



SLuckyD: Thanks for the IF test check ... I should have really put that in anyway (I once coded for a living, so it's quite bad I did not!) :wink:
User avatar
patricia kris
 
Posts: 3348
Joined: Tue Feb 13, 2007 5:49 am

Post » Wed Jun 20, 2012 8:54 pm

(I'll give you a hint ... Is a "Wilderness" Cell a location?!)

most of the time, no.
i would imagine running a location query on a wilderness cell will return a value of none, since there is no inherited location data (they exist within the parent, tamriel, which in itself has no location)
User avatar
Robert Jackson
 
Posts: 3385
Joined: Tue Nov 20, 2007 12:39 am

Post » Thu Jun 21, 2012 6:32 am

most of the time, no.
i would imagine running a location query on a wilderness cell will return a value of none, since there is no inherited location data (they exist within the parent, tamriel, which in itself has no location)
I'm testing that later ... While running the game with the mod enabled and just wandering, I came across my NPC (in the middle of no where) ... Brilliant, I thought, that's exactly what I want ... And then the "start scene" failed to ... start ... and I thought, "Oh b*gger!" and immediately started to wonder about Wilderness cells ...

So I'm pretty sure that is the answer ... when one of the two aliases is in a wilderness cell, SameLocation is failing because the location of one (or both) is None ...

I know how to fix ... But first I have a plan for testing whether this is the problem (just because I want to know, now!)

But thanks, Amethyst ... I reckon you've got the answer :smile:
User avatar
Joanne
 
Posts: 3357
Joined: Fri Oct 27, 2006 1:25 pm

Post » Thu Jun 21, 2012 1:32 am

if you do a GetWorldSpace(Tamriel) && GetLocation()==None, that should return true for all the wilderness cells, as usually all the named tamriel cells have a specific location attached to them and would work normally with your SameLocation function query
User avatar
Isabel Ruiz
 
Posts: 3447
Joined: Sat Nov 04, 2006 4:39 am

Post » Thu Jun 21, 2012 4:17 am

[If you're talking about falling out with me... I apologize that my tone sometimes come across as overly vigilant. I was just trying to be thorough in the explanation. I assure you, if I was irritated or whatever, either you'd KNOW it or I wouldn't post at all (which would be more likely). It seems some British Anglophones are overly sensitive to Yank haughtiness... heheheh. (you wouldn't be the first to miscontrue my tone through text; that's why I prefer my human contact still human.. heheh)]

I've run into problems using game.getPlayer() inside the 'lengthier' lines like you have. Those are instances where assigning Player to a actor property seems to be required. That may be your problem. I don't understand why, I just know I got it to work... yet other parts of my script still use game.getP without problems. [I think it may have to do with 'nesting' the game.getP inside ()... only my best guess right now.]

Locations: if you look in the objectWindow, under "world data" I think it is, you'll see the "locations". These are actually bases (what I sometimes mistakenly call objects I think), these need to be assigned to what you & I would consider a location-proper. That's what I meant above. I'm not too familiar with locations and aliases yet, so my advice is greatly limited to my anecdotal knowledge. These are the kinds of things that I've been easing into learning by piecework, regarding the major differences between Papyrus over the old Oblivion scripting format. I've also heard that there may be a bug or two regarding locations in Vanilla space... so you may want to avoid using that for now.

But if you're trying to trigger some kind of action, 'event', or scene: instead of checking for a location, you could check to see if it's in the same cell... isNearPlayer() I think does that. Also, "if (yourRef.GetParentCell() == Game.GetPlayer().GetParentCell())" tests to see if an object is in the same cell as Player. You could also do a getDistance()... plenty of different ways to test for proximity.

As far as 'none' in your aliases... I made a tiny little cheat-mod (ring that lets you carry 10k pounds in Inventory). It gives the ring to Player as soon as the game is started (or a saveGame is loaded). This is the ONLY time I've even GLANCED at alias drama so far... but what I DID learn was that in order for an alias to be 'filled' (or assigned or whatever), the quest it's attached to must be running. My ring 'quest' is set to begin 'on game start', so triggers without any effort from User or Player. So this may be the case if your quest isn't set to trigger until AFTER the scene/whatever has begun... which of course would never happen, should this correct.
User avatar
Elisha KIng
 
Posts: 3285
Joined: Sat Aug 18, 2007 12:18 am

Post » Thu Jun 21, 2012 6:16 am

if you do a GetWorldSpace(Tamriel) && GetLocation()==None, that should return true for all the wilderness cells, as usually all the named tamriel cells have a specific location attached to them and would work normally with your SameLocation function query
Yeah, that's my fix.

Sort of ...

Actually, I have to amend things back to how I started, just using GetDistance - which always works, though is sometimes stupidly large.

Then (actually, probably and/or) I need to use the test you suggest to check whether although they are miles and miles apart (in terms of where the CELLS are) they are - in terms of Tamriel - quite close! (I've nearly wrapped my head around how)

Then I should be getting what I want ...


Note: I did think the "Drunken Revellers" would help me out ... but they are fired by 130+ triggers placed about the World ... I'm kinda worried that is the only way to do what I want (which isn't what I want!), but we'll see (if you see what I mean!)

:wink:
User avatar
Tai Scott
 
Posts: 3446
Joined: Sat Jan 20, 2007 6:58 pm

Post » Thu Jun 21, 2012 4:20 am

[If you're talking about falling out with me... I apologize that my tone sometimes come across as overly vigilant. I was just trying to be thorough in the explanation. I assure you, if I was irritated or whatever, either you'd KNOW it or I wouldn't post at all (which would be more likely). It seems some British Anglophones are overly sensitive to Yank haughtiness... heheheh. (you wouldn't be the first to miscontrue my tone through text; that's why I prefer my human contact still human.. heheh)]
Nah, don't worry, mate - I live in australia. If you don't have a thick skin you die from sunburn before you are 2 years old :wink:


IsNearPlayer - http://www.creationkit.com/IsNearPlayer_-_ObjectReference
One of those functions that is not exactly well defined. Could mean LOS, could mean same cell, could mean something else! But yeah, that is worth a try as well as / instead of InSameLocation

The thing with InLocation is I then know they are in a potentially crowded place ... and eventually the plan was to shift them away from that place before starting up a scene ... But - like I put in the post above (thanks to Amethyst) - I have to figure out some error traps for when they are not in places at all!

I do use getdistance ... But I think I need to make that the starting point, then move down other if tests from there if that produces odd results.

And my Quest starts before the "Starting Scene", the quest is actually Start Enabled (but the player doesn't know)



Thanks for the help, both of you :smile:
User avatar
Alexandra Ryan
 
Posts: 3438
Joined: Mon Jul 31, 2006 9:01 am


Return to V - Skyrim