A: LunaLua is an SMBX Extension Module.
Q: Where can I download it?
A: viewtopic.php?f=26&t=329 (direct link: http://wohlsoft.ru/LunaLua/)
Q: How to install LunaLua to my SMBX?
A: Go to the link I posted above, it contains every necessary components (which are: SMBX 1.3.0.2 and basically, LunaLua).
Video tutorial:
http://www.youtube.com/watch?v=tIe6ZRgUCAo&feature=youtu.be
Q: AVAST says that LunaLua is a virus.
A: It's a false alarm, ignore it. It is recomended to put an exception for LunaLua in your antivirus too.
Q: How to use LunaLua in my level?
A:
- make LUA file called 'lunadll.lua' (or lunadll.txt for autocode (LunaDLL)) and put it in the same folder directory where you'd usually have custom graphics (if your level is called 'mylevel', create a new folder and call it 'mylevel' - both should be in the same folder!)
- Type your LUA code in lunadll.lua
Q: Any examples of LUA codes?
A:
- LUA code examples
- Makes every blue Shy-Guy running super fast:
Code: Select all
function onLoop()
allNPCs = findnpcs(20,player.section)
for k,v in pairs(allNPCs) do
if(v.direction == DIR_RIGHT)then
v.speedX = 5
else
v.speedX = -5
end
end
end
Makes every blue Shy-Guy jump every 100 frames.Code: Select all
i = 0
function onLoad()
i = 0
end
function onLoop()
i = i + 1
if(i % 100 == 0)then
allNPCs = findnpcs(20,player.section)
for k,v in pairs(allNPCs) do
v.speedY = -8
end
end
end
Let the player jump up when it reaches a specific y-value.Code: Select all
function onLoop()
if(player.y > -200320)then
player.speedY = -10
end
end
Some debug info.Code: Select all
i = 0
function onLoad()
i = 0
end
function onLoop()
printText("RUNNING "..tostring(i).." FRAMES", 30, 30)
printText("PLAYER COOR "..tostring(player.x).." "..tostring(player.y), 30, 60)
end
A new powerup every 200 frames (powerup roulett)Code: Select all
i = 0
function onLoad()
i = 0
end
function onLoop()
i = i + 1
if(i % 200 == 0)then
player.powerup = math.random(1,7)
end
end
A jump-counter with the new variable bank!Code: Select all
function onLoop()
if(UserData.getValue("jump-counter"))then
printText("Jumps: "..tostring(UserData.values()["jump-counter"]), 30, 160) -- values()[value-Name] can be used too, to get the a value
end
end
function onJump(plIndex)
if(UserData.getValue("jump-counter"))then
UserData.setValue("jump-counter", UserData.getValue("jump-counter")+1)
else
UserData.setValue("jump-counter", 1)
end
UserData.save()
end
It's only some basics.
LunaLua documentation:
http://wohlsoft.ru/pgewiki/Category:LunaLua_API
Q: How can I know if my LunaLua works?
A: Once you launch your SMBX via the "Start Game" button, at the top left corner of the screen, you should see "LunaLua v.#.#.#.#" (where #s are version numbers). If you see that, congratulations, your LunaLua works!
Q: Is there any storage for all the LunaLUA APIs (helper libraries)?
A: Yes, most (if not all) LunaLUA APIs are kept here:
http://wohlsoft.ru/pgewiki/Category:LunaLua_helper_libraries
If I didn't answered your questions, then feel free to ask them here!