Jump to content
The simFlight Network Forums

event textmenu not catching everytime gsx menu


Recommended Posts

31 minutes ago, Pete Dowson said:

The messages are just as they are. If they don't fit, they don't fit. What GSX messages are the problem? I have never had a problem reading them. Is your window very small.

BTW you seem to have quoted something from me completely disconnected from your question, and there is no "code above".

Pete

 

No, PRO-ATC X is the problem, GSX messages are short.

Sorry, by code above I meant this lua:

 

Quote

 

colours = { 0x000, 0xfff, 0xf00, 0x0f0, 0x00f, 0xff0, 0xf0f, 0x0ff }
doshow = 1
shown = 2
textset = false
menuset = false
time2 = 0
time3 = 0
timeclear2 = 0
timeclear3 = 0

w1 = wnd.open("Radar Contact", WND_FIXED, 0,0,1024,768)
wnd.backcol(w1, 0x000)
wnd.textcol(w1, 0x0f0)
wnd.font(w1, WND_ARIAL, 24, WND_BOLD)

w2 = wnd.open("FSX Text", WND_FIXED, 0,0,1024,100)
wnd.backcol(w2, 0xfff)
wnd.textcol(w2, 0x000)
wnd.font(w2, WND_ARIAL, 10, WND_BOLD)

w3 = wnd.open("FSX Menu", WND_FIXED, 0,100,1024,668)
wnd.backcol(w3, 0x88f)
wnd.textcol(w3, 0x000)
wnd.font(w3, WND_ARIAL, 17, WND_BOLD)

ext.state("FSX Menu", EXT_HIDE)
ext.state("FSX Text", EXT_HIDE)
ext.state("Radar Contact", EXT_NRML)
w1text = ipc.readSTR(0x3380,128)
ipc.log(w1text)
wnd.text(w1, w1text)

local function testifclear()
  doshow = 1
    if menuset or textset then
       doshow = 2
    end
    if doshow ~= shown then
       if doshow == 1 then
               ext.state("FSX Text", EXT_HIDE)
                ext.state("FSX Menu", EXT_HIDE)
                ext.state("Radar Contact", EXT_NRML)
                wnd.clear(w1)
                wnd.text(w1, w1text)
            ipc.log("Showing RC")
         else
                ext.state("Radar Contact", EXT_HIDE)
                 ext.state("FSX Text", EXT_NRML)
                ext.state("FSX Menu", EXT_NRML)
            ipc.log("Showing FSX Menus")
             end
     shown = doshow
    end
end

local function clearw2()
   wnd.clear(w2)
     textset = false
   testifclear()
end   

function clearw3()
   wnd.clear(w3)
     menuset = false
   testifclear()
end   

function textandmenu(mtype, colour, scroll, delay, id, n, msgs)
    doshow = 1
    if mtype == 2 then
       -- Menu
      time3 = 0
      if n == 0 then 
         wnd.clear(w3)
         menuset = false
             testifclear()
      else
         menuset = true
             testifclear()
         wnd.clear(w3)
           wnd.text(w3, " " .. msgs[1])
           wnd.text(w3, " ")
           wnd.text(w3, " " .. msgs[2])
           wnd.text(w3, " ")
           i = 3
           j = 1
           while i <= n do
                 wnd.text(w3, " " .. j .. " - " .. msgs)
              i = i + 1
              j = j + 1
              if (j > 9) then 
                 j = 0
              end
           end
           if delay ~= 0 then
                   timeclear3 = delay * 1000
                   time3 = ipc.elapsedtime()
           end
      end
    else
      -- Text
      time2 = 0
        if n == 0 then 
         wnd.clear(w2)
         textset = false
             testifclear()
      else
         textset = true
             testifclear()
           wnd.textcol(w2, colours[colour+1])
              wnd.backcol(w2, logic.Xor(colours[colour+1], 0xfff))
          x = 80  --my example of how many characters you want, max
mycopy = msgs[1] --make a copy for me to use
len = string.len(mycopy)
if len > x then
   --need to split
   mycopy = string.sub(mycopy,1,x) .. "\r" .. string.sub(mycopy, x+1)
