smallg wrote: "for 'end' statements i recommend getting notepad++ and getting used to indenting your code (tab), it will help you keep track of everything much easier - general rule is to indent everything every time you have an 'if' or similar statement.. i.e."
I agree. Although, I use LuaEditor. It also is free. It has an indent of four spaces which I like and all of us old programmers used that amount of spacing back in the seventies. At least that was how I was taught.
Here is my code snippet of a script created by Mr. VIP, smallg:
--lift script by smallg
local low_height = {}
local high_height = {}
local use_range = {}
local lift_speed = {}
pressed = 0
state = {}
up = {}
function lift2_init_name(e,name)
weapon_name[e] = name
state[e] = "wait"
up[e] = 0
use_range[e] = 60
lift_speed[e] = 75
low_height[e] = 600
high_height[e] = 800
--high_height[6] = 1000
--lift_speed[6] = 200
--lift_speed[7] = 400
--high_height[7] = 2000
CollisionOff(e)
Scale(e,100)
end
function lift2_main(e)
if state[e] == "wait" then
if g_Entity[e]['y'] > low_height[e] and up[e] == 0 then
CollisionOff(e)
MoveUp(e,-10)
--etRotation(e,0,0,0)
elseif g_Entity[e]['y'] < high_height[e] and up[e] == 1 then
CollisionOff(e)
MoveUp(e,20)
--SetRotation(e,0,0,0)
end
if GetPlayerDistance(e) <= use_range[e] then
if g_KeyPressE == 1 and pressed == 0 then
pressed = 1
if g_Entity[e]['y'] <= low_height[e] then
state[e] = "going up"
up[e] = 1
elseif g_Entity[e]['y'] >= high_height[e] - 10 then
state[e] = "going down"
MoveUp(e,-lift_speed[e]/2)
up[e] = 0
end
end
end
elseif state[e] == "going up" and g_Entity[e]['y'] < high_height[e] then
CollisionOff(e)
MoveUp(e,lift_speed[e])
--SetRotation(e,0,0,0)
elseif state[e] == "going down" and g_Entity[e]['y'] > low_height[e] then
CollisionOff(e)
MoveUp(e,-lift_speed[e]/4)
--SetRotation(e,0,0,0)
else
state[e] = "wait"
end
CollisionOn(e)
if GetPlayerDistance(e) <= use_range[e] then
if state[e] == "wait" then
if g_Entity[e]['y'] > low_height[e] + 10 then
Prompt("Press <E> to Go down!")
else
Prompt("Press <E> to Go up!")
end
end
end
if g_KeyPressE == 0 and pressed == 1 then
pressed = 0
end
end
I would like to take the opportunity to thank smallg for what he does for the community. It has helped me get a really fast start with GG. Lua is a far cry from Assembly and COBOL that I started out learning and were the languages I used for several years. I finally learned BASIC and then Visual BASIC and then 'C' for use with the PCs. Lua seems to be similar to 'C' so my learning curve won't be very steep.
BTW, here are two places that whoever wants LuaEditor can download it. They both are Virus free:
CNET, and
SourceForgeWhen in doubt -- C4 :heh, heh, heh:
-Jamie Hyneman