Help with menu template script

Post » Mon Jun 18, 2012 7:46 am

Been trying to get a very useful script to work I used quite often for Oblivion and the Fallouts, a menu template that used the message box to display choices, so when clicked on it would give you any number of useful commands.

After struggling (and finally succeeding) to even get a simple messagebox to appear, this is what I have so far:

Scriptname aaMenuTemplate extends ObjectReferenceMessage property box1 auto{Points to the message box that is shown on the first activation.}int countint choiceint chosenEvent OnActivate(ObjectReference akActionRef)	 count = count + 1	 GetMessage(count).Show()endEventMessage function GetMessage(int currentCount)	 Message chosenMessage		chosenMessage = box1		 Return chosenMessageendFunctionEvent GameMode(ObjectReference akActionRef)	if chosen		set choice GetButtonPressed		if choice > -1			set chosen to 0			if choice == 0		   	 (resulting code)			elseif choice == 1		   	 (resulting code)			elseif choice == 2		   	 (resulting code)			elseif choice == 3				return			endif		endif	endifendEvent

Well that doesn't work. Here is the errors produced:

.psc(28,13): required (...)+ loop did not match anything at input 'GetButtonPressed'
.psc(28,2): function variable choice already defined in the containing script
.psc(32,14): required (...)+ loop did not match anything at input 'to'
.psc(32,3): function variable chosen already defined in the containing script
.psc(32,14): no viable alternative at input 'to'

I don't fully understand these errors and what to do about them.
User avatar
gary lee
 
Posts: 3436
Joined: Tue Jul 03, 2007 7:49 pm

Post » Mon Jun 18, 2012 8:35 am

There is no getbuttonpressed any more. You need to define a message property and link it to your pre made message.

Then in your script you do myMessageBox.Show()

Where myMessageBox is the name of the message property you defined. It returns the index of the button they pressed.

For extremely simple info boxes just use Debug.MessageBox("Hello").

Also keep in mind that some idiot decided it would be best to have the message options lined up horizontally rather than vertically in a list so if you have too many they go off screen.
User avatar
RObert loVes MOmmy
 
Posts: 3432
Joined: Fri Dec 08, 2006 10:12 am

Post » Mon Jun 18, 2012 5:50 pm

Event OnActivate(ObjectReference akActivator)int ibutton = baseMessage.Show()If ibutton == 0    Debug.MessageBox("First button was pressed.)ElseIf ibutton == 1    Debug.MessageBox("Second button was pressed.)EndIfEndEvent

Is how I have a script laid out. Seems to work fine.
User avatar
Prue
 
Posts: 3425
Joined: Sun Feb 11, 2007 4:27 am

Post » Mon Jun 18, 2012 12:40 pm

I guess "to" isn't used anymore as that had the same error?

So far I find Papyrus needlessly confusing. Gonna take some getting used to.

Edit: ok thanks Neonox will give it a try. So I don't need the GameMode block?
User avatar
saharen beauty
 
Posts: 3456
Joined: Wed Nov 22, 2006 12:54 am

Post » Mon Jun 18, 2012 3:15 am

I didn't when I used it.

And yeah, "set * to" isn't used. They made it more like other languages. So now it's "int myInt = 5" to set it to 5, and "If myInt == 5" to check what it is. One equals sign sets the variable, two checks it.
User avatar
Shelby McDonald
 
Posts: 3497
Joined: Sat Jan 13, 2007 2:29 pm

Post » Mon Jun 18, 2012 7:16 am

Thanks Neonox, that worked.

One last question if I may. After battling with Papyrus for most of the day, I finally have a mod with working scripts. If was to upload it, would it need both the pex. file in the scripts folder and the PSC. file in the source folder? Or just one of those?
User avatar
Campbell
 
Posts: 3262
Joined: Tue Jun 05, 2007 8:54 am

Post » Mon Jun 18, 2012 6:01 am

No, you only need the compiled *.pex file.
User avatar
gemma king
 
Posts: 3523
Joined: Fri Feb 09, 2007 12:11 pm

Post » Mon Jun 18, 2012 3:47 pm

Thanks.

I may have been at it all day, but it was useful, I learned quite a bit. The new referencing and property system was also stumping me, the simple player.additem line won't work on it's own anymore will it. But asking on these forums, the wiki and Cipcis' site worked wonders. Thanks again all.
User avatar
Cagla Cali
 
Posts: 3431
Joined: Tue Apr 10, 2007 8:36 am


Return to V - Skyrim