OBSE Script problem

Post » Thu May 26, 2011 11:00 pm

This scirpt is making an OBSE error (into the log) when I put my crosshair over a reference that has one of the model paths listed.

- Removed -
User avatar
Chris Ellis
 
Posts: 3447
Joined: Thu Jul 26, 2007 10:00 am

Post » Fri May 27, 2011 10:28 am

Use eval with the condition that evaluates the model paths : if eval ( pathTemp == path1 || .. )
User avatar
Jordan Fletcher
 
Posts: 3355
Joined: Tue Oct 16, 2007 5:27 am

Post » Fri May 27, 2011 4:42 am

yep that fixed it. :)

Now I was wondering if you could help me make the next part of the script.
When everything is right and the script there run I want to add the reference to an array (which i can do), but when the cell its in resets (or at least the next time the player enters it after it has resets), i want t run reset3Dshape on it and remove it from the array.

Is this possible? if so can you show me how it would be done?
User avatar
Gill Mackin
 
Posts: 3384
Joined: Sat Dec 16, 2006 9:58 pm

Post » Fri May 27, 2011 12:30 am

Assuming you've got 2 parallel arrays for the holding the references to the objects and their cells,
if ( player.getParentCell == rLastCell )  ; --- evaluates true on cell change	 let rLastCell := player.getParentCell	 	 forEach aIterator <- aArray[ "cell" ]		  if eval ( *aIterator == rLastCell )			  let rRef := aArray[ "ref" ][ aIterator[ "key" ] ]			  rRef.reset3DShape			  let aRazorLog[ ar_Size aRazorLog ] := aIterator[ "key" ]  ; --- you'll need to queue each element for deletion		  endIf	 loop	 forEach aIterator <- aRazorLog		  ar_Erase aArray[ "ref" ] aIterator[ "key" ]		  ar_Erase aArray[ "cell" ] aIterator[ "key" ]	 loop	 ar_Erase aRazorLog 0:(( ar_Size aRazorLog ) - 1 )endIf
To call the code after a cell reset, you'll either need to track each cell's detach time ( more info in the command doc, under the cell functions section ) or add an activator as a watch dog that flags a variable in its script on reset ( you'll need to walk through the cell's activators, find yours, fetch the flag's value, evaluate and clear it )
User avatar
Karine laverre
 
Posts: 3439
Joined: Tue Mar 20, 2007 7:50 am

Post » Fri May 27, 2011 4:21 am

Ill be working on this more tomorrow but...

the first line of that:
if ( player.getParentCell == rLastCell )


shouldnt that be:
if ( player.getParentCell != rLastCell )


else from what i see it would never run...
User avatar
Miragel Ginza
 
Posts: 3502
Joined: Thu Dec 21, 2006 6:19 am

Post » Fri May 27, 2011 1:30 am

okay, looking at that I get totally confused....way too complicated for me...

but anyway i think I understand enough to do this, one question:
how do I assign the ref to one array and have it linking to the other....is it just linked by the number?


EDIT:
oh, it doesnt like this line:
		  if eval ( *aIterator == rLastCell )


EDIT2:
I want to use the activator to detect the cell reset, however how should i put the activator into the cell? I dont think placeatme would be good for it.
User avatar
Chris Duncan
 
Posts: 3471
Joined: Sun Jun 24, 2007 2:31 am

Post » Fri May 27, 2011 1:06 pm

okay, looking at that I get totally confused....way too complicated for me...

but anyway i think I understand enough to do this, one question:
how do I assign the ref to one array and have it linking to the other....is it just linked by the number?
Linking ? In what sense ?

EDIT:
oh, it doesnt like this line:
		  if eval ( *aIterator == rLastCell )
That's OBSE beta6 syntax in use. Make sure you're using the latest beta.

EDIT2:
I want to use the activator to detect the cell reset, however how should i put the activator into the cell? I dont think placeatme would be good for it.
True. The alternative would be to place one manually, which would be impractical. I guess I didn't think of it when I posted that as a plausible method.
User avatar
Star Dunkels Macmillan
 
Posts: 3421
Joined: Thu Aug 31, 2006 4:00 pm

Post » Fri May 27, 2011 9:06 am

okay, Ill do it the other way without activators.

okay, its getting cranky about this line now:
			  let rRef := RefArray[ "ref" ][ aIterator[ "key" ] ]


citing invalid operands for operator :=


EDIT: With the cell detatch time, a compare between it, the GetCellResetHours and current time be enough to find if i need to reset?
User avatar
Alyce Argabright
 
Posts: 3403
Joined: Mon Aug 20, 2007 8:11 pm

Post » Fri May 27, 2011 8:06 am

Is RefArray a valid string map array with the ref and cell arrays as its elements ? This is how you go about declaring such a structure :
let RefArray := ar_Construct stringMaplet refArray[ "ref" ] := ar_Construct arraylet refArray[ "cell" ] := ar_Construct array


EDIT: Yes. Info on http://obse.silverlock.org/obse_command_doc.html#Cell.
User avatar
Celestine Stardust
 
Posts: 3390
Joined: Fri Dec 01, 2006 11:22 pm

Post » Fri May 27, 2011 3:50 am

still same error...
User avatar
Amanda Leis
 
Posts: 3518
Joined: Sun Dec 24, 2006 1:57 am

Post » Thu May 26, 2011 11:19 pm

You'll have to populate the array first. Use getParentCell to save a reference of the cell you're in currently and then on cell change, add it (and its object ref) to the corresponding array(s).
User avatar
Vahpie
 
Posts: 3447
Joined: Sat Aug 26, 2006 5:07 pm

Post » Fri May 27, 2011 5:17 am

gah, i feel stupid asking all this...and I thank you for all the patients you are giving me with this.

I can seem to phrase it right to add the reference in on the on the first free slot....
User avatar
Sudah mati ini Keparat
 
Posts: 3605
Joined: Mon Jul 23, 2007 6:14 pm

Post » Fri May 27, 2011 12:22 am

let refArray[ "ref" ][ ar_Size refArray[ "ref" ] ] := rReflet refArray[ "ref" ][ ar_Size refArray[ "cell" ] ] := rCell

User avatar
Sxc-Mary
 
Posts: 3536
Joined: Wed Aug 23, 2006 12:53 pm

Post » Fri May 27, 2011 9:38 am

okay thats good now

one last thing, with the time, what does GetCellDetachTime return? and how can I get a corresponding time for the current time for the comparsion?\ ALl the funciton i find only return like the time of day, or day of the week...
User avatar
Matt Bee
 
Posts: 3441
Joined: Tue Jul 10, 2007 5:32 am

Post » Thu May 26, 2011 11:19 pm

It returns the number of game hours that had passed when you last exited a cell. You'll need to calculate the current value by using the gameDaysPassed and gameHours special global vars. TotalHoursPassed = 24 * daysPassed + gameHours
User avatar
Rhi Edwards
 
Posts: 3453
Joined: Fri Jul 28, 2006 1:42 am

Post » Fri May 27, 2011 10:26 am

okay its all done there...but its not working...

heres the current full script:
SCN DMCounterMeshSetshort doonceshort brokenref objectrefref counterrefref objectrefoldfloat fquestdelaytimestring_var path1string_var path2string_var path3string_var pathtemparray_var aRazorLogarray_var CellArrayarray_var aIteratorref rLastCellarray_var aRazorLogarray_var aIteratorarray_var RefArrayref rLastCellref rRefref rCellfloat resetdetachfloat resethoursfloat resettimeshort arraystartbegin gamemodeset fquestdelaytime to 0.1if doonce == 0	set doonce to 1	let path1 := "furniture\upperclass\uppercountermiddle02.nif"	let path2 := "furniture\upperclass\uppercounterend03.nif"	let path3 := "furniture\upperclass\uppercounterend04.nif"	let RefArray := ar_Construct stringMap	let refArray[ "ref" ] := ar_Construct array	let refArray[ "cell" ] := ar_Construct array	let aRazorLog := ar_Construct Arrayendifif broken == 0	set objectref to player.getcrosshairref	if objectref != objectrefold && objectref != 0		set objectrefold to objectref		if objectref.getdistance player <= 150 && (objectref.isactivatable == 0 || objectref.iscontainer == 1)			let pathtemp := objectref.getmodelpath			if eval (pathtemp == path1) || objectref.getmodelpath == path2 || objectref.getmodelpath == path3				set objectrefold to 0				if player.IsAnimGroupPlaying AttackLeft == 1 || player.IsAnimGroupPlaying AttackRight == 1 || player.IsAnimGroupPlaying AttackPower == 1					set broken to 1				endif			endif		endif	endifendifif broken == 1	objectref.playgroup forward 1	playsound CGlassMedium	set broken to 0	if arraystart == 0		set arraystart to 1	endif	 let rCell := player.getParentCell	let rRef := objectref	let refArray[ "ref" ][ ar_Size refArray[ "ref" ] ] := rRef	let refArray[ "ref" ][ ar_Size refArray[ "cell" ] ] := rCellendifif ( player.getParentCell != rLastCell ) && arraystart == 1	 let rLastCell := player.getParentCell	set resetdetach to GetCellDetachTime rLastCell	set resettime to GetCellResetHours rLastCell	set resethours to ((gamedayspassed - resetdetach) * 24) + gamehour	 if resethours >= 72	 	forEach aIterator <- RefArray[ "cell" ]	 		 if eval ( *aIterator == rLastCell )	 			 let rRef := RefArray[ "ref" ][ aIterator[ "key" ] ]	 			 rRef.reset3DState	 			 let aRazorLog[ ar_Size aRazorLog ] := aIterator[ "key" ]	 		 endIf	 	loop		 forEach aIterator <- aRazorLog			  ar_Erase RefArray[ "ref" ] aIterator[ "key" ]			  ar_Erase RefArray[ "cell" ] aIterator[ "key" ]		 loop			 ar_Erase aRazorLog 0:(( ar_Size aRazorLog ) - 1 )	endifendifend


With a bit of testing I found the this line never goes (had a messagebox before and after it, the one after never shows)
	 	forEach aIterator <- RefArray[ "cell" ]

User avatar
Mimi BC
 
Posts: 3282
Joined: Sat Oct 07, 2006 10:30 pm

Post » Fri May 27, 2011 12:54 pm

With a bit of testing I found the this line never goes (had a messagebox before and after it, the one after never shows)
	 	forEach aIterator <- RefArray[ "cell" ]

If so, it means that RefArray[ "cell" ] doesn't exist or is empty. Try using
ar_Dump RefArray[ "cell" ]
or even
ar_Dump RefArray
to get a dump of what your arrays contain. It may help you a lot.


Edit: I took a look at your code, and think I found the reason that it is empty too. The line
let refArray[ "ref" ][ ar_Size refArray[ "cell" ] ] := rCell
should quite surely be
let refArray[ "cell" ][ ar_Size refArray[ "cell" ] ] := rCell

User avatar
Doniesha World
 
Posts: 3437
Joined: Sun Jan 07, 2007 5:12 pm

Post » Fri May 27, 2011 2:47 am

Yes, that was the problem, shademe must have made a copy error there.

Its working fine now, thanks :)
User avatar
John N
 
