Using a Ref to compare to EditorID?

Post » Thu Jul 22, 2010 5:19 am

ref horseRefset horseRef to GetPCLastHorseif horseRef == HorsePCWhiteAnvilRef  let horseFound := 1  ; do somethingelse  let horseFound := 0endifif horseFound  Message "I Found AnvilWhite horse."else  Message "I found nothing."endif


If I mount the horse, then call this script, it goes "I found nothing".

Tried with if horseRef.GetBaseObject == HorsePCWhiteAnvil and nothing too.

How can I make it work?
User avatar
Jhenna lee Lizama
 
Posts: 3344
Joined: Wed Jun 06, 2007 5:39 am

Post » Thu Jul 22, 2010 7:31 am

http://cs.elderscrolls.com/constwiki/index.php/If#Comparisons_and_Reference_Variables
User avatar
Scott Clemmons
 
Posts: 3333
Joined: Sun Sep 16, 2007 5:35 pm

Post » Wed Jul 21, 2010 9:35 pm

Thanks a lot!
User avatar
matt
 
Posts: 3267
Joined: Wed May 30, 2007 10:17 am

Post » Thu Jul 22, 2010 6:14 am

Thanks a lot!
Did it work ?
What did you use finally ?
User avatar
Janette Segura
 
Posts: 3512
Joined: Wed Aug 22, 2007 12:36 am

Post » Thu Jul 22, 2010 5:52 am

umpf...

Tried:

horseRef.GetIsReference HorsePCWhiteAnvilRef ; objectRef put in the world space

horseRef.GetIsID HorsePCWhiteAnvil ; objectID in the editor

Doesn't work.

Any help?
User avatar
evelina c
 
Posts: 3377
Joined: Tue Dec 19, 2006 4:28 pm

Post » Wed Jul 21, 2010 5:52 pm

GetIsID ObjectIDReturns 1 if the calling object is a reference to ObjectID. The parameter for this function is a base object ID, as defined in the object window. 



HorsePCWhiteAnvil is the Object ID.

HorsePCWhiteAnvilRef is the Reference Editor ID.



let horseRef := GetPCLastHorse 
should return HorsePCWhiteAnvilRef (my last ridden horse)


if horseRef.GetIsID HorsePCWhiteAnvilRef 
<- doesn't work because I have to use an Object ID.


Then, if I use:
if horseRef.GetIsID HorsePCWhiteAnvil

HorsePCWhiteAnvil never matches horseRef because horseRef is Reference Editor ID (HorsePCWhiteAnvilRef) that is put in the world space.



Another try:
GetIsReference ReferenceIDReturns 1 if the calling object is the specified reference.As opposed to GetIsID, which checks against the base object ID as defined in the object window,this function takes a specific reference as a parameter. The reference must be persistent. 


if horseRef.GetIsReference HorsePCWhiteAnvilRef 
<- this should work. But it doesn't!


What's going on? Well, horseRef.GetIsReference seems to be treating HorsePCWhiteAnvil as the calling object instead of HorsePCWhiteAnvilRef, which is the reference I want to match against!



Another try:
[Ref.]GetBaseObjectReturns the base object of that reference.Notes:    * If Ref is a base object already, then calling BaseObjectRef.GetBaseObject will halt the script (quest scripts will show as still running but won't execute any more). 

let baseObj := horseRef.GetBaseObject

(In this case, should return HorsePCWhiteAnvil)


if baseObj.GetIsID HorsePCWhiteAnvil 
<- this freezes the script and I don't know why again...


It is being very frustrating to handle these peculiarities...
User avatar
NAkeshIa BENNETT
 
Posts: 3519
Joined: Fri Jun 16, 2006 12:23 pm

Post » Thu Jul 22, 2010 9:19 am

You're using too many functions where you just need to test for equality.

GetPCLastHorse returns a refid, so you can just compare it to the one you have. The appropriate test is
let horseRef := GetPCLastHorseif ( horseRef == HorsePCWhiteAnvilRef )


or in your last test where you get the base id
if ( baseObj == HorsePCWhiteAnvil )


However, there's a subtle difference between these results. The first test is saying "is this the exact same instance of this item?" and the second is asking "is this a copy of the same base object?" If there are multiple instance of HorsePCWhiteAnvil in the game, it's significant which test you use.
User avatar
Shiarra Curtis
 
Posts: 3393
Joined: Thu Jan 04, 2007 3:22 pm

Post » Wed Jul 21, 2010 11:37 pm

You're using too many functions where you just need to test for equality.

GetPCLastHorse returns a refid, so you can just compare it to the one you have. The appropriate test is
let horseRef := GetPCLastHorseif ( horseRef == HorsePCWhiteAnvilRef )


or in your last test where you get the base id
if ( baseObj == HorsePCWhiteAnvil )


However, there's a subtle difference between these results. The first test is saying "is this the exact same instance of this item?" and the second is asking "is this a copy of the same base object?" If there are multiple instance of HorsePCWhiteAnvil in the game, it's significant which test you use.


Thanks, but that is exactly where I started. Check OP.

Basicaly, yeah, "is this the exact same instance of this item?" is what I want.

Can anyone help?
User avatar
Donald Richards
 
Posts: 3378
Joined: Sat Jun 30, 2007 3:59 am

Post » Thu Jul 22, 2010 3:48 am

Did you say it works when not on the horse, but doesn't when mounted?
User avatar
Cayal
 
Posts: 3398
Joined: Tue Jan 30, 2007 6:24 pm

Post » Thu Jul 22, 2010 2:37 am

I mount the horse to make the script register the reference. Or, I can just select it in a menu but that's not the point.

The point is that I have a horse, for this example, AnvilWhite.

However, I can't make the script in the OP acknowledge the Ref. It returns negative and I can't do anything. I'm lost here because I don't understand it :sad:


Edit:
http://www.tesnexus.com/downloads/file.php?id=21862 to the rescue.

Result: I had been playing with a horse that is not the vanilla horse. Mods... eheh


if (varRef.GetIsReference otherRef) works as intended.


Case closed :)
User avatar
Jesus Lopez
 
Posts: 3508
Joined: Thu Aug 16, 2007 10:16 pm


Return to IV - Oblivion