end
wnd.text(w2, n, mycopy)


           if delay then
                   timeclear2 = delay * 1000
                   time2 = ipc.elapsedtime()
           end
      end
    end
end

ctr = 0
function time()
    ctr = ctr + 1
        val = ipc.elapsedtime()
    if time2 ~= 0 and ((val - time2) > timeclear2) then
       clearw2()
       time2 = 0
    end
    if time3 ~= 0 and ((val - time3) > timeclear3) then
       clearw3()
       time3 = 0
    end
    if (ctr <= 2) then 
        ipc.togglebitsUW(0x32FA,0xffff)
    elseif (ctr > 10) then ctr = 0 end
end    

function update1(off, val)
     w1text = ipc.readSTR(0x3380,128)
     wnd.clear(w1)
     wnd.text(w1, w1text)
end

event.textmenu(0, "textandmenu")
event.offset(0x3380, "STR", "update1")
event.offset(0x32FA, "UW", "update1")
event.timer(500, "time")

testifclear()

 

Thanks!

Igor.

 

Link to comment
Share on other sites

30 minutes ago, Sabrefly said:

No, PRO-ATC X is the problem

Oh, I use ProATC/X too. What messages are too long? If it's the clearance or taxi instructions, which obviously vary in length, then this isn't part of the menu but its it the normal test window , 

w2 = wnd.open("FSX Text", WND_FIXED, 0,0,1024,100)
wnd.backcol(w2, 0xfff)
wnd.textcol(w2, 0x000)
wnd.font(w2, WND_ARIAL, 10, WND_BOLD)

I see you already have the font much smaller than that for the other two windows (10 rather than 17), so i suppose you don't have scope to reduce it further?

Why not try changing this parameter, so it splits the line earlier?

x = 80  --my example of how many characters you want, max 

After all, this was only my 'example'.

If you want to split it further you need rather more complex code, maybe, for three lines, replace this:

mycopy = msgs[1] --make a copy for me to use
len = string.len(mycopy)
if len > x then
   --need to split
   mycopy = string.sub(mycopy,1,x) .. "\r" .. string.sub(mycopy, x+1)
end

by this:

mycopy = msgs[1] --make a copy for me to use
len = string.len(mycopy)
if len > x then
   --need to split
   mycopy2 = string.sub(mycopy, x+1)
   len = string.len(mycopy2)
   if len > x then
       --need to split again!
        mycopy2 = string.sub(mycopy2,1,x)  .. "\r" ..  string.sub(mycopy2, x+1)
   end
   mycopy = string.sub(mycopy,1,x) .. "\r" .. string.sub(mycopy2, x+1) 
end

I haven't been able to test this (my cockpit is not up at present), but it looks okay. If not you should be able to see what it is trying to do and fix it yourself.

Scrolling is possible, using code which keeps displaying from one later in the string, via another timer in another function. but that's even more complicated. If you fancy that, why not have a go?

Pete

 

Link to comment
Share on other sites

FSX%20Text_zpsz9jukro2.jpg

This is what I get with the LUA below:

Quote

 

colours = { 0x000, 0xfff, 0xf00, 0x0f0, 0x00f, 0xff0, 0xf0f, 0x0ff }
doshow = 1
shown = 2
textset = false
time2 = 0
time3 = 0
timeclear2 = 0
timeclear3 = 0


w2 = wnd.open("FSX Text",0,0,1200,150)
wnd.backcol(w2, 0xfff)
wnd.textcol(w2, 0x000)
wnd.font(w2, WND_ARIAL, 10, WND_BOLD)

w3 = wnd.open("FSX Menu",0,150,1200,518)
wnd.backcol(w3, 0x88f)
wnd.textcol(w3, 0x000)
wnd.font(w3, WND_ARIAL, 12, WND_BOLD)

ext.state("FSX Menu", EXT_HIDE)
ext.state("FSX Text", EXT_HIDE)


