Jump to content

MessageBox, what am I doing wrong?


Recommended Posts

well ... :smile:

Zd,

for the sake of efficient communication

I think you should change a bit your behaviour before replying :wink:

if I give you some code,

you should try that first before asking another question. That safe me for the repeating explanation

and also as confirming token that you understand that, after experience it yourself

from this look ... this mean :

- you still have not tried my second code, because you already tried my first code and not solved ---> that means you need infinite loop menu (the second script)

- you still not have tried that 2 small chunks of code about menu limit (10) in message box, that's why you don't understand paging

 

paging is like this my friend ... this is from my BSS mod, it contains 3 page and 30 menu. each page can only contain 10 menu, that's why I make 3 pages

 

46719-0-1454136213.jpg

Edited by lubronbrons
Link to comment
Share on other sites

I am not even how I gave you that feeling, but sorry. I appreciate the help. However, I would like to understand why my code, that is from the tutorial, does not work before considering alternate solutions.

 

I am confused about paging because the original problem was about 6 options MessageBox from an activator script such that puts on the screen a message of the button pressed. Nothing more, nothing less.

Where did you get the idea of the need of paging?

 

I referred to the tutorial, that according to your messages is pretty much crap. I think this is another source of misunderstanding because I was assuming to be fairly correct.

 

 

Anyway, I DO NOT want to create more annoyance. Consider the topic closed.

Link to comment
Share on other sites

OK

understood,

 

anyway

you remind me of Maskar ... a week ago when I tried give him a solution, and I even wrote him the code (imho is better and solve the 'general' issue about RemoveMe)

he repulse it

somehow this little event is reminiscing that...

Now I've learnt something again

being helpful is not always good, hmm...

now there is more people that should I not care about when comes to scripting :unsure:

 

EDIT : quote " I referred to the tutorial, that according to your messages is pretty much crap "

yes that article should get update, the code in that example is not efficient enough or even close to give the user easy-to-use chunk of code ...

Edited by lubronbrons
Link to comment
Share on other sites

Did you try something like the script I suggested? Something like that should work. Feel free to add in enough MessageBoxes to keep track of what is and what is not run in the script.

 

The issue (the one mentioned in the tutorial) is that GameMode blocks are run each frame on activators, but not run at all when the activator is not loaded, for example if the activator is in another cell. The workarounds seem to address this issue.

 

How are you "activating" the activator? Assuming it is a remote one, do you use a spell to activate it? If you do, you can add the messagebox to the spell effect script and it will work wonders with no issues activators have. Of course it will not have the benefits that activators have, either, but those can be worked around with a quest or something else that can store variables.

 

Here is another one, I have not tested it, but just to give an idea on how to achieve a menu with a spell. Sort of.

ScriptName YourMenuSpellEffectScript

Short Skip
Short Button

Begin ScriptEffectStart

    MessageBox "Pick one" "one" "two" "three"

End

Begin ScriptEffectUpdate

    If ( Skip )
        Return
    EndIf

    set Button to GetButtonPressed

    If ( Button < 0 || Button > 2 )
        Return
    EndIf

    set Skip to 1

    If ( Button == 0 )
        PlayerRef.AddItem F 100
        MessageBox "That's the way!"
    Else
        MessageBox "Whoo-ops. Read it again!"
    EndIf

End

Just add in as many MessageBoxes as you can to track stuff. You can also print to console if you want, at least OBSE offers some fine commands to do it, such as DebugPrint combined with SetDebugMode.

SetDebugMode 1 ; toggle debug printings on or off, now they are on
DebugPrint "YourPrefix: Variable == %.2f" variableName

Hopefully that helps. Maybe it is something small that is causing the issue. The best place to hide is in plain sight. :P

Link to comment
Share on other sites

The issue (the one mentioned in the tutorial) is that GameMode blocks are run each frame on activators, but not run at all when the activator is not loaded, for example if the activator is in another cell. The workarounds seem to address this issue.

 

Hopefully that helps. Maybe it is something small that is causing the issue. The best place to hide is in plain sight. :tongue:

Well said. The problem is really subtle. The remote activator scripts die after one frame of doing nothing and that is the reason in the tutorial they reset the Working variable over and over again. It is a way to ensure the script "do something" and keep running.

 

