Code Reference Issue

Post » Tue Sep 21, 2010 4:52 pm

below is a line of code on a stone slab to move it out of the way when the state of the linked reference is set to one. I had hoped to use this script to create a daisy chain effect but when I try to save the the script that the 'state' is and unknown function or variable.

So have I done something wrong or is this method just not supported by the language?

scn avadoormainLshort statefloat mvref parbegin onloadset par to getlinkedrefendbegin gamemodeif par.state == 1set mv to getpos Y + 5if mv > -42set state to 1endifif mv < 80setpos Y mvelsesetpos Y 80endifelseset mv to getpos  Y - 5if mv < 50set state to 0endifif mv > -72setpos Y mvelsesetpos Y -72endifendifend

User avatar
N3T4
 
Posts: 3428
Joined: Wed Aug 08, 2007 8:36 pm

Post » Tue Sep 21, 2010 9:35 pm

Are your stone slabs set to be persistent references? Anything that you want to reference from another object must be a persistent reference.
User avatar
ONLY ME!!!!
 
Posts: 3479
Joined: Tue Aug 28, 2007 12:16 pm

Post » Wed Sep 22, 2010 12:17 am

Yes they are all persistent reference.
User avatar
Abel Vazquez
 
Posts: 3334
Joined: Tue Aug 14, 2007 12:25 am

Post » Tue Sep 21, 2010 6:14 pm

set par to getlinkedref
...
par.state == 1

Can you do that? If you're using state in the same script, I think it should just be "state" - not "par.state". Or if each object has it's own script with "state" defined in it and you're trying to get another objects state from the posted script, I don't think you can do it with getlinkedref - or at least I've never been able to get it to work. I've had to use the ref's id (myRefsRealRefId.state), can you get a remote variable with getlinkedref?

Edit: or GetSelf?
User avatar
Charlotte Lloyd-Jones
 
Posts: 3345
Joined: Fri Jun 30, 2006 4:53 pm

Post » Tue Sep 21, 2010 9:40 pm

As I said it is a series of activators with the same script so it is trying to retrieve the 'state' of it's parent (par).

Well as I had feared it is beginning to become clear that getlinkedref is not able to retrieve variables which is strange since as you said (myRefsRealRefId.state) works and I would have imagined that the game would handle the id's the same way.
User avatar
MISS KEEP UR
 
Posts: 3384
Joined: Sat Aug 26, 2006 6:26 am

Post » Wed Sep 22, 2010 3:48 am

If your hearts set on a single script, you could probably do something like:
short state ; i'm local to this refif GetIsReference myRefsRealRefId01 == 1 ; i'm the 1st object if myRefsRealRefId02.state != state ; or something (same as: myRefsRealRefId02.state != myRefsRealRefId01.state)elseif GetIsReference myRefsRealRefId02 == 1 ; i'm the 2nd object if myRefsRealRefId01.state != state ; or something (same as: myRefsRealRefId01.state != myRefsRealRefId02.state); etc...endif

There might be a better way though.
User avatar
Karen anwyn Green
 
Posts: 3448
Joined: Thu Jun 15, 2006 4:26 pm

Post » Tue Sep 21, 2010 9:32 pm

Double post, sorry. :(
User avatar
Javaun Thompson
 
Posts: 3397
Joined: Fri Sep 21, 2007 10:28 am

Post » Tue Sep 21, 2010 12:45 pm

Ok thanks for the help the whole point was the simplicity of the script thus your method would sort of defeat the purpose of using the one script.

Have resorted to an alternative level design to bypass this issue for now but sure to come up to it again in the future.
User avatar
Breanna Van Dijk
 
Posts: 3384
Joined: Mon Mar 12, 2007 2:18 pm

Post » Tue Sep 21, 2010 7:41 pm

You can never get a variable by using a reference created in a script, it has to be a reference id assigned in the editor. The script won't compile because the reference doesn't exist until it is set in game. Since scripts run only one at a time you could use a quest variable, check if it's 0, preform and action then set it to 1. The script would check like this...
short MyVarif MyVar == 0if MyQuest.Var1 == 0  ;do something    set MyVar to 1  ;maybe use a timer before setting the next variable until the moving is completed. if you do you will need  to  set MyQuest.var to -1 while the timer runs  set MyQuest.var to 1 elseif MyQuest.Var1 == 1  ;do something  set MyVar to 1  set MyQuest.var to 2


I'm not sure how scripts are ordered to be processed, if it's random, or if its done using the editor ID. If is uses the ID then you could set up the chain to use that order.
User avatar
Emerald Dreams
 
Posts: 3376
Joined: Sun Jan 07, 2007 2:52 pm

Post » Tue Sep 21, 2010 6:55 pm

As mentioned before, remote variable syntax (location.varName) only works with editorIDs, and will not work with "ref" variables. If you need to store remotely accessible information on a reference that isn't predetermined, the easiest way is often to use a token, but that only works for actors and containers. With other types of reference, you could try using some other information, like the scale of the reference, depending on what you can change safely.

Cipscis
User avatar
RObert loVes MOmmy
 
Posts: 3432
Joined: Fri Dec 08, 2006 10:12 am


Return to Fallout 3