Jump to content

Scripting noob, need help


62firelight

Recommended Posts

Hey, I am going to release a update to my mod here and I was wondering if someone could help me with scripting. I am a scripting newbie and scripting confuses me at times, I am trying to have one of those Mages' Guild portals in the home and when you activate it, it will come up with a message box saying "The tingly feeling of the portal touches you and it makes you think, where do I go?" and the PC has a choice of 'Chorrol Mages' Guild' or "Bravil Mages' Guild". If the PC selects the respective options, he/she will be teleported to a XMarker placed there. Like if the PC picks Chorrol Mages' Guild, he/she will teleport to the XMarker placed there. But I have a bug, and it's an embarrassing one. When the PC selects one of the options, it works like it should, but pressing the "Continue" button makes it repeat the Message Box again. After a day of trying to figure it out, I have gave up and felt the need to ask for help. As said in the thread title, scripting confuses me and I am a noob at scripting. Now here is the script.

 

Scriptname 62RavenspirePortalwhereto

ref ravenchorrol

ref ravenbravil

 

short Ravencontrolvar

short Ravenbutton

 

Begin OnActivate

; When you activate object, it will popup a message box.

If ( ravencontrolvar == 0 )

MessageBox "The tingly feeling of the portal touches you and it makes you think, where do I go?" "Chorrol Mages Guild" "Bravil Mages Guild"

set ravencontrolvar to 1

set ravenbutton to getbuttonpressed

;messagebox is displayed, options are displayed and ravencontrolvar set to 1

Activate

endif

endif

end

 

Begin GameMode

If ( ravencontrolvar == 1 )

Set ravenbutton to GetButtonPressed

If ( ravenbutton == -1 )

return

elseif ( ravenbutton == 0 )

MessageBox "As you fade away, you see...the Chorrol Mages Guild."

playsound splalterationcast

player.moveto ravenchorrol

;scripting is so confusing

endif

elseif ( ravenbutton == 1 )

MessageBox "As you fade away, you see...the Bravil Mages Guild."

playsound splalterationcast

player.moveto ravenbravil

endif

;as you can see, the pc teleports to the bravil mages guild xmarker when the messagebox ends.

endif

endif

end

 

 

Thanks in advance. :)

 

(Noticed the semicolon comment "Scripting is so confusing" lol)

Link to comment
Share on other sites

I think it's missing the "escape clause" - until Ravencontrolvar is reset to zero, the script will run over and over and over again. It also has a few nesting errors.

 

Scriptname 62RavenspirePortalwhereto
ref ravenchorrol
ref ravenbravil

short Ravencontrolvar
short Ravenbutton

Begin OnActivate

; When you activate object, it will popup a message box.
If ( ravencontrolvar == 0 )
	MessageBox "The tingly feeling of the portal touches you and it makes you think, where do I go?" "Chorrol Mages Guild" "Bravil Mages Guild" 
	set ravencontrolvar to 1
	set ravenbutton to getbuttonpressed
	;messagebox is displayed, options are displayed and ravencontrolvar set to 1
	Activate
endif
;endif <------------ This looks like an extra and shouldn't be there

end

Begin GameMode

If ( ravencontrolvar == 1 ) 
	Set ravenbutton to GetButtonPressed
	If ( ravenbutton == -1 )
		return
	elseif  ( ravenbutton == 0 )
		MessageBox "As you fade away, you see...the Chorrol Mages Guild." 
		playsound splalterationcast
		player.moveto ravenchorrol
		;scripting is so confusing

	;endif <------------ This shouldn't be there

	elseif ( ravenbutton == 1 )
		MessageBox "As you fade away, you see...the Bravil Mages Guild."
		playsound splalterationcast
		player.moveto ravenbravil

;----------------- ESCAPE CLAUSE ; i.e. a button was pressed, but it wasn't a 0 or a 1... ----------------------

	else
		set ravencontrolvar to 0

;--------------------------------------------- END ESCAPE CLAUSE -----------------------------------------------------------


	endif
;as you can see, the pc teleports to the bravil mages guild xmarker when the messagebox ends.
endif  

;endif <------------ Again, this looks like an extra and shouldn't be there  

end

 

Also, the script name begins with a number and this can cause lots of problems. I suggest renaming it to start with a letter instead.

 

HTH

Link to comment
Share on other sites

Try this one now... that "escape clause" in the last post was supposed to be for the "Cancel" option which I just noticed you didn't have. I've added it to the new script, but you can take it back out if you want.

 

Scriptname AARavenspirePortalwhereto
ref ravenchorrol
ref ravenbravil

short Ravencontrolvar
short Ravenbutton

Begin OnActivate

; When you activate object, it will popup a message box.
If ( ravencontrolvar == 0 )
	MessageBox "The tingly feeling of the portal touches you and it makes you think, where do I go?" "Chorrol Mages Guild" "Bravil Mages Guild" "Cancel"	; <------- Added third option
	set ravencontrolvar to 1
	set ravenbutton to getbuttonpressed
	;messagebox is displayed, options are displayed and ravencontrolvar set to 1
	Activate
endif

end

Begin GameMode

