Advertisement
Guest User

Custom ME Aircraft Properties

a guest
Oct 23rd, 2016
210
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.41 KB | None | 0 0
  1. -- To add a custom properties tab to aircraft in the Mission Editor, add the following structure within the aircraft definition in the aircraft lua.
  2.  
  3. AddPropAircraft = {
  4.     { id = "CheckboxPlaceholder" , control = 'checkbox', label = _('Checkbox Placeholder'), defValue = false },
  5.     { id = "MassChangePlaceholder" , control = 'checkbox', label = _('Mass Change Placeholder'), defValue = false, weight = 500},
  6.     { id = "CombolistPlaceholder" , control = 'comboList', label = ('Combolist Placeholder'), defValue = 0,
  7.         values = {
  8.             { id = 0, dispName = _("ITEM1")},
  9.             { id = 1, dispName = _("ITEM2")},
  10.             },},
  11.     { id = "SliderPlaceholder", control = 'slider', label = _('Slider Placeholder'), defValue = 90, min = 0, max = 100, dimension = '%'},
  12. },
  13.  
  14. -- To read these properties in LUA:
  15. get_aircraft_property("<PROPERTY_NAME>")
  16. --returns an integer of the option value (0 or 1 for checkbox and 0 based index of combolist option)
  17.  
  18. -- To read these properties in C++ (Two methods):
  19. -- EFM functions:  
  20. //////////////////
  21. void ed_fm_set_property_numeric(const char * property_name, float value)
  22. {
  23.     std::string s_property_name = std::string(property_name);
  24.     if (s_property_name.compare("<PROPERTY_NAME>") == 0)
  25.     {
  26.     //use float value
  27.     }
  28. }
  29. void ed_fm_set_property_string(const char * property_name, const char * value)
  30. {
  31.     std::string s_property_name = std::string(property_name);
  32.     if (s_property_name.compare("<PROPERTY_NAME>") == 0)
  33.     {
  34.     //use string value
  35.     }
  36. }
  37. /////////////////
  38.  
  39. -- exported dll function ed_cockpit_aircraft_get_property:
  40. /////////////////////////////////
  41. // define structure of data returned
  42. struct  aircraft_property
  43. {
  44.     const char* s_val;
  45.     float val;
  46. };
  47.  
  48. //create a typedef for the function prototype
  49. typedef aircraft_property (*PFN_ED_COCKPIT_AIRCRAFT_GET_PROPERTY)(const char* property_name);
  50. //grab the dll
  51. HMODULE cockpit_dll = GetModuleHandle("CockpitBase.dll");
  52. //get the function address
  53. PFN_ED_COCKPIT_AIRCRAFT_GET_PROPERTY aircraft_get_property = (PFN_ED_COCKPIT_AIRCRAFT_GET_PROPERTY)GetProcAddress(cockpit_dll, "ed_cockpit_aircraft_get_property");
  54.  
  55. // declare property structure
  56. aircraft_property prop;
  57. // get property data
  58. prop = aircraft_get_property("<PROPERTY_NAME>");
  59. // use property float data with:
  60. prop.val
  61. // or use character string data with:
  62. prop.s_val
  63. ////////////////////////////////
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement