Guest User

Custom ME Aircraft Properties

a guest
Mar 26th, 2016
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.23 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. -- UNKNOWN??
  16.  
  17. -- To read these properties in C++ (Two methods):
  18. -- EFM functions:  
  19. //////////////////
  20. void ed_fm_set_property_numeric(const char * property_name, float value)
  21. {
  22.     std::string s_property_name = std::string(property_name);
  23.     if (s_property_name.compare("<PROPERTY_NAME>") == 0)
  24.     {
  25.     //use float value
  26.     }
  27. }
  28. void ed_fm_set_property_string(const char * property_name, const char * value)
  29. {
  30.     std::string s_property_name = std::string(property_name);
  31.     if (s_property_name.compare("<PROPERTY_NAME>") == 0)
  32.     {
  33.     //use string value
  34.     }
  35. }
  36. /////////////////
  37.  
  38. -- exported dll function ed_cockpit_aircraft_get_property:
  39. /////////////////////////////////
  40. // define structure of data returned
  41. struct  aircraft_property
  42. {
  43.     const char* s_val;
  44.     float val;
  45. };
  46.  
  47. //create a typedef for the function prototype
  48. typedef aircraft_property (*PFN_ED_COCKPIT_AIRCRAFT_GET_PROPERTY)(const char* property_name);
  49. //grab the dll
  50. HMODULE cockpit_dll = GetModuleHandle("CockpitBase.dll");
  51. //get the function address
  52. PFN_ED_COCKPIT_AIRCRAFT_GET_PROPERTY aircraft_get_property = (PFN_ED_COCKPIT_AIRCRAFT_GET_PROPERTY)GetProcAddress(cockpit_dll, "ed_cockpit_aircraft_get_property");
  53.  
  54. // declare property structure
  55. aircraft_property prop;
  56. // get property data
  57. prop = aircraft_get_property("<PROPERTY_NAME");
  58. // use property float data with:
  59. prop.val
  60. // or use character string data with:
  61. prop.s_val
  62. ////////////////////////////////
Add Comment
Please, Sign In to add comment