Script trouble

Post » Sun Feb 07, 2010 1:42 pm

Hi there. Having trouble getting this script here to work. Its activated in the dialogue via Startscript.
-----
begin 0HP_Mountainstage1

short daysPassed

if ( GetPCCell "Solstheim, Hvitkald Peak: Gamlin's cave" == 0 )
if ( daysPassed > 5 )
Journal HP_IceTomb 10
endif
endif
endif

End
----

Additionally its meant to activate this script in turn =
-----

begin 0HP_TyrsWarning

short doOnce
short GetDisabled

if ( GetDisabled == 0 )
if ( GetJournalIndex HP_IceTomb = 10 )
Enable
endif
endif

if ( GetDisabled == 0 )
if ( GetJournalIndex HP_IceTomb < 10 )
Disable
endif
endif

if ( GetDisabled == 0 )
if ( GetJournalIndex HP_IceTomb > 20 )
Disable
endif
endif

if ( doOnce == 0 )
if ( GetDistance Player < 200 )
if ( GetJournalIndex HP_IceTomb = 10 )
ForceGreeting
set doOnce to 1
endif
endif
endif

end 0HP_TyrsWarning
---

I know that the first script isn't working and I want to run the second by scripters anyway
User avatar
Amanda Furtado
 
Posts: 3454
Joined: Fri Dec 15, 2006 4:22 pm

Post » Sun Feb 07, 2010 9:21 am

There seems to be an extra endIf in the first script...
User avatar
Pawel Platek
 
Posts: 3489
Joined: Sat May 26, 2007 2:08 pm

Post » Sun Feb 07, 2010 10:09 am

To keep code indentation, pleas use the "Insert Code Snuppet" button (the one with the <> icon in the editor.
begin 0HP_Mountainstage1; short daysPassed  ; this is a global variable updated by Tribunal or better engine, you do not have to declare it else this local same named variable ; with a starting value of 0 will be used insteadif ( GetJournalIndex "HP_IceTomb" < 10 )	if ( GetPCCell "Solstheim, Hvitkald Peak: Gamlin's cave" == 0 )		if ( daysPassed > 5 )			Journal HP_IceTomb 10			; endif  ; extra endif commented		endif	endif	endifEnd

I know that the first script isn't working and I want to run the second by scripters anyway
Care to translate this sentence a bit?
User avatar
Amelia Pritchard
 
Posts: 3445
Joined: Mon Jul 24, 2006 2:40 am

Post » Sun Feb 07, 2010 7:18 am

To keep code indentation, pleas use the "Insert Code Snuppet" button (the one with the <> icon in the editor.
begin 0HP_Mountainstage1; short daysPassed  ; this is a global variable updated by Tribunal or better engine, you do not have to declare it else this local same named variable ; with a starting value of 0 will be used insteadif ( GetJournalIndex "HP_IceTomb" < 10 )	if ( GetPCCell "Solstheim, Hvitkald Peak: Gamlin's cave" == 0 )		if ( daysPassed > 5 )			Journal HP_IceTomb 10			; endif  ; extra endif commented		endif	endif	endifEnd

Care to translate this sentence a bit?



thanks I'll try this script and I meant I included a second script that I wasn't sure about (as it is activated by this first one) so I want to see if people more experience in scripts see any problems with it?
User avatar
Jynx Anthropic
 
Posts: 3352
Joined: Fri Sep 08, 2006 9:36 pm

Post » Sun Feb 07, 2010 4:55 pm

It looks ok, but I've made a few changes:
  • GetDisabled is a function, so you don't need to (and shouldn't) declare it as a variable
  • I'm guessing the first section should be when GetDisabled == 1, rather than 0, as you're Enabling the object
  • Sections with the same condition (GetDisabled == 0) can be merged
  • This can then be merged with the section with the opposite condition (GetDisabled == 1) using elseif.
  • You need a double equals when you're checking if GetJournalIndex equals a specific value.

Reformatted and tweaked:

begin 0HP_TyrsWarning		short doOnce		if ( GetDisabled == 1 )		if ( GetJournalIndex HP_IceTomb == 10 )			Enable		endif	else		if ( GetJournalIndex HP_IceTomb < 10 )			Disable		elseif ( GetJournalIndex HP_IceTomb > 20 )			Disable		endif	endif		if ( doOnce == 0 )		if ( GetDistance Player < 200 )			if ( GetJournalIndex HP_IceTomb == 10 )				ForceGreeting				set doOnce to 1			endif		endif	endif	end 0HP_TyrsWarning

User avatar
Sarah Unwin
 
Posts: 3413
Joined: Tue Aug 01, 2006 10:31 pm


Return to III - Morrowind