If ( ravencontrolvar == 1 ) 
	Set ravenbutton to GetButtonPressed
	If ( ravenbutton == -1 )
		return
	elseif  ( ravenbutton == 0 )
		MessageBox "As you fade away, you see...the Chorrol Mages Guild." 
		playsound splalterationcast
		player.moveto ravenchorrol

		set ravencontrolvar to 0	; <------- Added

		;scripting is so confusing

	elseif ( ravenbutton == 1 )
		MessageBox "As you fade away, you see...the Bravil Mages Guild."
		playsound splalterationcast
		player.moveto ravenbravil

		set ravencontrolvar to 0	; <------- Added

	else
		set ravencontrolvar to 0

	endif
	;as you can see, the pc teleports to the bravil mages guild xmarker when the messagebox ends.
endif  

end

Link to comment
Share on other sites

Strange..I copied the script from your post and it would still repeat the MessageBox. Also when I click the option "Bravil Mages' Guild" and continue, it will then start popping up the Chorrol Mages' Guild MessageBox. I'm not sure if it's just my ignorance, XMarker placings or something wrong in the script but it doesn't seem to work. :confused:
Link to comment
Share on other sites

Do'h! I just remembered something...

 

From the wiki:

If (MoveTo) is used to move the player, it will also act as a Return function -- no following lines of the script will be processed.

 

So moving the two set ravencontrolvar to 0 bits up one line to above the MoveTo commands will make it work. I've actually made a test esp and checked that it now works as intended. The below script was copied and pasted from my test esp. (Since I don't have your mods installed, I had to set the references to something so remember to remove them.) :)

 

 

Scriptname AARavenspirePortalwhereto
ref ravenchorrol
ref ravenbravil

short Ravencontrolvar
short Ravenbutton

Begin OnActivate


set ravenchorrol to MQ05BaurusFollowedPauseMarker	;<--- Remove this
set ravenbravil to MQ05BaurusStage72	;<--- Remove this

; When you activate object, it will popup a message box.
If ( ravencontrolvar == 0 )
	MessageBox "The tingly feeling of the portal touches you and it makes you think, where do I go?" "Chorrol Mages Guild" "Bravil Mages Guild" "Cancel"	; <------- Added third option
	set ravencontrolvar to 1
	set ravenbutton to getbuttonpressed
	;messagebox is displayed, options are displayed and ravencontrolvar set to 1
	Activate
endif

end

Begin GameMode

If ( ravencontrolvar == 1 ) 
	Set ravenbutton to GetButtonPressed
	If ( ravenbutton == -1 )
		return
	elseif  ( ravenbutton == 0 )
		MessageBox "As you fade away, you see...the Chorrol Mages Guild." 
		playsound splalterationcast
		set ravencontrolvar to 0	; <------- Added
		player.moveto ravenchorrol

		;scripting is so confusing

	elseif ( ravenbutton == 1 )
		MessageBox "As you fade away, you see...the Bravil Mages Guild."
		playsound splalterationcast
		set ravencontrolvar to 0	; <------- Added
		player.moveto ravenbravil

	else
		set ravencontrolvar to 0

	endif
	;as you can see, the pc teleports to the bravil mages guild xmarker when the messagebox ends.
endif  

end

 

Link to comment
Share on other sites

Yes! It works as intended but one more problem. It won't teleport to the XMarker placed at the Guilds. (Link removed)

(I used Dropbox to upload the files)

 

 

Scriptname AARavenspirePortalwhereto
ref RavenChorrol
ref RavenBravil

short Ravencontrolvar
short Ravenbutton

Begin OnActivate

       ; When you activate object, it will popup a message box.
       If ( ravencontrolvar == 0 )
               MessageBox "The tingly feeling of the portal touches you and it makes you think, where do I go?" "Chorrol Mages Guild" "Bravil Mages Guild" "Cancel"    ; <------- Added third option
               set ravencontrolvar to 1
               set ravenbutton to getbuttonpressed
               ;messagebox is displayed, options are displayed and ravencontrolvar set to 1
               Activate
       endif

end

Begin GameMode

       If ( ravencontrolvar == 1 ) 
               Set ravenbutton to GetButtonPressed
               If ( ravenbutton == -1 )
                       return
               elseif  ( ravenbutton == 0 )
                       MessageBox "As you fade away, you see...the Chorrol Mages Guild." 
                       set ravencontrolvar to 0
                       playsound splalterationcast
                       player.movetomarker RavenChorrol

                       ;scripting is so confusing

               elseif ( ravenbutton == 1 )
                       MessageBox "As you fade away, you see...the Bravil Mages Guild."
                       set ravencontrolvar to 0
                       playsound splalterationcast
                       player.movetomarker RavenBravil

               else
                       set ravencontrolvar to 0

               endif
               ;as you can see, the pc teleports to the bravil or chorrol mages guild xmarker when the messagebox ends.
       endif  

end

 

Edited by 62firelight
Link to comment
Share on other sites

You'll need to remove the two lines:

 

ref RavenChorrol

ref RavenBravil

 

By declaring them as reference variables, you are instructing the script to "Move the player to the object that I've stored in the variable RavenChorrol." instead of "Move the player to the object called RavenChorrol."

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...