local function testifclear()
  doshow = 1
    if menuset or textset then
       doshow = 2
    end
    if doshow ~= shown then
       if doshow == 1 then
                ext.state("FSX Text", EXT_HIDE)
                ext.state("FSX Menu", EXT_HIDE)

         else

                 ext.state("FSX Text", EXT_NRML)
                ext.state("FSX Menu", EXT_NRML)
         end
     shown = doshow
    end
end


local function clearw2()
   wnd.clear(w2)
     textset = false
   testifclear()
end   

function clearw3()
   wnd.clear(w3)
     menuset = false
   testifclear()
end   

function textandmenu(mtype, colour, scroll, delay, id, n, msgs)
    doshow = 1
    if mtype == 2 then
       -- Menu
      time3 = 0
      if n == 0 then 
         wnd.clear(w3)
         menuset = false
             testifclear()
      else
         menuset = true
             testifclear()
         wnd.clear(w3)
           wnd.text(w3, " " .. msgs[1])
           wnd.text(w3, " ")
           wnd.text(w3, " " .. msgs[2])
           wnd.text(w3, " ")
           i = 3
           j = 1
           while i <= n do
                 wnd.text(w3, " " .. j .. " - " .. msgs)
              i = i + 1
              j = j + 1
              if (j > 9) then 
                 j = 0
              end
           end
           if delay ~= 0 then
                   timeclear3 = delay * 1000
                   time3 = ipc.elapsedtime()
           end
      end
    else
      -- Text
      time2 = 0
        if n == 0 then 
         wnd.clear(w2)
         textset = false
             testifclear()
      else
         textset = true
             testifclear()
           wnd.textcol(w2, colours[colour+1])
              wnd.backcol(w2, logic.Xor(colours[colour+1], 0xfff))

x = 40  --my example of how many characters you want, max
mycopy = msgs[1] --make a copy for me to use
len = string.len(mycopy)
if len > x then
   --need to split
   mycopy2 = string.sub(mycopy, x+1)
   len = string.len(mycopy2)
   if len > x then
       --need to split again!
        mycopy2 = string.sub(mycopy2,1,x)  .. "\r" ..  string.sub(mycopy2, x+1)
   end
   mycopy = string.sub(mycopy,1,x) .. "\r" .. string.sub(mycopy2, x+1) 
end

wnd.text(w2, n, mycopy)

           if delay then
                   timeclear2 = delay * 1000
                   time2 = ipc.elapsedtime()
           end
      end
    end
end

function time()
  val = ipc.elapsedtime()
    if time2 ~= 0 and ((val - time2) > timeclear2) then
       clearw2()
       time2 = 0
    end
    if time3 ~= 0 and ((val - time3) > timeclear3) then
       clearw3()
       time3 = 0
    end
end    

function update1(off, val)
     wnd.clear(w1)
     wnd.text(w1, val)
end

event.textmenu(0, "textandmenu")
event.offset(0x3380, "STR", "update1")
event.timer(500, "time")
testifclear()

 

 

The message line (in FSX Text window) still gets cut off with the above settings in the lua.

I changed x=40 (from 80) - but it had no effect on anything.

Thanks,

Igor.
 

Link to comment
Share on other sites

2 hours ago, Sabrefly said:

mycopy = string.sub(mycopy,1,x) .. "\r" .. string.sub(mycopy2, x+1) 

I think that line should be

mycopy = string.sub(mycopy,1,x) .. "\r" .. mycopy2) 

Please test again. I still won't guarantee it. Written in haste -- extremely busy at the moment.

The idea of adding Lua to FSUIPC was to allow users to help themselves in making new facilities, so i didn't really expect to have to do it myself still, As a consequence so I don't give it as much time as the program itself. Sorry.

Pete

 

Link to comment
Share on other sites

Apologies and thanks are all mine.

This is what I get now:

FSX%20Text2_zpsr5pfggcu.jpg

 

The lines get doubled, but the text does not get moved to the next line when the limit (40 characters) is reached.

 

Quote

 

