Re: Need help with lua? - LunaLua General Help
Posted: Sat Feb 10, 2018 1:57 pm
A lot of those tags are specifically for PGE and won't have any effect on SMBX, just the editor.
Forums for SMBX
https://www.smbxgame.com/forums/
https://wohlsoft.ru/pgewiki/How_To:_Ove ... ayer_inputElectriking wrote:Does anyone know how to disable the ability to jump (all types)?
Try using code tags (also shows the indentation):Taycamgame wrote:https://wohlsoft.ru/pgewiki/How_To:_Ove ... ayer_inputElectriking wrote:Does anyone know how to disable the ability to jump (all types)?
I haven't tried it myself, but:
I think you need to look at the part called "Disable Spin Jump". Copy that code into your lunadll file but instead of saying altJumpKeyPressing just put JumpKeyPressing.
Idk if this would work but logically it should.
function onInputUpdate()
if(player.JumpKeyPressing) then
player.JumpKeyPressing = false;
end
end
Code: Select all
[code]
Code: Select all
function onInputUpdate()
player.jumpKeyPressing = false;
player.altJumpKeyPressing = false;
end
Any idea how to make vegetable blocking blocks as I mentioned earlier?PixelPest wrote:Try using code tags (also shows the indentation):Taycamgame wrote:https://wohlsoft.ru/pgewiki/How_To:_Ove ... ayer_inputElectriking wrote:Does anyone know how to disable the ability to jump (all types)?
I haven't tried it myself, but:
I think you need to look at the part called "Disable Spin Jump". Copy that code into your lunadll file but instead of saying altJumpKeyPressing just put JumpKeyPressing.
Idk if this would work but logically it should.
function onInputUpdate()
if(player.JumpKeyPressing) then
player.JumpKeyPressing = false;
end
end
[/code]Code: Select all
[code]
Also you don't even need to check for it and if you want to add no spinjumping either:
Code: Select all
function onInputUpdate() player.jumpKeyPressing = false; player.altJumpKeyPressing = false; end
Looks more simple, guess i almost had it. But doesn't that code run every time the player presses any key (including the arrow keys)? I thought the function OnInputUpdate checks for every key press, and to limit it to one key you use if?PixelPest wrote:Code: Select all
function onInputUpdate() player.jumpKeyPressing = false; player.altJumpKeyPressing = false; end
I'd suggest approaching it like this:Nonlen17 wrote:How do I make it so the image I load with Graphics.loadImage when an certain event activates will not disappear the next frame?
Code: Select all
local hasTriggered = false;
local myImg = Graphics.loadImage("myImg");
function onEvent(eventname)
if eventname == "myEvent" then
hasTriggered = true;
end
end
function onDraw()
if hasTriggered then
--draw the image here
end
end
NPC.spawn returns the NPC object. You can then immediately set it's direction field to player:mem(0x106, FIELD_WORD)WildWEEGEE wrote:How can I make an NPC that is spawned using NPC.spawn face the direction that the player is facing when spawned?
I don't know where I can place this piece of code...PixelPest wrote:NPC.spawn returns the NPC object. You can then immediately set it's direction field to player:mem(0x106, FIELD_WORD)WildWEEGEE wrote:How can I make an NPC that is spawned using NPC.spawn face the direction that the player is facing when spawned?
Code: Select all
function onKeyDown(keycode)
if keycode == KEY_RUN then
a = NPC.spawn(108,player.x,player.y - 48,player.section)
a.speedX = -6;
end
end
Hey Pixel, is there anyway to block vegetables (Or throw-able items in general) with a line of code which can be applied to a block?PixelPest wrote:NPC.spawn returns the NPC object. You can then immediately set it's direction field to player:mem(0x106, FIELD_WORD)WildWEEGEE wrote:How can I make an NPC that is spawned using NPC.spawn face the direction that the player is facing when spawned?
How long have you been searching for the answer to that? Months? All of your posts have been ignored... anywayThe_Loaf_Lord wrote:Hey Pixel, is there anyway to block vegetables (Or throw-able items in general) with a line of code which can be applied to a block?PixelPest wrote:NPC.spawn returns the NPC object. You can then immediately set it's direction field to player:mem(0x106, FIELD_WORD)WildWEEGEE wrote:How can I make an NPC that is spawned using NPC.spawn face the direction that the player is facing when spawned?
P.S: Nice profile picture
I can answer your second question just not your first. To achieve this you can have an NPC that looks like a switch block placed where the switch would be. When the NPC is killed by a vegetable it will trigger an event that spawns a new switch block NPC in the same place plus turn those switch blockers into the pass-through able backgrounds, vice versa.TheLoafLord wrote:is it possible to use LunaLua to make it so that when you throw a vegetable at a switch block it activates?
Ah, I got one answer! Thank you!WildWEEGEE wrote:How long have you been searching for the answer to that? Months? All of your posts have been ignored... anywayThe_Loaf_Lord wrote:Hey Pixel, is there anyway to block vegetables (Or throw-able items in general) with a line of code which can be applied to a block?PixelPest wrote: NPC.spawn returns the NPC object. You can then immediately set it's direction field to player:mem(0x106, FIELD_WORD)
P.S: Nice profile pictureI can answer your second question just not your first. To achieve this you can have an NPC that looks like a switch block placed where the switch would be. When the NPC is killed by a vegetable it will trigger an event that spawns a new switch block NPC in the same place plus turn those switch blockers into the pass-through able backgrounds, vice versa.TheLoafLord wrote:is it possible to use LunaLua to make it so that when you throw a vegetable at a switch block it activates?
I haven't tried it myself, but perhaps lava could work in this situation? Just reskin it to make it look like the blocks you need.The_Loaf_Lord wrote:Is it possible to make a block using LunaLua that kills off thrown items when they touch it? We all know that vegetables, when thrown, pass through walls, but I want to make a puzzle where the vegetable has to hit a certain receptacle while avoiding "No-Vegetable" blocks.
Code: Select all
noblockcollision=0
Yes but when throwing them, they pass right through blocks.Enjl wrote:Vegetables already have block collision. That's how they don't fall through the ground when simply placed.