Question C++ to Lua conversion

johnnymanly

Donator
Donator
Joined
Mar 17, 2008
Messages
179
Reaction score
116
Points
43
Location
Southwest Pennsylginia
Website
sites.google.com
I'm just learning Lua and I tried to convert this C++ code
C:
int i;
        
        for (i = 0; i < 6; i++) {
            oapiVCRegisterArea (MFD1_LBUTTON1+i, PANEL_REDRAW_NEVER, PANEL_MOUSE_LBDOWN);
            oapiVCSetAreaClickmode_Spherical(MFD1_LBUTTON1+i, _V(-0.31, 0.0547 - (i * 0.0245), 0.649), 0.0123);
            
            oapiVCRegisterArea (MFD1_RBUTTON1+i, PANEL_REDRAW_NEVER, PANEL_MOUSE_LBDOWN);
            oapiVCSetAreaClickmode_Spherical(MFD1_RBUTTON1+i, _V(-0.107, 0.0547-(i * 0.0245), 0.649), 0.0123);
        }
All I could come up with is
Code:
local i

  for i=0, i<6, i=i+1 do
    oapi.VC_register_area (MFD1_LBUTTON1+i, PANEL_REDRAW_NEVER, PANEL_MOUSE_LBDOWN)
    oapi.VC_set_areaclickmode_spherical(MFD1_LBUTTON1+i, _V(-0.31, 0.0547 - (i * 0.0245), 0.649), 0.0123)

    oapi.VC_register_area (MFD1_RBUTTON1+i, PANEL_REDRAW_NEVER, PANEL_MOUSE_LBDOWN)
    oapi.VC_set_areaclickmode_spherical(MFD1_RBUTTON1+i, _V(-0.107, 0.0547-(i * 0.0245), 0.649), 0.0123)
  end
which is incorrect.
Can anyone point me in the right direction?
 
Thanks Gondos, that's it.
No problem, also if you haven't noticed it yet, the constants are not defined in the same way so you need to adjust you code for it :
PANEL_REDRAW_NEVER -> PANEL_REDRAW.NEVER
PANEL_MOUSE_LBDOWN -> PANEL_MOUSE.LBDOWN
 
Back
Top