colours = { 0x000, 0xfff, 0xf00, 0x0f0, 0x00f, 0xff0, 0xf0f, 0x0ff }
doshow = 1
shown = 2
textset = false
time2 = 0
time3 = 0
timeclear2 = 0
timeclear3 = 0


w2 = wnd.open("FSX Text",0,0,1200,150)
wnd.backcol(w2, 0xfff)
wnd.textcol(w2, 0x000)
wnd.font(w2, WND_ARIAL, 10, WND_BOLD)

w3 = wnd.open("FSX Menu",0,150,1200,518)
wnd.backcol(w3, 0x88f)
wnd.textcol(w3, 0x000)
wnd.font(w3, WND_ARIAL, 12, WND_BOLD)

ext.state("FSX Menu", EXT_HIDE)
ext.state("FSX Text", EXT_HIDE)


local function testifclear()
  doshow = 1
    if menuset or textset then
       doshow = 2
    end
    if doshow ~= shown then
       if doshow == 1 then
                ext.state("FSX Text", EXT_HIDE)
                ext.state("FSX Menu", EXT_HIDE)

         else

                 ext.state("FSX Text", EXT_NRML)
                ext.state("FSX Menu", EXT_NRML)
         end
     shown = doshow
    end
end


local function clearw2()
   wnd.clear(w2)
     textset = false
   testifclear()
end   

function clearw3()
   wnd.clear(w3)
     menuset = false
   testifclear()
end   

function textandmenu(mtype, colour, scroll, delay, id, n, msgs)
    doshow = 1
    if mtype == 2 then
       -- Menu
      time3 = 0
      if n == 0 then 
         wnd.clear(w3)
         menuset = false
             testifclear()
      else
         menuset = true
             testifclear()
         wnd.clear(w3)
           wnd.text(w3, " " .. msgs[1])
           wnd.text(w3, " ")
           wnd.text(w3, " " .. msgs[2])
           wnd.text(w3, " ")
           i = 3
           j = 1
           while i <= n do
                 wnd.text(w3, " " .. j .. " - " .. msgs)
              i = i + 1
              j = j + 1
              if (j > 9) then 
                 j = 0
              end
           end
           if delay ~= 0 then
                   timeclear3 = delay * 1000
                   time3 = ipc.elapsedtime()
           end
      end
    else
      -- Text
      time2 = 0
        if n == 0 then 
         wnd.clear(w2)
         textset = false
             testifclear()
      else
         textset = true
             testifclear()
           wnd.textcol(w2, colours[colour+1])
              wnd.backcol(w2, logic.Xor(colours[colour+1], 0xfff))

x = 40  --my example of how many characters you want, max
mycopy = msgs[1] --make a copy for me to use
len = string.len(mycopy)
if len > x then
   --need to split
   mycopy2 = string.sub(mycopy, x+1)
   len = string.len(mycopy2)
   if len > x then
       --need to split again!
        mycopy2 = string.sub(mycopy2,1,x)  .. "\r" ..  string.sub(mycopy2, x+1)
   end
   mycopy = string.sub(mycopy,1,x) .. "\r" .. mycopy2) 
end

wnd.text(w2, n, mycopy)

           if delay then
                   timeclear2 = delay * 1000
                   time2 = ipc.elapsedtime()
           end
      end
    end
end

function time()
  val = ipc.elapsedtime()
    if time2 ~= 0 and ((val - time2) > timeclear2) then
       clearw2()
       time2 = 0
    end
    if time3 ~= 0 and ((val - time3) > timeclear3) then
       clearw3()
       time3 = 0
    end
end    

function update1(off, val)
     wnd.clear(w1)
     wnd.text(w1, val)
end

event.textmenu(0, "textandmenu")
event.offset(0x3380, "STR", "update1")
event.timer(500, "time")
testifclear()

 


Thanks so much,

Igor.

 

Link to comment
Share on other sites

2 hours ago, Sabrefly said:

The lines get doubled, but the text does not get moved to the next line when the limit (40 characters) is reached.

Hmm. I must still have an error there somewhere. I'll have a look when I get time. Sorry, I have much bigger problems to sort out first.

