Visibility command with concatenated filenames

Help and techniques for creating Air Manager Instrument Graphics

Moderators: russ, Ralph

Post Reply
Message
Author
JensMohr
Posts: 40
Joined: Mon Dec 12, 2016 6:42 pm

Visibility command with concatenated filenames

#1 Post by JensMohr »

Hello,

I have a problem with some (easy) visibility-switching.

There is one other "gauge" which is conected to the aircrafts battery and light panels. It generates AM-variables for use with all my other gauges. It works clean.

Now, with my actual gauge-project I have the following problem:
I have verified, that the "server-gauge" delivers the variables.
Given this, my intention is to switch graphics depending on the variable light setting.
Following code "works" but nothing happens:

Code: Select all

function new_OhdKnobAngle(lights_master, ohd_knob_angle)

if lights_master == 1 then -- if lights are to be processed...
	for myCnt = 10,90,10 do
		if myCnt == ohd_knob_angle then
			visible("L_opaque" .. myCnt .. ".png",true) -- make the image visible
			-- print("L_opaque" .. myCnt .. ".png -> true")
			if myCnt <= 80 then myCnt = myCnt + 10 else break end
		else
			visible("L_opaque" .. myCnt .. ".png",false) -- make all other images invisible
			-- print("L_opaque" .. myCnt .. ".png -> false")
		end
	end
else
	for myCnt = 10,90,10 do
		visible("L_opaque" .. myCnt .. ".png",false)
	end
end

end
For error tracing I used the out-commented printing function. It proves everything is fine.
All strings and variables are treated as intended.

Only the visible-command with the "concatenated" filename appears to do... nothing :-(
I verified that the files are all present and the required names do exist, as well as the filenames do match (name, upper and lower-case).

For example:
lights_master is 1 -> light settings have to be processed
ohd_knob_angle is 70 -> the image with the name "L_opaque70.png" shall be visible and the others "10,20,30,40,50,60,80,90" shall be invisible.
visible("L_opaque" .. myCnt .. ".png",true) doesn't work for 70.
visible("L_opaque" .. myCnt .. ".png",false) doesn't work for the rest.
Where is my problem?
Greetings from Germany,
JensMohr

User avatar
Ralph
Posts: 7933
Joined: Tue Oct 27, 2015 7:02 pm
Location: De Steeg
Contact:

Re: Visibility command with concatenated filenames

#2 Post by Ralph »

Quick response. It looks like your visible API command isn't correct, you can check the wiki to see how it works.

You're using visible as an image_add

JensMohr
Posts: 40
Joined: Mon Dec 12, 2016 6:42 pm

Re: Visibility command with concatenated filenames

#3 Post by JensMohr »

Oh,

and thanks.
The images are defined here:

Code: Select all

--***** 4th finally load all el-panel-text images which will show up over the storm light and set them inactive
L_opaque90 = img_add_fullscreen("T-Opaque90.png")
--visible(L_opaque90,false)
L_opaque80 = img_add_fullscreen("T-Opaque80.png")
--visible(L_opaque80,false)
L_opaque70 = img_add_fullscreen("T-Opaque70.png")
--visible(L_opaque70,false)
L_opaque60 = img_add_fullscreen("T-Opaque60.png")
--visible(L_opaque60,false)
L_opaque50 = img_add_fullscreen("T-Opaque50.png")
--visible(L_opaque50,false)
L_opaque40 = img_add_fullscreen("T-Opaque40.png")
--visible(L_opaque40,false)
L_opaque30 = img_add_fullscreen("T-Opaque30.png")
--visible(L_opaque30,false)
L_opaque20 = img_add_fullscreen("T-Opaque20.png")
--visible(L_opaque20,false)
L_opaque10 = img_add_fullscreen("T-Opaque10.png")
--visible(L_opaque10,false)

I can't use the image's name but must use the gui_id.
AAaaahhhmmmm...
Oops, NOW I figure out my mistake...

I'm more or less trying to concatenate (e. g.) the gui_id L_Opaque50 with the file name extension ".png"

(In so far it seems a little strange that LUA doesn't complain..., lol)

Will give it a try tomorrow and then report back.
(Have to think a little about the re-arrangement of the loop for this :-))

Time to go to bed :-)

'til then,
Greetings from Germany,
JensMohr

User avatar
Ralph
Posts: 7933
Joined: Tue Oct 27, 2015 7:02 pm
Location: De Steeg
Contact:

Re: Visibility command with concatenated filenames

#4 Post by Ralph »

Java is very forgiving, it'll be a lot different with OpenGL :)

JackZ
Posts: 2267
Joined: Mon Feb 22, 2016 1:02 pm

Re: Visibility command with concatenated filenames

#5 Post by JackZ »

Great idea this visibility trick, in the interim of the OpenGL version!
Are you using images with different degrees of transparency ?
Would be interesting you share them with us, so we can reuse the trick.

As for the loop itself, since you seem to only have 8 possibilities, I'd go with a serie of 8 lines such as:

visible(L_opaqueXX, ohd_knob_angle==XX)

with XX the actual angle of the ovh knob (btw are you sure there is only 8 values?),that would probably be faster.

Jacques
My YouTube Chanel on the A320 (Real SOPs by an Airline Pilot IRL):
https://www.youtube.com/playlist?list=P ... 0Q6SBASRqJ

JensMohr
Posts: 40
Joined: Mon Dec 12, 2016 6:42 pm

Re: Visibility command with concatenated filenames

#6 Post by JensMohr »

Hi,

and thanks. I've got it running.
(Do you know PEBSAC ? =>> P.roblem E.xists B.etween S.creen A.nd C.hair :-)
After al I decided to "maintain" the illumination conditions in my instruments as per the variables out of the Dash8.
Not tiggering every 0.1% I'd make my Dash8-light-server which again delivers 10% increments to the actual gauges via am_variables.
This, in co-operation with the way of coding you'd see, has the advantage that:
- I have only once to read out the lighting-Vars,
- I have one "light-bus" for all environmental, exterior and interior lights,
- As my lighting vars are aleways the same,they can be used immediately without further code-development
- Therefor I can copy-paste 99% of the core "lighting-code" from one gauge to the next and day-dusk/dawn-night, internal, external lights... all runs
- And I like it, haha ;-) EDITED:30.12.2016 - 12:27

At this very moment I rework some minor code blocks and re-build some graphics.
When ready I'll upload the light-server, the landing-flare-taxi-light panel, the dc-control panel and the internal light-setting panel for the MJC8Q400.
It appears that this will be by the end of next week.

EDIT:
Hope this works...
Image
Greetings from Germany,
JensMohr

Post Reply