Difference between revisions of "Talk:MessageBox Tutorial"
m
→Missing statement in examples
imported>ShadowDancer (more accurate about FPS) |
imported>HawkFest |
||
(22 intermediate revisions by 3 users not shown) | |||
Line 131: | Line 131: | ||
'' ElseIf (Timer > 0) | '' ElseIf (Timer > 0) | ||
'' Set Timer to Timer - GetSecondsPassed | '' Set Timer to Timer - GetSecondsPassed | ||
'' ElseIf (Timer < | '' ElseIf (Timer < 0) | ||
'' StopMagicShaderVisuals ;place effect shader Editor ID here i.e. effectEnchantMysticism | '' StopMagicShaderVisuals ;place effect shader Editor ID here i.e. effectEnchantMysticism | ||
'' Player.Dispel ;place spell Editor ID using script here i.e. SplMenuVariables | '' Set Timer to 0 | ||
'' Player.Dispel ;place spell's Editor ID using script here i.e. SplMenuVariables | |||
'' EndIf | '' EndIf | ||
Line 139: | Line 140: | ||
End | End | ||
''Begin ScriptEffectFinish | |||
''End | |||
::::::The things I would add are the italicized sections and just remove the ScriptEffectFinish block. Setting the Duration on the spell to 30 should give someone more than enough time to make a choice on a smaller menu and to even flip between menus. If the menus are more complex requiring more time, just raise the Duration of the spell to give them more time. Any change that clicking the button does can be done when the GetButtonPressed returns a value. The Dispel will get rid of the active spell and no worries about a spell hanging there doing nothing. | ::::::The things I would add are the italicized sections and just remove the ScriptEffectFinish block. Setting the Duration on the spell to 30 should give someone more than enough time to make a choice on a smaller menu and to even flip between menus. If the menus are more complex requiring more time, just raise the Duration of the spell to give them more time. Any change that clicking the button does can be done when the GetButtonPressed returns a value. The Dispel will get rid of the active spell and no worries about a spell hanging there doing nothing. | ||
Line 256: | Line 260: | ||
::Well, some of these I can answer right off the top of my head, and can make reasoned guesses at some others although they will need confirmation. ScriptEffectUpdate does not operate in MenuMode. MenuMode will put any normally written spell on hold - ScriptEffectStart, ScriptEffectUpdate, and ScriptEffectFinish all pause in MenuMode. ScriptEffectUpdate is somewhat odd and I am not exactly sure why. It is like GameMode and yet isn't like GameMode, at least thats how it appeared to be with effect shaders - I am not sure if that has to do with how the effect shaders work or not, since I have never tried running the same test with a GameMode block (no it wasn't at 7 FPS, it was more like 20ish). Yes, you can use a GameMode block in a spell script, and as far as I know, it acts like a regular normal GameMode block. Effect shaders should be tested with a GameMode block to see if the results turn out the same as they do in a ScriptEffectUpdate block; should probably be tested together in one script. I am not positive about the MenuMode block, but I am pretty sure that it will also run inside of a MagicEffect script - that will need testing to confirm. I believe that it is possible to cast a spell from a MenuMode block, but that it won't initialize until exiting MenuMode when written in standard format - also needs testing. I am off to start some of these tests. | ::Well, some of these I can answer right off the top of my head, and can make reasoned guesses at some others although they will need confirmation. ScriptEffectUpdate does not operate in MenuMode. MenuMode will put any normally written spell on hold - ScriptEffectStart, ScriptEffectUpdate, and ScriptEffectFinish all pause in MenuMode. ScriptEffectUpdate is somewhat odd and I am not exactly sure why. It is like GameMode and yet isn't like GameMode, at least thats how it appeared to be with effect shaders - I am not sure if that has to do with how the effect shaders work or not, since I have never tried running the same test with a GameMode block (no it wasn't at 7 FPS, it was more like 20ish). Yes, you can use a GameMode block in a spell script, and as far as I know, it acts like a regular normal GameMode block. Effect shaders should be tested with a GameMode block to see if the results turn out the same as they do in a ScriptEffectUpdate block; should probably be tested together in one script. I am not positive about the MenuMode block, but I am pretty sure that it will also run inside of a MagicEffect script - that will need testing to confirm. I believe that it is possible to cast a spell from a MenuMode block, but that it won't initialize until exiting MenuMode when written in standard format - also needs testing. I am off to start some of these tests. | ||
::--[[User:ShadowDancer|ShadowDancer]] 14:09, 28 August 2007 (EDT) | ::--[[User:ShadowDancer|ShadowDancer]] 14:09, 28 August 2007 (EDT) | ||
:::Well, some interesting results showed up. Some of my earlier information is apparently wrong. Using pretty much the same script as before, I got the following results: | |||
Spell cast @ 20 FPS (was the easiest FPS to achieve multiple times) | |||
0 Duration = 3 cycles | |||
1 Duration = 18 cycles | |||
2 Duration = 36 cycles | |||
3 Duration = 56-58 cycles (which is a bump I noticed the first time testing this) | |||
:::But the cycles are consistant up until you hit the Duration of 3. To my surprise, MenuMode will not work from a Magic Effect script. GameMode and ScriptEffectUpdate produce the same number of cycles inside of the script with approximately 18-20 FPS (according to ATI) while the effect shader is running (apparently its closer to 18 and increases as the effect shader continues longer than 2 seconds). Based on this latest test, it leads me to believe that the ScriptEffectUpdate runs when the ScriptEffectStart is initialized, runs once just for the ScriptEffectUpdate, and once when the ScriptEffectFinish is run at minimum duration (of 0). I am going to try a test now to determine if the ScriptEffectUpdate will run before the ScriptEffectStart if I place it above that in the script. | |||
:::--[[User:ShadowDancer|ShadowDancer]] 15:26, 28 August 2007 (EDT) | |||
::::Yes, those numbers make more sense. So ScriptEffectUpdate is every frame, or at least as often as GameMode (I kind-of wonder if the FPS shown is wrong, or if GameMode doesn't run every frame, but not too much) | |||
::::--[[User:Haama|Haama]] 11:50, 29 August 2007 (EDT) | |||
::::OK, this result is <u>really</u> weird. A MessageBox in a ScriptEffectUpdate before a GameMode block will stop the GameMode block from running <u>at all</u> with a zero duration (ScriptEffectUpdate still cycles 3 times though). If the GameMode block is first, it will run <u>once</u> with a zero duration and the spell will go through its full routine (with three passes through the ScriptEffectUpdate block). Once a non-zero duration is included, the GameMode count will be 1 less than the ScriptEffectUpdate count (regardless of script order). | |||
::::If the GameMode block has the MessageBox (no MessageBox in the ScriptEffectUpdate block), it will cycle once, while the spell goes through the full spell at zero duration (including 3 ScriptEffectUpdate cycles). If there is a non-zero duration to the spell, the GameMode count will still be 1 less than the ScriptEffectUpdate count with the same script. Moving the GameMode block to before or after the ScriptEffectUpdate block has no effect in this case (zero or non-zero duration). | |||
::::The ScriptEffectUpdate block will run before the ScriptEffectStart block when placed before it in the script. Apparently this block runs whenever the script is cycled, no matter where it is placed. | |||
Base Script: | |||
<pre>Scriptname SCTrialEffect | |||
Short SEUCount | |||
Short GMCount | |||
Begin ScriptEffectStart | |||
Player.PlayMagicShaderVisuals effectAtronachFlame | |||
Message "Spell Started" | |||
End | |||
Begin ScriptEffectUpdate | |||
Set SEUCount to SEUCount + 1 | |||
End | |||
Begin GameMode | |||
Set GMCount to GMCount + 1 | |||
If GMCount == 1 | |||
MessageBox "Count = 1" | |||
EndIf | |||
End | |||
Begin ScriptEffectFinish | |||
Player.StopMagicShaderVisuals effectAtronachFlame | |||
MessageBox "ScriptEffectUpdate Count = %3.0f <br> GameMode Count = %3.0f", SEUCount, GMCount | |||
End</pre> | |||
::::--[[User:ShadowDancer|ShadowDancer]] 16:32, 28 August 2007 (EDT) | |||
:::::I wonder what happens if you use printc instead of messagebox? Will the message be displayed once, or multiple times? | |||
:::::--[[User:Haama|Haama]] 11:50, 29 August 2007 (EDT) | |||
:::::A spell can be cast while in MenuMode from a MenuMode script. It doesn't start the Magic Effect script until the player has exited MenuMode. Even a zero duration spell won't start running until back in GameMode. | |||
:::::--[[User:ShadowDancer|ShadowDancer]] 03:29, 29 August 2007 (EDT) | |||
Ok, so if I understand this correctly, there's no way for the spell to start in MenuMode. I've noticed from Guidobot's Throwing Stars 3 that a MenuMode block will run from a magic script (at least for potions), but he said it will only run for a single frame. | |||
Ok, so that also means that spell menus can only be used from GameMode (not bad, but it's still a point). This also means that there will always be passing time between menus, so the spell must be recast if time runs out. | |||
--[[User:Haama|Haama]] 11:50, 29 August 2007 (EDT) | |||
---- | |||
Haama, out of curiosity, why do you have so many | |||
If (Choice == -1) ;No choice yet | |||
Set Choice to GetButtonPressed | |||
statements in the script? If you use a couple more '''If''' statements, you could just put one of those in and remove that '''If''' statement from each of the additional menu sections. I don't even think you need to use an '''If''' statement with '''GetButtonPressed''' to begin with. | |||
--[[User:ShadowDancer|ShadowDancer]] 05:59, 29 August 2007 (EDT) | |||
:See [[MessageBox_Tutorial#Running_the_same_choice_for_multiple_frames]]. It's rare, but I've needed to do it, and I've had to answer a couple of threads on it. | |||
:--[[User:Haama|Haama]] 11:50, 29 August 2007 (EDT) | |||
:Lots of rewrites. It should be much easier to understand the original cases and reasons for each part of the script now. I've also left a much clearer place to place alternatives (spells, token scripts, quest scripts, etc.). | |||
:Since no one has brought up problems with the Poison Equipper mod, I'll switch over to using SetAtStart rather than moving the activator back to the XMarker. I'll give that a little while longer, but so far so good. | |||
:--[[User:Haama|Haama]] 13:03, 29 August 2007 (EDT) | |||
== Missing statement in examples == | |||
All examples used to illustrate an activator menu (section 4.5 and following) are missing a Return statement: | |||
If Working | |||
If (Choosing == 0) | |||
.... | |||
Set Working to 0 | |||
.... | |||
'''[[Return]]''' | |||
Elseif (Choosing == -1) | |||
.... | |||
Elseif (Choosing == 1) | |||
.... | |||
Elseif (Choosing == -10) | |||
.... | |||
Elseif (Choosing == 10) | |||
... | |||
Endif | |||
Set Working to 1 | |||
Endif | |||
Otherwise, setting Choosing to 0 will NOT provide for Working to be reset to 0 at the end of the script, since Working will anyways get set back to 1 after the if block. | |||
No [[Return]] statement would imply that after a first activation (menu use), Working stays set to 1, and a bunch of "if-elseif" will from then on get evaluated in GameMode block, while not using the Activator. Or, it will continuously check for Choosing == 0, set Working to 0 and then reset Working to 1... | |||
<small><font color=white>I wonder what would happen if this activator is then moved back to a remote cell, to see if the engine would make its script keep on going into ModeBlocks (since a ''set'' variable instruction within the first ''if'' block will always fires up the script for he next frame... But I guess that the activator would have to get activated in its remote cell via an ''Activate player,1'' instruction for the later to take place - when the activator is unloaded, the end of script keeps Working set to 1... I dunno).</font></small> | |||
--[[User:HawkFest|HawkFest]] 11:16, 24 December 2007 (EST) | |||
:Thanks Hawkfest. (I think) I've fixed them all, even the ones on the sub-pages. Instead of the return, I moved the '''set Working to 1''' line up top, so it can be set to 0 below. (Oops, thought I had fixed that long ago)--[[User:Haama|Haama]] 11:12, 24 December 2007 (EST) | |||
::I can see that you too you don't like [[Return]] statements too much..;p --[[User:HawkFest|HawkFest]] 11:26, 24 December 2007 (EST) |