Pete

 

  • Upvote 1
Link to comment
Share on other sites

35 minutes ago, Pete Dowson said:

Hmm. I must still have an error there somewhere. I'll have a look when I get time. Sorry, I have much bigger problems to sort out first.

Pete

 

 

Sorry, I may have made a wrong observation and inference, but the error may have been elsewhere in the lua. For example, how could I definitely say "when the limit (40 characters) is reached"? I better be more humble putting in words what I think my eyes see. Please disregard my blabber and see into the lua when you have a moment. My pictures will talk better I guess. 

Thanks,

Igor.

 

 

Link to comment
Share on other sites

Okay. This should work okay, it does here:

Replace all of this:

if len > x then
   --need to split
   mycopy2 = string.sub(mycopy, x+1)
   len = string.len(mycopy2)
   if len > x then
       --need to split again!
        mycopy2 = string.sub(mycopy2,1,x)  .. "\r" ..  string.sub(mycopy2, x+1)
   end
   mycopy = string.sub(mycopy,1,x) .. "\r" .. mycopy2) 
end

by all of this:

if len > x then
  --need to split
  n = x + 1
  mycopy2 = mycopy
  while len >= n do
    mycopy = string.sub(mycopy2, n)
    mycopy2 = string.sub(mycopy2,1,n-1) .. "\n" .. mycopy
    len = string.len(mycopy2)
    n = n + x + 1 
  end
  mycopy = mycopy2
end

This isn't limited. It will split into as many lines as needed.

Better would be to find the nearest space character before your limit, and split there each time. But that's more complicated again and I don't have time at present. I may look at it again some time.

Pete

 

Link to comment
Share on other sites

I'm so sorry:

FSX%20Text3_zpsebyjbxtb.jpg

 

Quote

 

colours = { 0x000, 0xfff, 0xf00, 0x0f0, 0x00f, 0xff0, 0xf0f, 0x0ff }
doshow = 1
shown = 2
textset = false
time2 = 0
time3 = 0
timeclear2 = 0
timeclear3 = 0


w2 = wnd.open("FSX Text",0,0,1200,150)
wnd.backcol(w2, 0xfff)
wnd.textcol(w2, 0x000)
wnd.font(w2, WND_ARIAL, 10, WND_BOLD)

w3 = wnd.open("FSX Menu",0,150,1200,518)
wnd.backcol(w3, 0x88f)
wnd.textcol(w3, 0x000)
wnd.font(w3, WND_ARIAL, 12, WND_BOLD)

ext.state("FSX Menu", EXT_HIDE)
ext.state("FSX Text", EXT_HIDE)


local function testifclear()
  doshow = 1
    if menuset or textset then
       doshow = 2
    end
    if doshow ~= shown then
       if doshow == 1 then
                ext.state("FSX Text", EXT_HIDE)
                ext.state("FSX Menu", EXT_HIDE)

         else

                 ext.state("FSX Text", EXT_NRML)
                ext.state("FSX Menu", EXT_NRML)
         end
     shown = doshow
    end
end


local function clearw2()
   wnd.clear(w2)
     textset = false
   testifclear()
end   

function clearw3()
   wnd.clear(w3)
     menuset = false
   testifclear()
end   

function textandmenu(mtype, colour, scroll, delay, id, n, msgs)
    doshow = 1
    if mtype == 2 then
       -- Menu
      time3 = 0
      if n == 0 then 
         wnd.clear(w3)
         menuset = false
             testifclear()
      else
         menuset = true
             testifclear()
         wnd.clear(w3)
           wnd.text(w3, " " .. msgs[1])
           wnd.text(w3, " ")
           wnd.text(w3, " " .. msgs[2])
           wnd.text(w3, " ")
           i = 3
           j = 1
           while i <= n do
                 wnd.text(w3, " " .. j .. " - " .. msgs)
              i = i + 1
              j = j + 1
              if (j > 9) then 
                 j = 0
              end
           end
           if delay ~= 0 then
                   timeclear3 = delay * 1000
                   time3 = ipc.elapsedtime()
           end
      end
    else
      -- Text
      time2 = 0
        if n == 0 then 
         wnd.clear(w2)
         textset = false
             testifclear()
      else
         textset = true
             testifclear()
           wnd.textcol(w2, colours[colour+1])
              wnd.backcol(w2, logic.Xor(colours[colour+1], 0xfff))

