Forum rules
Before you make a topic/post, consider the following:
-Is there a topic for this already?
-Is your post on topic/appropriate?
-Are you posting in the right forum/following the forum rules?
HenryRichard wrote:Is there a way to trigger events when you collide with a block? I know there is if you use autocode, but I'd rather use Lua if it's possible.
Yes there is. You can use the Block:collidesWith function + triggerEvent function. But I don't have a sample code at the moment.
HenryRichard wrote:EDIT: Also, is there any way to scale/transform images that are displayed? We could do a ton of cool things if that's possible...
not yet, but with the new opengl render coming, we will see what is possible
HenryRichard wrote:Is there a way to trigger events when you collide with a block? I know there is if you use autocode, but I'd rather use Lua if it's possible.
Yes there is. You can use the Block:collidesWith function + triggerEvent function. But I don't have a sample code at the moment.
That's good to know - to bad I can't figure out how to get it to work since I'm a complete l=Lua noob and all I know is based off of Java and C. If you do happen to make an example at some point, I'd like to see it.
Kevsoft wrote:
HenryRichard wrote:EDIT: Also, is there any way to scale/transform images that are displayed? We could do a ton of cool things if that's possible...
not yet, but with the new opengl render coming, we will see what is possible
Let's hope for the best - even if we can't scale or rotate, we're still gonna be able to do great things!
Also, I can't seem to get a line of text that displays your current star count. I tried to use this -
I did that before, only adds 1 every time the key is pressed, I want to make it so that while I'm holding down the key, it would add 1, so I could use it like a timer.
Example would be this
I tried to mess with this, but couldn't get it to work.
local isLayerShown = false
function onLoop()
if (player.x > -200000 and isLayerShown == false) then
triggerEvent("ShowLayer")
isLayerShown = true
else
if(isLayerShown == true)then
triggerEvent("HideLayer")
end
end
end
local isLayerShown = false
function onLoop()
if (player.x > -200000 and isLayerShown == false) then
triggerEvent("ShowLayer")
isLayerShown = true
elseif(player.x <= -200000 and isLayerShown == true)then
triggerEvent("HideLayer")
isLayerShown = false
end
end
function onLoop()
cannonBlocks = findblocks(34);
for k,v in pairs(cannonBlocks) do
if(v:collidesWith(player) == 1) then
cannon(player);
elseif(v:collidesWith(player2) == 1) then
cannon(player2);
end
end
end
function cannon(thePlayer)
thePlayer.x = thePlayer.x + 240;
thePlayer.y = thePlayer.y - 256;
thePlayer.speedX = 12;
thePlayer.speedY = -12;
thePlayer.HasJumped = -1;
thePlayer.FacingDirection = 1;
--playSFXSDL("SM64-cannonfire.wav");
end
The level loads fine, but the game freezes when I test, and I get a "SuperMarioBrosX.org has stopped working" window. Is this a problem with my installation or my code or my computer or something else?
What really frustrates me is that it was working just fine but then just stopped working...
EDIT: I just tried re-installing lunalua, and I think it was a bit outdated. However, it's still freezing.
function onLoop()
cannonBlocks = findblocks(34);
for k,v in pairs(cannonBlocks) do
if(v:collidesWith(player) == 1) then
cannon(player);
if(player2) then
if(v:collidesWith(player2) == 1) then
cannon(player2);
end
end
end
end