Script review, please...

Post » Tue Aug 23, 2011 10:43 am

This script...

Elseif sChoosing == 2		MessageBoxEX "Torch Brightness Options %rBrightness Increments Index: %.0f %rCurrent Brightness: %.0f|Increase Increments|Increase Brightness|Decrease Brightness|Back", aaaMalonnDropLitTorches.lBrightIncr, lCurrentBrightness		Set sChoosing to -2		Set sChoice to -1	Elseif sChoosing == -2		Set sChoice to GetButtonPressed		If sChoice == -1			Return		Elseif sChoice == 0			Set aaaMalonnDropLitTorches.lBrightIncr to aaaMalonnDropLitTorches.lBrightIncr + 10			Set sChoosing to 2		Elseif sChoice == 1			If sTorchOnce == 0				Set l2LightRadius to l2LightRadius + lCurrentBrightness				Set sTorchOnce to 1			Else				Set l3LightRadius to l2LightRadius + aaaMalonnDropLitTorches.lBrightIncr			Endif			SetLightRadius l3LightRadius Torch02			Set sChoosing to 2		Elseif sChoice == 2			If sTorchOnce2 == 0				Set l4LightRadius to l4LightRadius + lCurrentBrightness				Set sTorchOnce2 to 1			Else				Set l3LightRadius to l4LightRadius - aaaMalonnDropLitTorches.lBrightIncr			Endif			SetLightRadius l3LightRadius Torch02			Set sChoosing to 2		Elseif sChoice == 3			Set sChoosing to 1		Endif	Endif


...isn't doing what I want it to. I'm trying to make torches brighter by using a menu. Problem is, when pressing button 1, the torch radius resets, and then the next time I pres the button it gets brighter the way it should. Then, if I press the button again, nothing happens. If I press button 3, the torch light radius is subtracted one time. If I press Button 3 any more, nothing happens. I can then toggle back and forth between adding and subtracting torch light radius, but that's it. Nothing happens beyond that. Any idea why? The script looks solid to me. I'm at a loss.
User avatar
Hilm Music
 
Posts: 3357
Joined: Wed Jun 06, 2007 9:36 pm

Post » Tue Aug 23, 2011 10:40 am

Your coding is way more complex than you need it to, with a few logical errors here and there. Why use more than two variables (the increment rate and the current brightness)? With that you get something like:
Elseif sChoosing == 2                MessageBoxEX "Torch Brightness Options %rBrightness Increments Index: %.0f %rCurrent Brightness: %.0f|Increase Increments|Increase Brightness|Decrease Brightness|Back", aaaMalonnDropLitTorches.lBrightIncr, lCurrentBrightness                Set sChoosing to -2                Set sChoice to -1        Elseif sChoosing == -2                Set sChoice to GetButtonPressed                If sChoice == -1                        Return                Elseif sChoice == 0                        Set aaaMalonnDropLitTorches.lBrightIncr to aaaMalonnDropLitTorches.lBrightIncr + 10                        Set sChoosing to 2                Elseif sChoice == 1                        Set lCurrentBrightness to lCurrentBrightness + aaaMalonnDropLitTorches.lBrightIncr                        SetLightRadius lCurrentBrightness Torch02                        Set sChoosing to 2                Elseif sChoice == 2			Set lCurrentBrightness to lCurrentBrightness + aaaMalonnDropLitTorches.lBrightIncr                        SetLightRadius CurrentBrightness Torch02                        Set sChoosing to 2                Elseif sChoice == 3                        Set sChoosing to 1                Endif        Endif

User avatar
Vivien
 
Posts: 3530
Joined: Fri Apr 13, 2007 2:47 pm

Post » Tue Aug 23, 2011 2:02 am

Ah, okay. I see. Well, that's why you can script extremely complex mods (like HUD Status Bars), and I can't (yet :smile: ).

Thanks, TNO.
User avatar
Adam Kriner
 
Posts: 3448
Joined: Mon Aug 06, 2007 2:30 am

Post » Tue Aug 23, 2011 12:10 pm

Alright, TNO. Your above changes work perfectly. Thanks again. Now, let me ask you...

Let avModifyLightColor[0] := avCurrentColor[0] + 20SetLightRGB avModifyLightColor Torch02


...why doesn't that work. The first element is an array to set the light RGB values. The second is an array to get the light RGB values. When I apply that formula, nothing happens. Any idea why?
User avatar
T. tacks Rims
 
Posts: 3447
Joined: Wed Oct 10, 2007 10:35 am

Post » Tue Aug 23, 2011 10:16 am

The above doesn't work, but neither does this:
(display a little more of the script to help grasp what I'm striving to accomplish)

Let avModifyLightColor := Ar_Construct ArrayLet avCurrentColor := Ar_Construct ArrayLet avCurrentColor := GetLightRGB Torch02Let lCurrentRed := avCurrentColor[0]Let lCurrentGreen := avCurrentColor[1]Let lCurrentBlue := avCurrentColor[2]


Initializing the arrays

Elseif sChoosing == 3	MessageBoxEX "Torch Light Coloration Options %rRed Component: %.0f %rGreen Component: %.0f %rBlue Component %.0f|Increase Red|Decrease Red|Increase Green|Decrease Green|Increase Blue|Decrease Blue|Back", lCurrentRed, lCurrentGreen, lCurrentBlue	Set sChoosing to -3	Set sChoice to -1Elseif sChoosing == -3	Set sChoice to GetButtonPressed	If sChoice == -1		Return	Elseif sChoice == 0		Let avModifyLightColor[0] := 20 		SetLightRGB avModifyLightColor Torch02		Set sChoosing to 3


Just simply attempting to modify the red component of the torch light. But nothing happens during runtime. There are absolutely no color changes to the light.
User avatar
Emmi Coolahan
 
Posts: 3335
Joined: Wed Jan 24, 2007 9:14 pm


Return to IV - Oblivion

cron