x = 40  --my example of how many characters you want, max
mycopy = msgs[1] --make a copy for me to use
len = string.len(mycopy)
if len > x then
  --need to split
  n = x + 1
  mycopy2 = mycopy
  while len >= n do
    mycopy = string.sub(mycopy2, n)
    mycopy2 = string.sub(mycopy2,1,n-1) .. "\n" .. mycopy
    len = string.len(mycopy2)
    n = n + x + 1 
  end
  mycopy = mycopy2
end

wnd.text(w2, n, mycopy)

           if delay then
                   timeclear2 = delay * 1000
                   time2 = ipc.elapsedtime()
           end
      end
    end
end

function time()
  val = ipc.elapsedtime()
    if time2 ~= 0 and ((val - time2) > timeclear2) then
       clearw2()
       time2 = 0
    end
    if time3 ~= 0 and ((val - time3) > timeclear3) then
       clearw3()
       time3 = 0
    end
end    

function update1(off, val)
     wnd.clear(w1)
     wnd.text(w1, val)
end

event.textmenu(0, "textandmenu")
event.offset(0x3380, "STR", "update1")
event.timer(500, "time")
testifclear()

 

Thanks,

Igor.

Link to comment
Share on other sites

Sorry, then. It works perfectly here. I don't know where to start working out what is different there. I'm tired and exhausted. i've been trying to do too much today. It's no good at my age.

If anything occurs to me tomorrow i might have nother have a look, but my first guess is that you are still running the old version, as nothing has changed it at all. That makes no sense. You need to replace it and restart WideClient.

Pete

 

  • Upvote 1
Link to comment
Share on other sites

Pete, please take your time, maybe tomorrow you'll post your lua that works, and I'll go through comparing them.

I have only one lua running at a time on the specific Client, so I just edit the lua, save, close then run WideClient.exre.

I'm on FSUIPC v4.959p (test one) and 6.999z4, the client is on WinXP.

Thanks so much,

Igor.

Link to comment
Share on other sites

Try just one thing for me, please, just in case.

You might have noticed that I had "\n" as the new line code in my last effort. Can you try "\r" again instead, please? I think either should do, but it's a "just in case".

What I certainly don't understand is why you get two copies of each line. I don't think that's my code, It looks to be seeing two copies. If my splitting code isn't working you'd only get the one unsplit line.

Pete

 

Link to comment
Share on other sites

22 hours ago, Pete Dowson said:

but my first guess is that you are still running the old version, as nothing has changed it at all. That makes no sense. You need to replace it and restart WideClient.

Pete

 

Pete, I remembered this when I ran the test again today so I didn't change anything before starting it today. I knew it was a little too late in my location (UTC+3:00) last night, so I thought I might have done something wrong yet. So this is what I got today: 

FSX%20Text4_zps0vhg5xvl.jpg

The script works!! I'll sort it out with the redundant windows I hope. See, I was looking at the wrong window and observed the same behaviour. The right one was covered under. 

Thank you so much, so sorry for taking so much of your time, I owe you a couple of tickets to the Bolshoi (just mind you that will take you to visit Moscow in winter, and I l like winter!! Just let me know)

Thanks,

Igor. 

Sorry, the wrong picture again! Will correct now - now corrected, this is the right one.

Link to comment
Share on other sites

19 hours ago, Pete Dowson said:

Try just one thing for me, please, just in case.

You might have noticed that I had "\n" as the new line code in my last effort. Can you try "\r" again instead, please? I think either should do, but it's a "just in case".

Pete

 

Replaced "\n" with "\r" and got properly cut off text at 40 characters, but not going down to the next line. 

Thank you!

Igor.

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use. Guidelines Privacy Policy We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.