We usually use code tags (see the '#' button in the message editing formatting selectors).
But I haven't run into any style Nazi's in these forums... but if you google "Lua code" you'll get links to all kinds of examples of the 'standard' style. Most important thing is adopting a strict approach to variable/table naming, and indentation. Done consistently, both will make your life much easier when it comes to the 'why doesn't this work?' stage. Most people use the lowerUpperUpper naming style like weaponDeckPos. There's also a good argument for just using all lowercase and underscores like you did - weapon_deck_pos. Use whichever you like, it shouldn't phase anyone trying to help you either way.
Indentation helps you know the boundaries of chunks of code. For your last snippet, the indentation below makes the start and end of the function and 'for' loop obvious.
Code:
function set_weapon_pos()
local x=1
wpos_x=weapon_deck_pos.x+2.7
for i=1,3 do
local params = {}
params.flip=true
params.position={wpos_x,weapon_deck_pos.y,weapon_d eck_pos.z}
weapon_deck.takeObject(params)
if x==1 then wpos_x=wpos_x+3 end
if x==2 then wpos_x=wpos_x+2.7 end
x=x+1
end
W1=1
W2=1
W3=1
end
Note that I moved the 'local' tag on the 'x' variable from near the bottom to the top. The 'local' tag just only go on the very first instance of a variable/table within a section of code that it exists in. As far as I know, it causes Lua to create a new variable which in your version would mean the 'x' at the end would not be the same variable as the 'x' at the beginning. Even though they have the same name.