Double MessageBoxes

Post » Mon Jun 18, 2012 5:09 am

I look for a bit of help, for a very simple script :

Scriptname AASSQuestScript extends QuestMessage Property AASSMessage00 Auto ; MessageBox with 3 choicesMessage Property AASSMessage01 Auto ; Message 1 (Notification)Message Property AASSMessage02 Auto ; Message 2 (Notification)Message Property AASSMessage03 Auto ; Message 3 (Notification)Int Property Version Autoint InitEVENT OnInit()RegisterForUpdate(5)EndEVENTEVENT OnUpdate()if ( Init == 0 )	 RegisterForUpdate(1)	 AASSMessage00.Show()	 Init += 1elseif ( Init == 1 )	 Version = AASSMessage00.Show()	 if ( Version == 0 )		  AASSMessage01.Show()		  Init += 1	 elseif ( Version == 1 )		  AASSMessage02.Show()		  Init += 1	 elseif ( Version == 2 )		  AASSMessage03.Show()		  Init += 1	 endifendifEndEVENT

The problem is that the MessageBox (AASSMessage00) appears twice; the first time i click on one of the 3 options and it does nothing, then the box shows again and this time when i click the options it works, the others messages are displayed.

In the CS this script would be the same in GameMode excepted that you would use GetButtonPressed. Can someone tell me what i'm doing wrong ?
User avatar
Stacey Mason
 
Posts: 3350
Joined: Wed Nov 08, 2006 6:18 am

Post » Mon Jun 18, 2012 7:56 am

Your script is running again before Init is set to 1
To fix move the Init += 1 to be the first thing in that condition, or you could use states.
See threading notes: http://www.creationkit.com/Threading_Notes_(Papyrus)
and states: http://www.creationkit.com/States_(Papyrus)
User avatar
Yung Prince
 
Posts: 3373
Joined: Thu Oct 11, 2007 10:45 pm

Post » Mon Jun 18, 2012 9:17 am

That is exactly what your code says to do. Tell us what you expect your code to do and perhaps someone can give you a rewrite.
User avatar
Alex Vincent
 
Posts: 3514
Joined: Thu Jun 28, 2007 9:31 pm

Post » Mon Jun 18, 2012 9:29 am

Aye, on second look it is kind of convoluted :blink: you could probably get rid of the first block of that if(init == 1) and use if(init == 0)
User avatar
C.L.U.T.C.H
 
Posts: 3385
Joined: Tue Aug 14, 2007 6:23 pm

Post » Mon Jun 18, 2012 3:05 am

I made a script similar to what you're trying to do, although it's meant for 4 messages that are all connected, so it's a fair bit longer. It's also activated by a trigger.

But it all worked for me as far as I could tell.

There's two parts, the first script which contains the function, and the seconds script which tells it to run and contains the properties


I made a script similar to what you're trying to do, although it's meant for 4 messages that are all connected, so it's a fair bit longer.

There's two parts, the first script which contains the function, and the seconds script which tells it to run and contains the properties

Spoiler

Scriptname FunctionTestScriptBase extends ObjectReference  function DisplayBaseMessage(Message baseMessage, Message subMessage1, Message subMessage2, Message subMessage3)int ibutton = baseMessage.Show()If ibutton == 0DisplaySubMessage1(baseMessage, subMessage1, subMessage2, subMessage3)ElseIf ibutton == 1DisplaySubMessage2(baseMessage, subMessage1, subMessage2, subMessage3)ElseIf ibutton == 2DisplaySubMessage3(baseMessage, subMessage1, subMessage2, subMessage3)ElseEndIfEndFunctionfunction DisplaySubMessage1(Message baseMessage, Message subMessage1, Message subMessage2, Message subMessage3)int ibutton = subMessage1.Show()If ibutton == 0DisplayBaseMessage(baseMessage, subMessage1, subMessage2, subMessage3)ElseIf ibutton == 1DisplaySubMessage2(baseMessage, subMessage1, subMessage2, subMessage3)ElseIf ibutton == 2DisplaySubMessage3(baseMessage, subMessage1, subMessage2, subMessage3)ElseEndIfEndFunctionfunction DisplaySubMessage2(Message baseMessage, Message subMessage1, Message subMessage2, Message subMessage3)int ibutton = subMessage2.Show()If ibutton == 0DisplayBaseMessage(baseMessage, subMessage1, subMessage2, subMessage3)ElseIf ibutton == 1DisplaySubMessage1(baseMessage, subMessage1, subMessage2, subMessage3)ElseIf ibutton == 2DisplaySubMessage3(baseMessage, subMessage1, subMessage2, subMessage3)ElseEndIfEndFunctionfunction DisplaySubMessage3(Message baseMessage, Message subMessage1, Message subMessage2, Message subMessage3)int ibutton = subMessage3.Show()If ibutton == 0DisplayBaseMessage(baseMessage, subMessage1, subMessage2, subMessage3)ElseIf ibutton == 1DisplaySubMessage1(baseMessage, subMessage1, subMessage2, subMessage3)ElseIf ibutton == 2DisplaySubMessage2(baseMessage, subMessage1, subMessage2, subMessage3)ElseEndIfEndFunction

