Sabrefly Posted January 22, 2017 Report Posted January 22, 2017 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, maxmycopy = msgs[1] --make a copy for me to uselen = string.len(mycopy)if len > x then --need to split mycopy = string.sub(mycopy,1,x) .. "\r" .. string.sub(mycopy, x+1)endwnd.text(w2, n, mycopy) if delay then timeclear2 = delay * 1000 time2 = ipc.elapsedtime() end end endend ctr = 0function 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 endend 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.
Pete Dowson Posted January 22, 2017 Report Posted January 22, 2017 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
Sabrefly Posted January 23, 2017 Report Posted January 23, 2017 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.
Pete Dowson Posted January 24, 2017 Report Posted January 24, 2017 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
Sabrefly Posted January 24, 2017 Report Posted January 24, 2017 Apologies and thanks are all mine. This is what I get now: 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.
Pete Dowson Posted January 24, 2017 Report Posted January 24, 2017 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 1
Sabrefly Posted January 24, 2017 Report Posted January 24, 2017 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.
Pete Dowson Posted January 24, 2017 Report Posted January 24, 2017 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
Sabrefly Posted January 24, 2017 Report Posted January 24, 2017 I'm so sorry: 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.
Pete Dowson Posted January 24, 2017 Report Posted January 24, 2017 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 1
Sabrefly Posted January 24, 2017 Report Posted January 24, 2017 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.
Pete Dowson Posted January 24, 2017 Report Posted January 24, 2017 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
Sabrefly Posted January 25, 2017 Report Posted January 25, 2017 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: 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.
Sabrefly Posted January 25, 2017 Report Posted January 25, 2017 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.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now