Scripting Resources & Utilities > OpenEUO Scripting Chat

Unresponsible TForm with "while" cycle

(1/2) > >>

MrMongus:
Hello, sorry for maybe stupid question, but I'm stuck while creating menu.
I'm trying (about 14 days of trying and searching) to start and stop "while" cycle by buttons, but when I start cycle then menu stops responding.

I tried all sorts of crazy constructions, but I just couldn't. Certainly it will be related to the fact that I play it in the same thread ...I just don't know how the threads work in LUA, so if anyone would want to advise me, I'll be glad.

Please is there any way I can start and stop a "while" cycle using the form with button ?

Here is my last example of start/stop menu - that stops responding after start of course...
Spoiler: show
local val = false
function Main()
        frmMain = Obj.Create("TForm")
        frmMain.Left =          0
        frmMain.Top =           0
        frmMain.Width =         100
        frmMain.Height =        100
        frmMain.Font.Name =     "Arial"
        frmMain.Font.Size =     8
        frmMain.Caption =       "Some testing text"
        frmMain.OnClose =       function(pSender) Obj.Exit() end
        frmMain.FormStyle =     3
 
        btnStartStop = Obj.Create("TButton")
        btnStartStop.Caption =      "Start/stop"
        btnStartStop.OnClick =      function(pSender) btnOnClick(not val, pSender) end
        btnStartStop.Parent =       frmMain
        btnStartStop.Top =          10
        btnStartStop.Left =         20
        btnStartStop.Width =        100
 
        frmMain.Show()
        Obj.Loop()
end

function btnOnClick(value)
  while value == true do
    print("...")
    wait(500)
  end
end
 
function Clean()
        Obj.Free(btnStartStop)
        Obj.Free(frmMain)
end
 
Main()
Clean()


Thank you very much for your suggestions.

MrMongus:
OK, I give up, using an atom and two running scripts at the same time... It's not comfortable, but what can be done...

Crisis:
I am sorry you have had little help. I am not sure how many people actually use OEUO. I tried it a while back but got frustrated and gave up. This is within the first year of it and I could not find the variety of scripts nor make my own. I ended up going back to normal EUO.

MrMongus:
It's OK. I was just trying to ask. :) I read somewhere that an atom is perhaps the only option...

Endless Night:
Its been years since I fiddled with OpenEUO,  I'm not 100% sure the menu system ever even completed.   My advise would be to look for a posted openeuo scripts that incorporates a menu system and see how they did it.

Navigation

[0] Message Index

[#] Next page

Go to full version