Uh oh, scripting help again.

Post » Sun Sep 19, 2010 11:56 pm

Here's the script. Looks right to me... I made another script very similar to this that works perfectly.

If SLv.FPSsmoothing == 1	Set Choice to 1	Set Working to 1EndIfIf Choice == 0	Set Working to 0ElseIf Choice == 1 	MessageBoxEX "Streamsmooth is enabled.  Please disable it for FightSmoothing to function correctly. |Disable|Ok"	Set Choice to 2	Set ButtonPress to -1ElseIf Choice == 2	If ButtonPress == -1		Set ButtonPress to GetButtonPressed	ElseIf ButtonPress == 0		Set SLv.FPSsmoothing to SLv.FPSsmoothing == 0		Set Choice to 0	ElseIf ButtonPress == 1		Set Choice to 0	EndIfEndIf


The message box opens when it's supposed to, it's just that it doesn't close when it's supposed to. I have it written so that when you press any of the buttons in the message box, the menu should close. But it doesn't. Help, please.
User avatar
Zoe Ratcliffe
 
Posts: 3370
Joined: Mon Feb 19, 2007 12:45 am

Post » Sun Sep 19, 2010 11:26 pm

Here's an updated version of the script. This is just a excerpt from the script. There's more to it, but it's not related to the message box. The problem is still the same. The menu will not close.

Begin GameModeIf SLv.FPSsmoothing == 1	Set Choice to 1	Set Working to 1EndIfIf Working	Set Working to 1	If Choice == 0		Set Working to 0	ElseIf Choice == 1 		MessageBoxEX "Streamsmooth is enabled.  Please disable it for FightSmoothing to function correctly. |Disable|Ok"		Set Choice to 2		Set ButtonPress to -1	ElseIf Choice == 2 		If ButtonPress == -1			Set ButtonPress to GetButtonPressed		ElseIf ButtonPress == 0			Set SLv.FPSsmoothing to SLv.FPSsmoothing == 0			Set SLMainMenu.M to -1			Set Choice to 0		ElseIf ButtonPress == 1			Set Choice to 0			Set SLMainMenu.M to -1		EndIf	EndIfEndIf

User avatar
kiss my weasel
 
Posts: 3221
Joined: Tue Feb 20, 2007 9:08 am

Post » Mon Sep 20, 2010 4:46 am

Another minor change. But the menu still won't exit.

Begin GameModeIf SLv.FPSsmoothing == 1	Set Choice to 1	Set Working to 1	Set Run to 1EndIfIf Working	Set Working to 1	If Choice == 0		Set Working to 0	ElseIf Choice == 1		Set SLMainMenu.M to -1		MessageBoxEX "Streamsmooth is enabled.  Please disable it for FightSmoothing to function correctly. |Disable|Exit"		Set Choice to 2		Set ButtonPress to -1	ElseIf Choice == 2 		If ButtonPress == -1			Set ButtonPress to GetButtonPressed		ElseIf ButtonPress == 0			Set SLv.FPSsmoothing to SLv.FPSsmoothing == 0			Set Choice to 0		ElseIf ButtonPress == 1			Set Choice to 0		EndIf	EndIfEndIf

User avatar
roxanna matoorah
 
Posts: 3368
Joined: Fri Oct 13, 2006 6:01 am

Post » Mon Sep 20, 2010 12:53 am

Menus do exit when a button is clicked. If you think it doesn't, it is because you immediately open it again.

In your code above, when SLv.FPSsmoothing == 1 you set Choice to 1 every single frame, which again means that the "ElseIf Choice == 1" block is the one that gets called every single frame as well, and the "ElseIf Choice == 2" block never gets run, since Choice gets reset to 1 every frame.


But really, things like this would be very easy to spot if you took your time to add some debug messages. So the next time you get into a problem, I suggest you add "DebugPrint" or "PrintC" messages and see what your mod writes to the console. If you had taken one minute to add three different PrintC lines after each "(Else)If Choise", you would immediately have seen that the one beneath "ElseIf Choice == 1" would spam messages each frame.
User avatar
Adam Kriner
 
Posts: 3448
Joined: Mon Aug 06, 2007 2:30 am

Post » Mon Sep 20, 2010 2:18 pm

Menus do exit when a button is clicked. If you think it doesn't, it is because you immediately open it again.

In your code above, when SLv.FPSsmoothing == 1 you set Choice to 1 every single frame, which again means that the "ElseIf Choice == 1" block is the one that gets called every single frame as well, and the "ElseIf Choice == 2" block never gets run, since Choice gets reset to 1 every frame.