The problem is that when the menu box is open the game is not in GameMode, the game is in MenuMode. So after a frame of MenuMode of awaiting the player, since the script is doing nothing the game engine stops it.

 

Solution, just ensure the script continue running even in MenuMode.

 

Begin MenuMode
  if Working == 1
     Set Working to 1
  endIf
End
You can activate the activator (eheh) with this script line:

YourActivatorsReferenceEditorID.Activate player, 1
Full code, rewritten from scratch.

scn ezzeMenuScript

; Working exists only to keep the script running
Short Working

; Phase == 1 display menu
; Phase == 2 await click
Short Phase

; hold the pressed button id
Short Button


Begin onActivate
  Set Phase to 1
  Set Working to 1
End


Begin GameMode
  If Working == 1
     Set Working to 1

     If Phase == 2
        Set Button to GetButtonPressed
        If Button < 0
            Return
        EndIf
        Set Working to 0 ;stop the script next frame

        ; Button now contains the pressed button ID
        Message "Choice %.0f " Button
     ElseIf Phase == 1
        Set Phase to 2
        Messagebox "TEST" "zero" "one" "two" "three" "four" "five"
     EndIf
  EndIf
End


Begin MenuMode
  If Working == 1
     Set Working to 1
  EndIf
End
Edited by zdswulyx
Link to comment
Share on other sites

 

You can activate the activator (eheh) with this script line:

YourActivatorsReferenceEditorID.Activate player, 1

 

Where is this used? Just curious. I have never used an external activator for messageboxes, I have always managed to make them work locally somehow, and a spell is one handy way to do it - assuming the messagebox only has one "page" of options, as in, no "submenus" or something like that. Is that command above called from a dialogue topic? If so, then finding a straightforward solution might be more tedious. But in case it is called from a spell effect, and if the menu only needs to display once per cast (as in, not persist on the screen), adding the menu itself to a spell would work.

 

An alternative to an activator - one that would run with no need for workarounds - would be to make a quest dedicated to the menu. Set the fQuestDelayTime variable to 0.01, reset the necessary variables and start the quest when the menu needs to be opened. That should work. When the menu is closed, the quest could be stopped, and the script would not run at all. Maybe that could work better, in case a spell effect is not enough to solve your menu issue?

 

I think one way forward at the moment would be to get rid of the "unloaded" status for the activator. Assuming you have all the background stuff in a dummy cell,p lace a floor panel or something in that dummy cell, move the objects (activator, container, etc.) on the floor, use the console to move the player into the dummy cell, on the floor next to the activator, and then try it. That way the activator would always be loaded, and you could concentrate on getting your actual menu to work, in case the issue is there. Maybe?

Link to comment
Share on other sites

Read the tutorial I linked in the first post for all details, it's not very long and since you have scripting experience it won't be difficult. There they also speak about alternatives, but the author explains how the activator is the simplest/best solution.

 

Honestly I have the feeling he is right. As using an activator is indeed fairly straightforward, BUT the tutorial misses the point of keeping the script alive during the MenuMode (or I missed it).

Edited by zdswulyx
Link to comment
Share on other sites

... are you aware I solved the problem as I mentioned in message #15?

The problem was that the script stop working after one frame of doing nothing and in the code I put in the first message this happened once the game went in MenuMode. One frame and script stopped.

Edited by zdswulyx
Link to comment
Share on other sites

Even if you solved the riddle, why are hurting yourself with an Object script attached to a remote activators?

As you learnt, Object scripts stop working if the object they're attached to is unloaded, and you need to continuously set a variable to ensure the object is not unloaded. If you need to show a menu and ensure the script keep running anywhere you are, for as long as you need, change the script type to "quest script" and attach it to a quest.

 

Quest are always loaded, runs independently from the location, and work even better because you can start and stop them at any time with StartQuest and StopQuest (so you can also erase the variable "Working").

Just don't forget to declare and set (only once, not every frame) the variable fQuestDelayTime in the Quest script, else it will run every 5 seconds.

 

If you heard "Quests are bad", well, it's not true. You have full control of a Quest script and you can completely stop it with the above commands and change the running speed to (example) 5 times per second with the above variable.

Instead, an Object script can't be controlled or stopped. The game keep processing its script every frame and it only stops when the game unload the object. And since it keep running, you need to keep it at bay with a "Working" variable.

 

Object script for a menu? IMHO, a very bad choice...

Edited by forli
Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...