Random script problem

Post » Sat Aug 08, 2009 8:17 pm

I find that this script works fine for me, but other players sometimes report that this sliding bookcase stops working completely. Is there any way I can optimize this script to make it work properly for everyone? The script is attached to an activator, and the objects it moves are statics. References persist is checked for all of them, and they're all unique objects.

begin Uvi_Open_bookcase_switch; Like a normal bookcase, but moves when you have the keyshort Movingfloat Timershort toggleSoundShort StartPosShort StartPos2if ( MenuMode == 1 )	returnendifIf ( StartPos == 0 )	Set StartPos to ( "slidingbookcase"->GetPos, z )	Set StartPos2 to ( "in_t_platform_mov01"->GetPos, z )Endifif ( OnActivate == 1 )	if ( player->GetItemCount "key_teluvirith" > 0 )		if ( Moving == 0 )			set Moving to 1			set toggleSound to 0		elseif ( Moving == 2 )			set Moving to 3			set toggleSound to 0		endif	else		MessageBox "You need the Tel Uvirith Key to activate this switch."		return	endifendif; Moving states:; 0  At rest in 'set' (covering door) position; 1  Moving from 'set' to 'open'; 2  At rest in 'open' (revealing door) position; 3  Moving from 'open' to 'set'if ( Moving == 0 )	"slidingbookcase"->SetPos, z, StartPos	"in_t_platform_mov01"->SetPos, z, StartPos2	returnelseif ( Moving == 2 )	"slidingbookcase"->SetPos, z, -1578	"in_t_platform_mov01"->SetPos, z, -1690	returnelseif ( Moving == 1 )	if ( toggleSound == 0 )		PlaySound "Door Stone Close"		set toggleSound to 1	endif	"slidingbookcase"->MoveWorld Z, 75	"in_t_platform_mov01"->MoveWorld Z, 75elseif ( Moving == 3 )	if ( toggleSound == 0 )		PlaySound "Door Stone Close"		set toggleSound to 1	endif	"slidingbookcase"->MoveWorld Z, -75	"in_t_platform_mov01"->MoveWorld Z, -75endifif ( Timer > 3 )	set Timer to 0	if ( Moving == 1 )		set Moving to 2	else		set Moving to 0	endif	returnendifset Timer to ( Timer + GetSecondsPassed )end

User avatar
tannis
 
Posts: 3446
Joined: Sat Dec 09, 2006 11:21 pm

Post » Sat Aug 08, 2009 8:59 pm

I don't think i'll be able to help but i'll give what little experience i already know to try and help. My first question is what are the variables startpos and starpos2 did you make those up?

The reason I ask is because I was writing a script earlier and i set up a couple global variables one was called "SM_Tourney" and the other was called "SM_Tourney2" and what happened was when ever i set the global variable "SM_Tourney2" the script would seem to think i was calling for the global fariable "SM_Tourney" like it didn't take into account the 2 at the end it seemed a little buggy so i changed the second global variable to something different and it actually fixed my problem. I don't know if that is your problem though. If anything my advice will probably confuse you more since my advice won't solve your problem .Like i said i'm a noobie scripter but just trying to help with what little experience I have.
User avatar
Nicholas
 
Posts: 3454
Joined: Wed Jul 04, 2007 12:05 am

Post » Sat Aug 08, 2009 10:48 pm

Not the problem but StartPos, StartPos2 should be floats.


You could also get the user to send you their save. They may have doubling issues which may be moving only one of the bookcases :shrug:
User avatar
mishionary
 
Posts: 3414
Joined: Tue Feb 20, 2007 6:19 am

Post » Sun Aug 09, 2009 11:40 am

Not the problem but StartPos, StartPos2 should be floats.


You could also get the user to send you their save. They may have doubling issues which may be moving only one of the bookcases :shrug:


Ah, it could be a doubling issue indeed, since the script works for most people with no issue. I really should change those variables to floats though. It works fine as it is, but it's a good idea anyway.
User avatar
Mrs. Patton
 
Posts: 3418
Joined: Fri Jan 26, 2007 8:00 am

Post » Sun Aug 09, 2009 3:48 am

I really should change those variables to floats though. It works fine as it is, but it's a good idea anyway.

It would only be an issue really if you ended up reusing the script in areas where the object was placed more than 215-1 units from the origin
User avatar
Eduardo Rosas
 
Posts: 3381
Joined: Thu Oct 18, 2007 3:15 pm

Post » Sun Aug 09, 2009 1:45 am

Ah ok. Good to know. :)
User avatar
ezra
 
Posts: 3510
Joined: Sun Aug 12, 2007 6:40 pm

Post » Sun Aug 09, 2009 7:06 am

Untested , but maybe containing a couple of efficiency hints
begin Uvi_Open_bookcase_switch; Like a normal bookcase, but moves when you have the keyshort Movingfloat Timershort toggleSoundShort StartPosShort StartPos2if ( MenuMode == 1 )	returnendifIf ( StartPos == 0 )	Set StartPos to ( "slidingbookcase"->GetPos, z )	Set StartPos2 to ( "in_t_platform_mov01"->GetPos, z )Endifif ( OnActivate == 1 )	if ( player->GetItemCount "key_teluvirith" > 0 )		if ( Moving == 0 )			set Moving to 1			PlaySound "Door Stone Close"		elseif ( Moving == 2 )			set Moving to 3			PlaySound "Door Stone Close"		endif	else		MessageBox "You need the Tel Uvirith Key to activate this switch."		return	endifendif; Moving states:; 0  At rest in 'set' (covering door) position; 1  Moving from 'set' to 'open'; 2  At rest in 'open' (revealing door) position; 3  Moving from 'open' to 'set'if ( moving == 0 )	returnelseif ( moving == 2 )	returnelseif ( Moving == 1 )	"slidingbookcase"->MoveWorld Z, 75	"in_t_platform_mov01"->MoveWorld Z, 75elseif ( Moving == 3 )	"slidingbookcase"->MoveWorld Z, -75	"in_t_platform_mov01"->MoveWorld Z, -75else	return ; to skip timer when unneeded endifif ( Timer < 3 )	set Timer to ( Timer + GetSecondsPassed )	returnendifset Timer to 0if ( Moving == 1 ) 	"slidingbookcase"->SetPos, z, -1578	"in_t_platform_mov01"->SetPos, z, -1690	set moving to 2   ; do onceelse	"slidingbookcase"->SetPos, z, StartPos	"in_t_platform_mov01"->SetPos, z, StartPos2	set moving to 0   ; do onceendifend
[edit]typo
User avatar
sarah taylor
 
Posts: 3490
Joined: Thu Nov 16, 2006 3:36 pm


Return to III - Morrowind

cron