Jump to content

flyer10au

Members
  • Posts

    21
  • Joined

  • Last visited

Everything posted by flyer10au

  1. Thanks for the reply. That is a shame. I know other devs also have this limitation but I know Aerobask for instance has a way to make their custom popouts work without the 3D cockpit showing. Hopefully you guys and the other devs can lobby LR to fix this limitation.
  2. A related question. When the G1000 displays are popped out do they still operate as normal if the Xplane view is set to outside only. I.e. No 3D cockpit shown. I have had issues with other developers aircraft that require the 3D cockpit to show. I want to be able to only show outside view. This question also applies to SR22 and other G1000 equipped models. Wanting to purchase but need this to work.
  3. Yes that helps. Good information for when the API documentation finally gets updated. Thanks again.
  4. Thanks Ben. I thought I'd tried that but must of been finger trouble last time. It now works like a dream. Out of interest what is adding return 1 to the end of OnStart actually doing different to not using return 1.
  5. I'm not getting it. I have the following code and the custom dataref only increments by 1. Nothing happens when I hold or release the button. The button is running a custom command created with xp.newCommand("sim/custom/button", "Button", "button"). The dataref is declared elsewhere. button_count = 0function button_OnStart() button_count = button_count + 1 dref.setFloat(CDRtest1, button_count) endfunction button_OnHold() button_count = button_count + 10 dref.setFloat(CDRtest1, button_count)endfunction button_OnStop() button_count = button_count - 1 dref.setFloat(CDRtest1, button_count)end
  6. Anyone have any success using the OnStop or OnHold hooks that should be called when executing a custom command. I have the same bit of test code in the OnStart, OnHold and OnStop functions but only the OnStart executes. I can't get button release or hold to work at all. I'm using the latest 13.11.05.0205 Gizmo release.
  7. Thanks for the confirmation. Shouldn't take too long with find and replace.
  8. I've just got round to updating my gizmo plugin to 13.11.05.0205 from an older 64 bit version (i can dig the version out if important). I am getting script error's in the console for all the xp.get and xp.set functions in previously working code. I have managed to figure out that by changing these to dref API functions clears the errors. I haven't changed every reference in my multi file scripts yet as I just want to be sure that xp functions will not function with these newer gizmo versions any longer and that dref is the new kid on the block and should be used in new script. I know dref has been in the API for a while now but when and why did xp cease, or did it? The API only seems to be current for 12.09.16.1422.
  9. Thanks for the clarification. It's easy to deal with as you say. Just seemed a little weird to me, but your explanation at least makes some sense to the reasoning behind it.
  10. All Working. Now I understand what the built in OnDraw functions are for it makes sense. My problem was simply because I was trying to draw panel stuff with OnDraw_windows. The only thing that doesn't stack up is this. In the aircraft I tried (including xp's C172). If I make the planemaker co-ordinates 0,0 for a gauge the centre of it is aligned with the left edge of the screen as expected. However in the vertical plane the middle of the gauge sits about 256 pixels above the bottom edge of the screen. Therefore if I add 256 to my y co-ordinate plus half the gauges height I get the top of the gauge. Weird I know.
  11. Jim, I have been using the font functions with success elsewhere so thanks for the tip about gfx.drawstring. I knew about the gfx.texOn() and gfx.texOff() but somehow managed to forget to include them. That now makes the png draw as expected from either OnDraw_Gauges() or OnDraw_BeforeGauges(). I think On_Draw_Gauges() draws stuff just the once and its likely best use is for one time drawing items that don't move or change based on changing dataref's. What I still don't understand is when to use calls from each of these functions and what the differences are. I assume anything that needs to be continually redrawn has to be called from OnDraw_Windows(). I didn't really understand your Side Note. Do you mean create and load all the required textures outside of functions as part of the initial dofile and then just use them by reference to the texture id within the functions. All of the above is really a side show to my main problem with the alignment (see original post). Anyone have any ideas on this?
  12. OK back again. Working my way through the API trying to understand what's possible with Gizmo. This time I'm on to the graphics API and open GL drawing. I've got a couple of questions. My main question relates to how to align png images placed in planemaker with Gizmo code generated open gl drawing elements. What I can currently do is have some gl generated text and number elements drawn with font.drawString nicely align in the desired locations within a planemaker png while the screen size window is less than or equal to the panel.png resolution (1920x1080 in this case). I do this by reading the acf file for the png location (yes, I've also been playing with the IO APi too) and formatting the open gl co-ordinates such that the gizmo drawn elements are using the same reference point. The formatting is simple maths to allow for the fact that planemaker and open gl co-ordinates do not directly reference the same point on the screen. What i'm struggling with is when I extend the x-plane window beyond either the 1920, 1080 or both x-plane scales and shifts the panel such that my open gl draws are now no longer aligned with the desired location of the planemaker png. I have tried some simple maths solutions using combinations of screen size and panel size information which improve a little but they don't solve the problem for all window sizes. I have a dual monitor ( 2 x 1920x1200) set-up that i used for this testing. I really would like to get gizmo playing nice with my existing planemaker generated panels. Any idea's on how to make this work? My second question relates to function calls from OnDraw_Gauges(). I tried to call a function that draws a png to the screen from OnDraw_Gauges(), but the png just would not show. However as soon as I put a gfx.drawString into the function the png draws fine (see code below). What's happening here? Also when should I use OnDraw_Gauges() and/or OnDraw_BeforeGauges(). ------file1dofile("file2.lua")function OnDraw_Gauges() draw_imageA()end------file2function draw_imageA() gfx.setColor(0,0,0,1) gfx.drawString("." , 944, 116 ) --call from OnDrawGauges() to draw_imageA() will not draw image without this png_file = "/image_path/Bezel.png" draw_png( 942, 114, 550, 145, 1, png_file ) --draw and place Bezel endfunction draw_png(x, y, width, height, zoom, file) png_texture = gfx.newTexture() local width = width * zoom local height = height * zoom gl.PushMatrix() gl.Translate (x, y, 0 ) gfx.loadPng(png_texture, file ) gfx.useTexture(png_texture) gfx.setColor(1,1,1,1) gl.Begin('QUADS') gl.TexCoord( 0, 0 ); gl.Vertex( 0, 0, 0 ); gl.TexCoord( 0, 1 ); gl.Vertex( 0, height, 0 ); gl.TexCoord( 1, 1 ); gl.Vertex( width, height, 0 ); gl.TexCoord( 1, 0 ); gl.Vertex( width, 0, 0 ); gl.End() gl.PopMatrix()end
  13. Jim, I agree with you its safer to use nav.getNextNavAid just in case the database changes in the future. I was just pointing out that at this moment in time its the same, which is why my incrementing method worked until you pointed out the documentation error. This is however all now irrelevant for my use because as I previously stated I was able to get the findNavAid function working just as I needed. Once again thanks for your support on this. I'm sure I'll be needing some further help from this great community as time goes on. I could certainly help someone with a nav api question in the future.
  14. Thanks Guys. It sounds like improved documentation is already on the agenda then. It really will help smooth the way for newer developers. We still have this great forum for help in the meantime. Ben thanks for the github reminder. I had been along there a few weeks back. Now I know a little more about Gizmo it may be of more use. Jim, The VOR_NavRef = nav.getNextNavAid( VOR_NavRef ) works as you suggest but is of little improvement over just incrementing the VOR_NavRef by 1 for each iteration until you reach the last VOR entry. This is simply because all the VOR's are in the database sequentially between id's 7065 to 10758. It would help some if the database ever evolved to be un-ordered. What I first had working simply checked each id's frequency, lat and lon for a proximity match within 200 miles of the aircraft location. when I had a match I calculated the bearing. I didn't get a definitive answer to the findNavAid functionality but after reading through the stuff at xsquawkbox It helped me understand how to use it effectively. I changed my code and now i have no iterations at all, just a simple search and some validity checking before the bearing calc's. It's really quite simple with Gizmo. Thanks Ben.
  15. Well I took Jim's advice and re-tracked this little project down the nav database lookup route. I've got to say the things that are possible with Gizmo and the relative lack of time they take to implement is absolutely brilliant. Take me a relative newbie ( about 6 weeks in) to gizmo development and I have been able to not only get all this working but in a matter of a couple of days. That said, I do wish the API documentation was better. I personally think some example code on each page of the API of how to use each function would help greatly. It wasn't all plain sailing but most of my troubles were down to the version of Gizmo (11.5.25) i was using. I also had to update X-plane from 10.02r1 to 10.21. It registered with me when I read a post which mentioned the nav api functions not working correctly in my version. After switching to the latest beta release progress was a lot smoother. I have everything that I originally asked about working. I'm thrilled with the results. But I do have some questions with respect to the nav api and albeit off topic Gizmo in general. I started by using navaid_id = nav.getFirstNavAidOfType(4) which correctly returned the id of the first VOR, after checking to see if it matched what I was looking for I then tried to use navaid_id = nav.getNextNavAid(4). it did not return the id of the next VOR navaid in the database. It simply returned a number 1 higher than the nav_type, in this case 5. Anyone got any ideas why? When using the nav.findNavAid function how do you cycle through all the results that match your search criteria or do you only have access to the one match? Can I get versions of Gizmo between 11.5.25 and the current beta release. If so how? The reason i'm asking is i've been having many crashes with X-plane 10.21 and I'm pulling my hair out trying to even get it to run. 10.02r1 ran fine every time. I believe the latest Gizmo beta will only run on 10.20 or above.
  16. Thanks again Jim. I revised your code slightly as follows to force the stby numbers to update on aircraft load and also to do the swap thing if not only the main freq changed but also if the stby freq changes. Everything worked as expected. However my joy was short lived when I realised that I have overlooked one major thing in my revised on frequency change thinking. Its Ok while testing this while static, but as soon as you start moving and the heading changes the stby frequency bearing will not update until you change frequency. The idea is that both the main and stby frequencies should drive a changing bearing number as you turn the aircraft. Not sure if this if possible without the annoying blip during frequency swap. I tried slowing the update down with a basic count loop by only swapping and grabbing the stby bearing every so many counts but IMO it's an un-acceptable trade off between blip and bearing update rates. I was intending to use this data to drive a HSI stby bearing pointer just like in the real world. Its a shame bearing, relative_bearing or both are not available in the standard x-plane datarefs. -- FIND THE XP DATAREFSDRnav1_frequency = xp.getDataref("sim/cockpit2/radios/actuators/nav1_frequency_hz")DRnav1_stby_frequency = xp.getDataref("sim/cockpit2/radios/actuators/nav1_standby_frequency_hz")DRtest_relative_bearing_deg = xp.getDataref("sim/cockpit2/radios/indicators/nav1_relative_bearing_deg")-- SCRIPT SCOPE LOCAL VARIABLESlocal sw, sh = gfx.getScreenSize()local nav1_freq_b4_swap = xp.getInt(DRnav1_frequency)local nav1_stby_freq_b4_swap = xp.getInt(DRnav1_stby_frequency)local nav1_bearing_b4_swap = xp.getFloat(DRtest_relative_bearing_deg)local nav1_freq_after_swap = 0local nav1_stby_freq_after_swap = 0local nav1_bearing_after_swap = 0local old_freq = 0 -----local delay_timer = nil ------- local delay_flag = 1 --------local count = 0function main() swap_on_freq_change() -----end-- TEST FREQUENCY FOR CHANGE AND SWAP TO GET STANDBY BEARINGfunction swap_on_freq_change() -- GET THE INITIAL DATA if delay_flag == 1 then ----- nav1_freq_b4_swap = xp.getInt(DRnav1_frequency) nav1_stby_freq_b4_swap = xp.getInt(DRnav1_stby_frequency) nav1_bearing_b4_swap = xp.getFloat(DRtest_relative_bearing_deg) end count = count + 1 -- CHECK FOR CHANGE IN FREQUENCY if (nav1_freq_b4_swap ~= old_freq or nav1_stby_freq_b4_swap ~= old_stby_freq or count==100) then -- SWAP THE FREQUENCIES xp.setInt(DRnav1_frequency, nav1_stby_freq_b4_swap) xp.setInt(DRnav1_stby_frequency, nav1_freq_b4_swap) -- GET THE SWAPPED FREQUENCIES nav1_freq_after_swap = xp.getInt(DRnav1_frequency) nav1_stby_freq_after_swap = xp.getInt(DRnav1_stby_frequency) -- GET THE SWAPPED FREQUENCY BEARING & RESET THE FREQUENCIES delay_flag = 0 delay_timer = timer.newOneShot("delay_get_bearing", 0.1) -- SET COMPARISON FREQUENCY old_freq = nav1_freq_b4_swap old_stby_freq = nav1_stby_freq_b4_swap count = 0 endend-- DELAY TIMER FUNCTIONfunction delay_get_bearing() nav1_bearing_after_swap = xp.getFloat(DRtest_relative_bearing_deg) xp.setInt(DRnav1_frequency, nav1_freq_b4_swap) xp.setInt(DRnav1_stby_frequency, nav1_stby_freq_b4_swap) delay_flag = 1end-- DRAW THE DATAfunction OnDraw_Windows() gfx.drawString(nav1_freq_b4_swap .. " / " .. nav1_stby_freq_b4_swap .. " / " ..nav1_bearing_b4_swap, sw/2, sh-200) gfx.drawString(nav1_freq_after_swap .. " / " .. nav1_stby_freq_after_swap .. " / " ..nav1_bearing_after_swap, sw/2, sh-220)end
  17. I'm really struggling to get this to work correctly. Jim's code works very nicely as a one shot capture. However if I try to stick anything like this into a function called from main such that it gets updated continually than I get flickering frequencies due to the required delay. I thought maybe that rather than continually calling this as a function I could use a hooked dataref linked to the frequencies to only call it when a frequency changes. However I could not get the hooked dataref code to work at all. The OnRead seemed to be continually called but I just could not get the OnWrite to trigger at all. Does the hooked dataref idea seem likely to work in this case? if not any suggestions on a better way to implement this. In any case I really would like to understand the specifics of how the OnRead and OnWrite functions work with a working code example. This is what I played around with. I created a custom dataref with a hook nav1_frequency_changed_toggle = xp.newDataref("sim/aircraft/custom/nav1_frequency_changed_toggle", "NAV1_freq_changed" )then created a function to check the frequencies for change and if changed flip my custom dataref between its 2 states 0 and 1. nav1_freq_existing = 0nav1_stby_freq_existing = 0function NAV1_changed_toggle()local drnav1_frequency = xp.getDataref("sim/cockpit2/radios/actuators/nav1_frequency_hz")local drnav1_stby_frequency = xp.getDataref("sim/cockpit2/radios/actuators/nav1_standby_frequency_hz")local nav1_freq_new = xp.getInt(drnav1_frequency) local nav1_stby_freq_new = xp.getInt(drnav1_stby_frequency)local toggle = xp.getFloat(nav1_frequency_changed_toggle) if(nav1_freq_existing < nav1_freq_new or nav1_freq_existing > nav1_freq_new)then nav1_freq_existing = nav1_freq_new if(toggle == 0) then xp.setFloat(nav1_frequency_changed_toggle, 1) else xp.setFloat(nav1_frequency_changed_toggle, 0) endelse if(nav1_stby_freq_existing < nav1_stby_freq_new or nav1_stby_freq_existing > nav1_stby_freq_new)then nav1_stby_freq_existing = nav1_stby_freq_new if(toggle == 0) then xp.setFloat(nav1_frequency_changed_toggle, 1) else xp.setFloat(nav1_frequency_changed_toggle, 0) endendendendI was hoping that everytime I wrote to the dataref (only when frequencies changed) it would trigger the associated NAV1_freq_changed_OnWrite function which in turn called a function similar in operation to the code Jim posted. As previously stated I could not get the OnWrite function to run. Obviously I must not be doing something right but i've looked at the API information and can't see what i've overlooked.
  18. Thanks Jim It proves my concept was right just the implementation that wasn't quite right. The example you gave being a one time thing isn't exactly what I need but I think I can make this work continually for my application. I thought it may have been something to do with timing and did experiment a little with while loops to slow things down but didn't get anywhere with it. I'm still getting to know the API and the one shot timer looks like it will come in handy for other stuff too. I'll post back when I get it working as required. I did realise 2 of the functions where identical. It was just how the functions ended up after lots of experimenting and changes. I'll streamline the final version.
  19. test3 and test4 are custom dataref created elsewhere in code. I have 10 custom datarefs setup for testing. test3 represents the nav1 main frequenciy just after the swap and test4 is the nav1 relative bearing just after the swap. As explained in the original post test3 correctly shows the swapped frequency (113.50), but test4 does not show the bearing for this frequency. It shows the bearing for the original main frequency (116.50). For testing i'm setup on runway 02C at WSSS and my nav1 main and standby frequencies are 116.50 & 113.50.
  20. Thanks for the reply, script file is attached. Do you think what I am trying to achieve is possible? Each of the 3 functions are called in turn from main. The dataref registration is taken care of elsewhere (this is not included in the attached code as all this is working just fine) radios.txt
  21. Hi, I've been watching over these forums for a little while now and have managed to figure out answers to most of my questions from the help on here and my own tinkerings. My latest problem however has me baffled. I am trying to script some custom dataref sources for the implementation of a nav radio that provides a bearing output for the standby frequency. My thinking rightly or wrongly is that I should be able to briefly swap the main and standby nav frequencies in code grab the relative_bearing_deg dataref based on the now swapped frequency info and store in a new custom dataref before reverting the frequencies back to original. what i'm finding is that although a snap shot of the frequencies shows they are swapped at that point in the code, the relative_bearing_deg dataref at the same point in code still reports the bearing for the original main frequency and not the frequency that is now swapped into the main location. What am I missing here? The code at the point of setting the standby bearing dataref is shown below. Before and after this code (not shown) are functions to swap the main and standby frequencies. The functions are independently called in order directly from main. local test_relative_bearing_deg = xp.getDataref("sim/cockpit2/radios/indicators/nav1_relative_bearing_deg") local test_stby_bearing = xp.getFloat(test_relative_bearing_deg) xp.setFloat(test4, test_stby_bearing) I'm new to gizmo and x-plane so hopefully its just something basic that i'm overlooking.
×
×
  • Create New...