Re: Need help with lua? - LunaLua General Help
Posted: Tue Jan 16, 2018 12:51 pm
In order for shadows to work, you have to specify what actually casts shadows. That's the shadow geometry.
Forums for SMBX
https://www.smbxgame.com/forums/
I tried this and it didn't work, but the memory list onPixelPest wrote:Notxarb wrote:How can I check whether the player is alive?Code: Select all
player:mem(0x13A, FIELD_WORD) == 0
Can you show your code? I know where the memory list is an you use 0x13A to test the player being alive because 0x13A is the death animation timer. If it's greater than zero the player is no longer alive, while 0x13C only triggers after the player death animation is finishedNotxarb wrote:I tried this and it didn't work, but the memory list onPixelPest wrote:Notxarb wrote:How can I check whether the player is alive?Code: Select all
player:mem(0x13A, FIELD_WORD) == 0
https://wohlsoft.ru/pgewiki/SMBX_Player_Offsets
says that the player death state memory address is 0x13C. I tried both, but neither worked. Am I supposed to replace FIELD_WORD or something?
Code: Select all
Text.print(player:mem(0x13A, FIELD_WORD),150,80)
My mistake it was 0x13E. Sorry.Notxarb wrote:If I want to make a "Time's Up!" graphic and display it when the time runs out, where should I put that graphic and how can I access it in an lua script?
Also, is there no way to make music play faster?
Ok thanks. Also, I suspected I'd have to do that to the music, but that means I'll have to have nearly twice as many songs, and believe me I will be having LOTS of songs in my episode.PixelPest wrote:My mistake it was 0x13E. Sorry.Notxarb wrote:If I want to make a "Time's Up!" graphic and display it when the time runs out, where should I put that graphic and how can I access it in an lua script?
Also, is there no way to make music play faster?
To load a graphics use the Graphics.loadImage function with the argument being the file path. You can place the file in your custom graphics folder along with your lunadll.lua file and your file path will just be the name of your file. Then draw it with Graphics.drawImageWP at a priority of 5 (HUD priority). You also could possibly just use Text.printWP or textblox.lua as well depending on how complicated you want the text to be instead of loading an image file. There's no way to modify music files rn but you can just use a program outside of SMBX to change the speed of the music file and then load and play it in LunaLua
That wouldn't be easy and probably end up pretty ugly if you tried it. I don't think it's planned for Beta4 but it's been discussed for the future iirc. Beta4 will be released before April this year if all goes as planned.Notxarb wrote:If you think about it, do you think you could make artificial 4-players by cloning player 1 and 2 and having player 3 and 4 control those clones?
Also, will 4-players be added in Beta 4? When will Beta 4 come out?
I don't understand. Mario can only travel across connected paths. Maybe be more specific as to what you want to happen? Are you adding paths?Notxarb wrote:We all know how you can travel across any adjacent paths on the world map. Could you use lua scripts to program individual paths so that Mario can only travel across connected parts of paths?
Ok, I'm assuming I'd need a different event for each block I want to use, since that's what tells it where to spawn the powerup.Quantumenace wrote:You could give the block an event that does nothing on being destroyed, and use onEvent() to detect it and spawn the powerup.
Oof... If you wanna rewrite the entire overworld movement system and give every path an identity for where it connects... Be wary that this limits custom graphics for paths or at least makes it more of a hassle to use nonstandard ones. The easy solution is to space out your paths well so that paths bleeding into each other can't happen.Notxarb wrote:We all know how you can travel across any adjacent paths on the world map. Could you use lua scripts to program individual paths so that Mario can only travel across connected parts of paths?
Here's something I wrote just to see if it would work. It automatically handles the NPC contents of the block types listed in the shatterableBlocks table. Note however that P-switches will turn them into coins and they'll lose the contents data as a result.The Dwarven Digger wrote:Ok, I'm assuming I'd need a different event for each block I want to use, since that's what tells it where to spawn the powerup.
Code: Select all
local shatterableBlocks = {4,60}
function onStart()
for k,v in ipairs(Block.get(shatterableBlocks)) do
v:mem(0x50,FIELD_WORD,0)
end
end
function onTickEnd()
for k,v in ipairs(Block.get(shatterableBlocks)) do
if v:mem(0x08,FIELD_WORD) > 1000 and v.isHidden and tostring(v.layerName) == "Destroyed Blocks" then
local n = NPC.spawn(v:mem(0x08,FIELD_WORD)-1000, v.x+0.5*v.width, v.y+0.5*v.height, player.section, false, true)
n.speedY = -6
v:mem(0x08,FIELD_WORD,0)
end
end
end
Thanks! I won't be using P-switches in the same levels as this mechanic, so that aspect isn't a problem. I'll make sure I mention you in the credits for my episode.Quantumenace wrote:Here's something I wrote just to see if it would work. It automatically handles the NPC contents of the block types listed in the shatterableBlocks table. Note however that P-switches will turn them into coins and they'll lose the contents data as a result.The Dwarven Digger wrote:Ok, I'm assuming I'd need a different event for each block I want to use, since that's what tells it where to spawn the powerup.
Code: Select all
local shatterableBlocks = {4,60} function onStart() for k,v in ipairs(Block.get(shatterableBlocks)) do v:mem(0x50,FIELD_WORD,0) end end function onTickEnd() for k,v in ipairs(Block.get(shatterableBlocks)) do if v:mem(0x08,FIELD_WORD) > 1000 and v.isHidden and tostring(v.layerName) == "Destroyed Blocks" then local n = NPC.spawn(v:mem(0x08,FIELD_WORD)-1000, v.x+0.5*v.width, v.y+0.5*v.height, player.section, false, true) n.speedY = -6 v:mem(0x08,FIELD_WORD,0) end end end
No, Enjl was right, and PixelPest was confused. On the main map, you can cross between any adjacent placed paths, regardless of whether they're connected graphically. Just for fun, I was wondering if we could program it so that you can't cross graphically unconnected paths, but as I thought, it wouldn't be worth it.Taycamgame wrote:I think he meant that if you have a crossroad of paths, how would you make only one way open rather than them all (assuming that the crossroad intersection isn't a level)?