Oh man a lot has happened since my last log. I started doing what I never thought I'll ever do; add Lua script support. Long story short
this BlitzMax module is amazing and allows me to easily expose all my classes and related functions to Lua script without much effort at all. This finally made me sit down and learn Lua script, which I found out is pretty crazy but versatile too.
So I have spent most of my time moving my prototype's initaliziation, updating, and rendering code to Lua script, and currently looks like this:
--- Solarance : Procyon Council | Alpha 2
--- Lua Test
--- (C) Ion Trail Productions 2008-2011
require(SCRIPT_FOLDER.."KEY")
function Game_Init()
SystemManager:Initialize()
SystemManager:AddNew("New Avalon",15,7.5)
SystemManager:AddNew("Goldstone",5,-25)
CurrentSystem = SystemManager:Find("Goldstone")
CurrentSystem:LoadResources()
playerShip = NewShip():Create(500,0,"lc/Gladius")
CurrentSystem:AddShip(playerShip)
Starfield:Fill((SCREENW*SCREENH)/3500)
SCREENX = (SCREENW/2) - playerShip.x
SCREENY = (SCREENH/2) - playerShip.y
currentScreen = 1
Planet_Count = 0
end
function Game_Update()
SMALLSCALE = 0.0125
if (currentScreen == 2) then if (KeyDown(KEY.LSHIFT) == 1) then SMALLSCALE = 0.005 end end
if (currentScreen == 2) then if (KeyDown(KEY.LCONTROL) == 1) then SMALLSCALE = 0.025 end end
if KeyHit(KEY.F1) == 1 then currentScreen = 1 end
if KeyHit(KEY.F2) == 1 then currentScreen = 2 end
if KeyHit(KEY.F3) == 1 then currentScreen = 3 end
SystemManager:Update()
if (currentScreen == 1) then
SCREENX = (SCREENW/2) - playerShip.x
SCREENY = (SCREENH/2) - playerShip.y
playerShip.thrustApplied = KeyDown(KEY.UP)
playerShip.turningDir = KeyDown(KEY.RIGHT) - KeyDown(KEY.LEFT)
elseif (currentScreen == 2) then
if KeyDown(KEY.UP) > 0 then SCREENY = SCREENY + (5000.0*DELTATIME) end
if KeyDown(KEY.DOWN) > 0 then SCREENY = SCREENY - (5000.0*DELTATIME) end
if KeyDown(KEY.LEFT) > 0 then SCREENX = SCREENX + (5000.0*DELTATIME) end
if KeyDown(KEY.RIGHT) > 0 then SCREENX = SCREENX - (5000.0*DELTATIME) end
end
end
function Game_Render()
Planet_Count = 0
if (currentScreen == 1) then
Starfield:Draw(3.0)
IsF6Hit = KeyHit(KEY.F6)
ForEach(CurrentSystem.PlanetList,
function (self)
if (self.parent ~= nil) then
--DrawText("Test!! "..self.parent.rx,0,128)
SetAlpha(0.15)
DrawLine(self.rx,self.ry, self.parent.rx,self.parent.ry)
tbDraw:Circle(self.parent.rx, self.parent.ry, self.oDist, 90)
if IsF6Hit == 1 then
PrintConsole(self.Name.." < "..self.parent.Name.." x="..self.parent.rx.." y="..self.parent.ry)
end
SetAlpha(1.0)
end
end )
IsF6Hit = 0
CurrentSystem:Draw()
DrawText("Player Ship: x = "..playerShip.x, 64,64)
DrawText("y = "..playerShip.y, 128+32-3,64+16)
elseif (currentScreen == 2) then
CurrentSystem:DrawSmall()
ForEach(CurrentSystem.PlanetList,
function (planet)
DrawText(planet.Name.." : "..planet.oAngle, SCREENW/2-128, 0+(16*Planet_Count))
Planet_Count=Planet_Count+1
end )
DrawText("Planet Count ".. Planet_Count, 128,128)
elseif (currentScreen == 3) then
SystemManager:Draw(1.0)
DrawText(SystemManager.x.."x"..SystemManager.y ,0,64)
end
--DrawText("CurScn: "..currentScreen, 0,64)
--DrawText("DT: "..DELTATIME, 0,96)--DELTATIME
DrawText("Current System: "..CurrentSystem.Name,0,0)
DrawText("FPS: "..tb:FPS(),0,16)
SetFont(LARGEFONT)
DrawText("Solarance: Lua Test",0,SCREENH-32)
SetFont(SMALLFONT)
end
Planet_DrawSmall = nil--function (self)
--[[
DrawText(self.Name.." : "..self.oAngle,0,24+(16*Planet_Count))
Planet_Count=Planet_Count+1
end
--]]
Planet_Draw = nil--function (self)
-- DrawText(self.Name,self.rx,self.ry)
--end
This is groundbreaking for me, as I love modding and want to make flexibilty in modding a cornerstone of this game. These are folders that mods can be placed in and will overwrite each other depending of their placement in settings.yml, mods listed first will be overwritten by the mods below it. So by placing a "Gladius.png" file under "TestMod/graphics/ships/lc/" it will overwrite the original gladius in "graphics/ships/lc/". But if you listed "Battlestar" mod after "TestMod" then you'll get it's version of Gladius if it has it, if not then nothing will be changed.
I believe this will allow for a great deal of flexibility and control over what mod influences other mods and allow for tweaks of other mods. I am sure I am going to have to tweak this setup eventually, currently only one lua file is tested against. I have begun to list all my class's variables and methods on
my forums. I am also keeping up with a To-Do list for the project in
this other thread In addition to Lua scripting and mod support, I have also added basic frame animation possibilities to all image layers and a functioning Lua Console you can access by hitting tilde.
I hope to have another build ready in the following weeks, after I get bullets working and adding a more flexible hook system to attach lua functions to BlitzMax class method calls.