Posts: 3458
Joined: Sun Aug 26, 2007 5:11 pm

Post » Fri May 27, 2011 7:21 am

I feel horrible for asking all these questions...

But at the top i need to run a check on the array. if objectref (the reference it picks up) is in the array already I dont want it to run...I know Ive done this before (in anothe rscript), but can you explain again how I do this?
User avatar
Jessica Colville
 
Posts: 3349
Joined: Wed Oct 18, 2006 6:53 pm

Post » Fri May 27, 2011 4:13 am

How else did you think you'd learn :P

If you'd like to see if an element is present in an array, you do this : if eval ( ar_Find rRef refArray[ "ref" ] != -99999 ). ar_Find returns the key of the element you're looking for. If it can't find it, it returns -99999.
User avatar
Jah Allen
 
Posts: 3444
Joined: Wed Jan 24, 2007 2:09 am

Post » Fri May 27, 2011 2:30 am

well I tried it but it gave the error:

Invalid expression for parameter 2. Expected array.


Now looking at it, the array is correctly named in it...same with the variable Im looking for...

any ideas?


EDIT: this is the last thing before the mod is done.
User avatar
Emma Copeland
 
Posts: 3383
Joined: Sat Jul 01, 2006 12:37 am

Post » Fri May 27, 2011 8:48 am

