Difference between revisions of "Talk:MessageBox Tutorial"
m
→Missing statement in examples
imported>DragoonWraith (ShadowDancer, please explain) |
imported>HawkFest |
||
(28 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 237: | Line 241: | ||
:::::::OK, now I'm very confused. Why would not want to store the results of a menu? Or, if you do, just drop the information, this would work just fine. ShadowDancer, I really don't understand what you want from this tutorial, and I ''really'' don't understand '''why''' you would want a MessageBox menu in anything but an Activator. What purpose does that serve? What is complicated about this script that you would remove? Yes, menu scripts are complicated, but that's what they are. I don't see how you can simplify it while still asking questions of the player and getting answers. Please explain what you mean, and ''please'' explain what possible situation might be better served by a menu in a spell than in an activator triggered by spell. | :::::::OK, now I'm very confused. Why would not want to store the results of a menu? Or, if you do, just drop the information, this would work just fine. ShadowDancer, I really don't understand what you want from this tutorial, and I ''really'' don't understand '''why''' you would want a MessageBox menu in anything but an Activator. What purpose does that serve? What is complicated about this script that you would remove? Yes, menu scripts are complicated, but that's what they are. I don't see how you can simplify it while still asking questions of the player and getting answers. Please explain what you mean, and ''please'' explain what possible situation might be better served by a menu in a spell than in an activator triggered by spell. | ||
:::::::[[User:DragoonWraith|<span style="font-family: Oblivion, Daedric Runes; size=2;">D</span>ragoon <span style="font-family: Oblivion, Daedric Runes; size=2;">W</span>raith]] [[User_talk:DragoonWraith|<span style="font-family: Oblivion, Daedric Runes; size=2;">TALK</span>]] 18:17, 27 August 2007 (EDT) | :::::::[[User:DragoonWraith|<span style="font-family: Oblivion, Daedric Runes; size=2;">D</span>ragoon <span style="font-family: Oblivion, Daedric Runes; size=2;">W</span>raith]] [[User_talk:DragoonWraith|<span style="font-family: Oblivion, Daedric Runes; size=2;">TALK</span>]] 18:17, 27 August 2007 (EDT) | ||
(Back to the left) First off, let me say that I didn't do more than skim this tutorial originally since I was looking to help Raziel23x out with his spell script. It just so happens that this came into play at the same time that this tutorial was marked as possibly containing misinformation. Since Haama had written that he hadn't seen multiple menus done in a spell script, I added a spell script that worked multiple menus via the MessageBox function. Additionally, since I was working with Raziel23x's script, I went pretty much to the scripts to look at the coding being fairly competent with scripts. So yes, this whole mess is my fault. However, aside from that, what I am trying to say is that this isn't really a '''MessageBox''' tutorial, its a '''MessageBox Menu System and Variable Storage''' tutorial. | |||
I suspect that if there had been a simplified version of how to set up multiple menus using the MessageBox function in a Magic Effect script that Raziel23x probably wouldn't have had to ask for help with it. I even had trouble looking through the scripts trying to seperate out what wasn't necessary and apply it to a spell script - the real problem ended up being an active return statement (If Choice == -1 ==> Return). To this end, I think that a Multi-Menu tutorial using MessageBox is probably something that would be useful with a demonstration of how to do it in different ways, i.e. Activators, Spells, etc. so that if someone needs help figuring out how to do it, they don't have to come to a tutorial that isn't set up for it just because its the closest thing that will help them. If you look at what Raziel23x was doing, it was either use a multiple menu or else write 20+ seperate spells. I personally would have done the same thing Raziel23x originally did; made multiple menus in a single spell. I did something similar with the ''Alter Weather'' spell that I made a while ago in that I allowed the caster to choose the weather type from a menu when the spell is cast rather than writing 7 seperate spells for each weather type in Tamriel. I didn't feel that the seperate weather types warranted 7 seperate spells when one spell could do all of them (it also cuts down on clutter in the spell list). The difference being that mine didn't need multiple menus for the spell where as Raziel23x's script did. ''This'' is where a menu in a spell serves better than an activator - because you don't need to drag the activator out and deal with it and then put it away again when just casting a simple spell. You just handle the choice and the consequences internally in the spell. | |||
Likewise, there are other things that don't require variables to be stored when using multiple menus for different choices. To that end, I think it would be wise to show people how to just make multiple menus for what they wish to do. I also agree that there are times when one might want to store variables choosen from multiple menus. Hence my suggestions above. A tutorial to create multiple menus. Another tutorial (or the same one if you like, though it would be necessarily longer) to show how to take those multiple menu systems and store the variables. The current tutorial didn't show how to set up multiple menus just for the sake of creating multiple menus and demonstrate them before introducing the activator, and the information in the article didn't lend well to a spell script that needs a menu to make a choice about the spell being cast. Which is what I was originally trying to suggest - a menu in a spell that doesn't store variables - because I hadn't paid much attention to the tutorial other than that it talked about creating multiple menus. | |||
--[[User:ShadowDancer|ShadowDancer]] 23:51, 27 August 2007 (EDT) | |||
:While I agree a piecemeal approach works (and is desirable) for most topics, I don't feel the same with messageboxes. Before I posted this tutorial, there were a couple of simple examples floating around (I think there was even a generator), that most would use as a base. While the scripts worked when things were kept simple, they didn't work once the script became more complex. There were quite a few threads and people asking for help, who had started out with the simple scripts, and, getting tired of pointing out the same 3 things, I wrote the tutorial - hoping that an all-purpose menu script would prevent people from running into the same errors whenever they want their menus to do something slightly different. | |||
:I see what you mean about the returns. I need to think about them for a bit, but I don't think they're needed. | |||
:Hmm... trying to write the spell advantages and disadvantages - 3 questions: Will a ScriptEffectStart work from MenuMode? Will the GameMode or MenuMode blocks run in a spell (and if so, how many times)? How often does the ScriptEffectUpdate run (from the discussion on that article, it seems like it's not every frame, at least I hope the test wasn't at 7 FPS)? | |||
:--[[User:Haama|Haama]] 12:19, 28 August 2007 (EDT) | |||
::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) | |||
:::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) |