But really, things like this would be very easy to spot if you took your time to add some debug messages. So the next time you get into a problem, I suggest you add "DebugPrint" or "PrintC" messages and see what your mod writes to the console. If you had taken one minute to add three different PrintC lines after each "(Else)If Choise", you would immediately have seen that the one beneath "ElseIf Choice == 1" would spam messages each frame.


Okay. I'll add debug messages the next time I run into a problem. So I need to find a way to prevent the "ElseIf Choice" from returning 1 every frame? Great. Thanks fro your help. Again.
User avatar
Music Show
 
Posts: 3512
Joined: Sun Sep 09, 2007 10:53 am

Post » Mon Sep 20, 2010 1:14 pm

I'm a little confused. I understand what you said, and it makes sense. That's definitely the problem. I added some debug info and you're right. Choice is always being set to 1. But how do I circumvent this in the script. I'm having trouble figuring that out.
User avatar
benjamin corsini
 
Posts: 3411
Joined: Tue Jul 31, 2007 11:32 pm

Post » Mon Sep 20, 2010 7:30 am

I figured it out. It's not really 100% the way I want it to be, but it works.
User avatar
nath
 
Posts: 3463
Joined: Mon Jan 22, 2007 5:34 am

Post » Sun Sep 19, 2010 10:44 pm

I'm having trouble getting this script exactly the way I want it. Here's the script. You should be able to tell what I want it to do, but if not, I'll explain:

Begin GameModeIf SLv.FPSsmoothing == 1 && SLv.FightSmoothing == 1	Set Choice to 1	Set SLv.FPSsmoothing to SLv.FPSsmoothing == 0EndIfIf Choice == 0ElseIf Choice == 1	Set SLMainMenu.M to -1        MessageBoxEX "Streamsmooth was enabled.  That has been corrected |I Prefer Streamsmooth|Exit"		Set Choice to 2                Set ButtonPress to -1ElseIf Choice == 2         If ButtonPress == -1        	Set ButtonPress to GetButtonPressed        ElseIf ButtonPress == 0		Set SLv.FightSmoothing to SLv.FightSmoothing == 0		Set SLv.FPSsmoothing to SLv.FPSsmoothing == 1		Set Choice to 0	ElseIf ButtonPress == 1		Set Choice to 0		Set Working to 0	EndIfEndIf...


When you press "I prefer Streamsmooth", it should enable Streamsmooth, disable Fightsmooth and close the menu. It disables Fightsmooth. No problem there. But it doesn't enable Streamsmooth. That remains disabled. As of this writing, I haven't added any debugging options -- I'm going to do that now. But if the reason it isn't working correctly is obvious to anybody, please share. Thanks.
User avatar
Makenna Nomad
 
Posts: 3391
Joined: Tue Aug 29, 2006 10:05 pm

Post » Mon Sep 20, 2010 1:30 pm

Okay, after running some debugging commands, it seems that

ElseIf ButtonPress == 0                Set SLv.FightSmoothing to SLv.FightSmoothing == 0                Set SLv.FPSsmoothing to SLv.FPSsmoothing == 1


That command disables FightSmoothing, but doesn't enable FPSsmoothing. Why is that? Is it the nature of "GetButtonPressed"?
User avatar
CArlos BArrera
 
Posts: 3470
Joined: Wed Nov 21, 2007 3:26 am

Post » Mon Sep 20, 2010 3:22 am

What's happening is that your setting your variables as the result of a boolean condition.

For SLv.FightSmoothing, if it's currently enabled (i.e. set to 1), the condition SLv.FightSmoothing == 0 (1 == 0) evaluates to false, which equates to 0 when you assign it back to SLv.FightSmoothing, resulting in it being disabled.

For SLv.FPSsmoothing, it's currently disabled (so has the value 0), the condition SLv.FPSsmoothing == 1 (0 == 1) equates to false, which again is 0, so SLv.FPSsmoothing is just assigned 0 again, and remains disabled.

It sounds to me like all you need to do is

Set SLv.FightSmoothing to 0 ; disableSet SLv.FPSsmoothing to 1 ; enable


If you wish to toggle both variables (i.e. if 0 set to 1, if 1 set to 0), then use the == 0 for both like you've done with SLv.FightSmoothing.
User avatar
Travis
 
Posts: 3456
Joined: Wed Oct 24, 2007 1:57 am

Post » Mon Sep 20, 2010 11:35 am

Ahh, you are correct, sir. Thank you very much.
User avatar
Shianne Donato
 
Posts: 3422
Joined: Sat Aug 11, 2007 5:55 am


Return to IV - Oblivion