Hi
I'm starting on a bigger script that involves the use of local variables and an indexed table.
I just want to make sure that I have the initial structure correct.
--Move Entity Sequence 1
local Startcode1 = 0
local Stepcode1 = 1
local Count1 = 500
local Passcode1 = 0
local StartXX = 0
local StartYY = 0
local StartZZ = 0
ObjcontE1 {}
ObjcontE1[1] = 0 -- X Target
ObjcontE1[2] = 0 -- y Target
ObjcontE1[3] = 0 -- z Target
ObjcontE1[4] = 0 -- x or z target 1=x 3=z
ObjcontE1[5] = 0 -- Max Speed
ObjcontE1[6] = 0 -- Min Speed
ObjcontE1[7] = 0 -- ACDC 1=AC 2=DC 0=No ACDC
ObjcontE1[8] = 0 -- ACDC add value
ObjcontE1[9] = 0 -- ACDC begin location
ObjcontE1[10] = 0 -- Total Number of steps in sequence
ObjcontE1[11] = 0 -- Pause Counter
ObjcontE1[12] = 0 -- Type of step 1=move ahead 2=pause. TBD
function aamovseq1_init(e)
-- should set-up of variables be here or above?
end
function aamovseq1_main(e)
if Passcode1 == 0 then
if local Count1 > 0 then local Count1 = local Count1 - 5
end
if local Count1 < 1 then local Count1 = 0;local Passcode = 1
end
end -- Passcode1 = 0 delays first step start
end -- End of main function
1) Is it proper to set up the local variables before the Init statement, or should this be part of the Init code?
2) By making the local declaration those variables are only available for use within this specific LUA script .. Correct?
3) Like the local variables, should the table ObjcontE1 be before the Init statement or part if the Init statement?
4) Are indexed tables global by nature or can they too be localized?
The above code is in the very early stages. Eventually it will move an object through a series of preset targets and at various speeds.
Thanks in advance
"There is no spoon"