well I tried it but it gave the error:

Invalid expression for parameter 2. Expected array.


Now looking at it, the array is correctly named in it...same with the variable Im looking for...

any ideas?
shadeMe's line seems correct to me, so I cannot tell what's wrong, but you could try to split it up just to separate the problem, ex:

let tmpArray := refArray[ "ref" ]; ar_Dump tmpArrayif eval (ar_Find rRef tmpArray >= 0)

Note that I added a outcommented ar_Dump. It can be useful, as it prints out the actual content of the array. Also note that I changed "!= -99999" to ">= 0". While a purely subjective view, I think checking for a legal index result is much more intuitive than checking for the one specific non-legal value.

Edit, if the error is still there, try to move the end paranthesis like this: if eval (ar_Find rRef tmpArray) >= 0. That way you make sure that the compiler doesn't think ">= 0" is a parameter for ar_Find.
User avatar
Neliel Kudoh
 
Posts: 3348
Joined: Thu Oct 26, 2006 2:39 am

Post » Fri May 27, 2011 9:22 am

Edit, if the error is still there, try to move the end paranthesis like this: if eval (ar_Find rRef tmpArray) >= 0. That way you make sure that the compiler doesn't think ">= 0" is a parameter for ar_Find.


all i just was move the ) and that fixed it.
User avatar
Lakyn Ellery
 
Posts: 3447
Joined: Sat Jan 27, 2007 1:02 pm


Return to IV - Oblivion