I have made some changes to the "Default" Script to test something out, and now it won't run at all
How can I force a Script to run more than once (i.e. when I click the Run button, the Script runs)?
When I import the original "Default" Script everything works fine, but when I import my amended version nothing happens.
Here is my amended Script:
- Code: Select all
-- |------------------------------------------------------------------------------------
-- | .: S K Y L I N E :. Default Lua Script. Script containing some common events
-- |------------------------------------------------------------------------------------
obj = 0; -- | Define a global variable for our object ID
count = 0;
-- |------------------------------------------------------------------------------
-- | initialise
-- |------------------------------------------------------------------------------
function onInit(objID)
sky.lprint("\nLUA: Welcome - Hello World!");
obj = objID;
end
-- |------------------------------------------------------------------------------
-- | Update
-- |------------------------------------------------------------------------------
function onUpdate( timeDelta )
-- Do your game loop stuff here....
--sky.lprint("Counter :: "..count);
count = count + 1;
end
function onKeyUp( key )
sky.lprint("Key Released = "..key);
end
-- |------------------------------------------------------------------------------
-- | Mouse Events
-- |------------------------------------------------------------------------------
function onMouseDown( button, x, y )
sky.lprint("Mouse Pos x :"..x.." y : "..y);
sky.lprint("Mouse Button pressed :"..button);
end
function onMouseUp( button,x ,y )
sky.lprint("Mouse Button Clicked");
end
function onMouseMove( x, y )
sky.lprint("MOVING! Pos x :"..x.." y : "..y);
end
-- |------------------------------------------------------------------------------
-- | Object Clicked: see sky.clickObject() for more information
-- |------------------------------------------------------------------------------
function onClick( )
end
-- |------------------------------------------------------------------------------
-- | Stop
-- |------------------------------------------------------------------------------
function onStop()
end
function onKeyDown ( key )
if ( key == "p" ) then
sky.lprint ( "\nLUA: Hello World!" );
obj = objID;
file = io.open("H:/Aurasoft/MapData.csv")
if file == nil then
sky.lprint("NO FILE")
else
sky.lprint("YES FILE")
end
loadCSV ( "H:\Aurasoft\MapData.csv" );
end
end
function readcsv (file)
local fp = assert(io.open (file))
local csv = {}
for line in fp:lines() do
local row = {}
for value in line:gmatch("[^,]*") do -- note: doesn\'t work with strings that contain , values
row[#row+1] = value
end
csv[#csv+1] = row
end
-- csv contains now rows / colums from the csv file, i.e.
return csv
end
function loadCSV ( sCSV )
local tTab={};
local aa, bb, cc, dd, ee
local yy, zz
sky.lprint("In loadCSV")
tTab = readcsv ( sCSV )
yy = table.getn(tTab)
sky.lprint("" .. yy)
for zz = 0 to yy
sky.lprint(sLine)
tTab = fromCSV ( sLine );
aa = tTab [ 0 ]
bb = tTab [ 1 ]
cc = tTab [ 2 ]
dd = tTab [ 3 ]
ee = tTab [ 4 ]
sky.lprint ( aa .. " - " )
sky.lprint ( bb .. " - " )
sky.lprint ( cc .. " - " )
sky.lprint ( dd .. " - " )
sky.lprint ( ee .. "/n" .. "/n" )
end
end
As usual, any help would be greatly appreciated.
Regards
Shando