Spoiler

Scriptname FunctionTestScriptRun extends FunctionTestScriptBase  Message Property messageToShow AutoMessage Property buttonMessage1 AutoMessage Property buttonMessage2 AutoMessage Property buttonMessage3 AutoEvent OnTriggerEnter(ObjectReference akActionRef)DisplayBaseMessage(messageToShow, buttonMessage1, buttonMessage2, buttonMessage3)EndEvent
User avatar
Nicole Coucopoulos
 
Posts: 3484
Joined: Fri Feb 23, 2007 4:09 am

Post » Mon Jun 18, 2012 1:00 am

Your script is running again before Init is set to 1
To fix move the Init += 1 to be the first thing in that condition, or you could use states.
So i've tried that, but it has not fixed the problem. But i found that a line under the Box.Show is not read until i exit the Box.

That is exactly what your code says to do. Tell us what you expect your code to do and perhaps someone can give you a rewrite.
Player gets a MessageBox with 3 choices, after he clicks on one, a message (notification) confirms his choice.

Aye, on second look it is kind of convoluted :blink: you could probably get rid of the first block of that if(init == 1) and use if(init == 0)
I've tried to put all the lines under the if ( Init == 0 ) with only one int variable change, but it doesn't work properly. The box shows once, but i must click two times on an option to exit the Box.

I made a script similar to what you're trying to do, although it's meant for 4 messages that are all connected, so it's a fair bit longer. It's also activated by a trigger.

But it all worked for me as far as I could tell.

There's two parts, the first script which contains the function, and the seconds script which tells it to run and contains the properties


I made a script similar to what you're trying to do, although it's meant for 4 messages that are all connected, so it's a fair bit longer.

There's two parts, the first script which contains the function, and the seconds script which tells it to run and contains the properties

Spoiler

Scriptname FunctionTestScriptBase extends ObjectReference  function DisplayBaseMessage(Message baseMessage, Message subMessage1, Message subMessage2, Message subMessage3)int ibutton = baseMessage.Show()If ibutton == 0DisplaySubMessage1(baseMessage, subMessage1, subMessage2, subMessage3)ElseIf ibutton == 1DisplaySubMessage2(baseMessage, subMessage1, subMessage2, subMessage3)ElseIf ibutton == 2DisplaySubMessage3(baseMessage, subMessage1, subMessage2, subMessage3)ElseEndIfEndFunctionfunction DisplaySubMessage1(Message baseMessage, Message subMessage1, Message subMessage2, Message subMessage3)int ibutton = subMessage1.Show()If ibutton == 0DisplayBaseMessage(baseMessage, subMessage1, subMessage2, subMessage3)ElseIf ibutton == 1DisplaySubMessage2(baseMessage, subMessage1, subMessage2, subMessage3)ElseIf ibutton == 2DisplaySubMessage3(baseMessage, subMessage1, subMessage2, subMessage3)ElseEndIfEndFunctionfunction DisplaySubMessage2(Message baseMessage, Message subMessage1, Message subMessage2, Message subMessage3)int ibutton = subMessage2.Show()If ibutton == 0DisplayBaseMessage(baseMessage, subMessage1, subMessage2, subMessage3)ElseIf ibutton == 1DisplaySubMessage1(baseMessage, subMessage1, subMessage2, subMessage3)ElseIf ibutton == 2DisplaySubMessage3(baseMessage, subMessage1, subMessage2, subMessage3)ElseEndIfEndFunctionfunction DisplaySubMessage3(Message baseMessage, Message subMessage1, Message subMessage2, Message subMessage3)int ibutton = subMessage3.Show()If ibutton == 0DisplayBaseMessage(baseMessage, subMessage1, subMessage2, subMessage3)ElseIf ibutton == 1DisplaySubMessage1(baseMessage, subMessage1, subMessage2, subMessage3)ElseIf ibutton == 2DisplaySubMessage2(baseMessage, subMessage1, subMessage2, subMessage3)ElseEndIfEndFunction

Spoiler

Scriptname FunctionTestScriptRun extends FunctionTestScriptBase  Message Property messageToShow AutoMessage Property buttonMessage1 AutoMessage Property buttonMessage2 AutoMessage Property buttonMessage3 AutoEvent OnTriggerEnter(ObjectReference akActionRef)DisplayBaseMessage(messageToShow, buttonMessage1, buttonMessage2, buttonMessage3)EndEvent
Okay, i will see that and have a try at it.

I've too edited the OP, to make things clearer.
User avatar
Connor Wing
 
Posts: 3465
Joined: Wed Jun 20, 2007 1:22 am

Post » Mon Jun 18, 2012 8:06 am

Fixed ! It was just because this line :

Version = AASSMessage00.Show()

shows the box too, so the first (AASSMessage00.Show()) is not needed. Good to know.
User avatar
Arrogant SId
 
Posts: 3366
Joined: Sat May 19, 2007 11:39 am


Return to V - Skyrim