This is the place for discussion and support for LunaLua and related modifications and libraries.
Moderator: Userbase Moderators
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?
|
|
|
|
-
Rixitic
- Spike

- Posts: 272
- Joined: Sat Dec 12, 2015 1:00 am
-
Contact:
Postby Rixitic » 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.
|
|
|
|
|
|
|
|
|
-
erkyp3rky
- Ninji

- Posts: 934
- Joined: Fri Apr 15, 2016 1:41 am
- Flair: formerly theloaflord
Postby erkyp3rky » Wed Feb 14, 2018 5:00 am
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.
Which leads me to my second question, is it possible to use LunaLua to make it so that when you throw a vegetable at a switch block it activates? Thanks!
|
|
|
|
|
|
|
|
|
-
ElectriKong
- Bowser

- Posts: 4651
- Joined: Mon Jun 06, 2016 4:32 pm
- Flair: I have NO idea what to put here
- Pronouns: he/him
-
Contact:
Postby ElectriKong » Tue Mar 06, 2018 4:43 pm
Does anyone know how to disable the ability to jump (all types)?
|
|
|
|
|
|
|
|
|
-
Taycamgame
- Gold Yoshi Egg

- Posts: 1483
- Joined: Mon Jun 19, 2017 11:35 am
- Flair: Stargard
-
Contact:
Postby Taycamgame » Tue Mar 06, 2018 4:50 pm
Electriking wrote:Does anyone know how to disable the ability to jump (all types)?
https://wohlsoft.ru/pgewiki/How_To:_Ove ... ayer_input
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
|
|
|
|
|
|
|
|
|
-
PixelPest
- Link

- Posts: 7111
- Joined: Sun Jul 12, 2015 5:38 pm
- Flair: Tamer of Boom Booms
-
Contact:
Postby PixelPest » Tue Mar 06, 2018 7:59 pm
Taycamgame wrote:Electriking wrote:Does anyone know how to disable the ability to jump (all types)?
https://wohlsoft.ru/pgewiki/How_To:_Ove ... ayer_input
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
Try using code tags (also shows the indentation):
[/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
|
|
|
|
|
|
|
|
|
-
erkyp3rky
- Ninji

- Posts: 934
- Joined: Fri Apr 15, 2016 1:41 am
- Flair: formerly theloaflord
Postby erkyp3rky » Tue Mar 06, 2018 11:53 pm
PixelPest wrote:Taycamgame wrote:Electriking wrote:Does anyone know how to disable the ability to jump (all types)?
https://wohlsoft.ru/pgewiki/How_To:_Ove ... ayer_input
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
Try using code tags (also shows the indentation):
[/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
Any idea how to make vegetable blocking blocks as I mentioned earlier?
|
|
|
|
|
|
|
|
|
-
Taycamgame
- Gold Yoshi Egg

- Posts: 1483
- Joined: Mon Jun 19, 2017 11:35 am
- Flair: Stargard
-
Contact:
Postby Taycamgame » Wed Mar 07, 2018 3:22 am
PixelPest wrote:
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?
|
|
|
|
|
|
|
|
|
-
Hoeloe
- Phanto

- Posts: 1465
- Joined: Sat Oct 03, 2015 6:18 pm
- Flair: The Codehaus Girl
- Pronouns: she/her
Postby Hoeloe » Wed Mar 07, 2018 4:48 am
onInputUpdate runs every frame, not every time you press a key. And even if that were the case, a condition inside the function definition wouldn't stop the function from running.
|
|
|
|
|
|
|
|
|
-
Nonlen17
- Goomba

- Posts: 3
- Joined: Thu Nov 09, 2017 1:47 am
Postby Nonlen17 » Fri Mar 30, 2018 10:05 pm
How do I make it so the image I load with Graphics.loadImage when an certain event activates will not disappear the next frame?
|
|
|
|
|
|
|
|
|
-
PixelPest
- Link

- Posts: 7111
- Joined: Sun Jul 12, 2015 5:38 pm
- Flair: Tamer of Boom Booms
-
Contact:
Postby PixelPest » Fri Mar 30, 2018 10:30 pm
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?
I'd suggest approaching it like this:
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
Set a variable that represents the state as to whether or not your event has been triggered (hasTriggered), initially being false. Also load your image at the start and set it as a variable (myImg). Then in your onEvent if the eventname is the one you're looking for set the variable hasTriggered to true. In your onDraw (this runs every frame) check if hasTriggered is true (if hasTriggered then) and then draw your image (myImg).
Since you said it's appearing for one frame I assumed you have the line already for drawing the code so I didn't include one. If you have any questions about anything in the code feel free to ask and I can explain it better if needed
|
|
|
|
|
|
|
|
|
-
WildW
- Rocky Wrench

- Posts: 676
- Joined: Thu Dec 14, 2017 2:21 pm
- Flair: C# more like Db
- Pronouns: he/him
Postby WildW » Tue Apr 03, 2018 4:44 pm
How can I make an NPC that is spawned using NPC.spawn face the direction that the player is facing when spawned?
|
|
|
|
|
|
|
|
|
-
PixelPest
- Link

- Posts: 7111
- Joined: Sun Jul 12, 2015 5:38 pm
- Flair: Tamer of Boom Booms
-
Contact:
Postby PixelPest » Tue Apr 03, 2018 4:55 pm
WildWEEGEE wrote:How can I make an NPC that is spawned using NPC.spawn face the direction that the player is facing when spawned?
NPC.spawn returns the NPC object. You can then immediately set it's direction field to player:mem(0x106, FIELD_WORD)
|
|
|
|
|
|
|
|
|
-
WildW
- Rocky Wrench

- Posts: 676
- Joined: Thu Dec 14, 2017 2:21 pm
- Flair: C# more like Db
- Pronouns: he/him
Postby WildW » Tue Apr 03, 2018 5:24 pm
PixelPest wrote:WildWEEGEE wrote:How can I make an NPC that is spawned using NPC.spawn face the direction that the player is facing when spawned?
NPC.spawn returns the NPC object. You can then immediately set it's direction field to player:mem(0x106, FIELD_WORD)
I don't know where I can place this piece of code...
this is the script I'm using:
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
It's WIP but so far it can only spawn the object facing left.
|
|
|
|
|
|
|
|
|
-
erkyp3rky
- Ninji

- Posts: 934
- Joined: Fri Apr 15, 2016 1:41 am
- Flair: formerly theloaflord
Postby erkyp3rky » Wed Apr 04, 2018 1:15 am
PixelPest wrote:WildWEEGEE wrote:How can I make an NPC that is spawned using NPC.spawn face the direction that the player is facing when spawned?
NPC.spawn returns the NPC object. You can then immediately set it's direction field to player:mem(0x106, FIELD_WORD)
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?
P.S: Nice profile picture 
|
|
|
|
|
|
|
|
|
-
WildW
- Rocky Wrench

- Posts: 676
- Joined: Thu Dec 14, 2017 2:21 pm
- Flair: C# more like Db
- Pronouns: he/him
Postby WildW » Wed Apr 04, 2018 1:32 am
The_Loaf_Lord wrote:PixelPest wrote:WildWEEGEE wrote:How can I make an NPC that is spawned using NPC.spawn face the direction that the player is facing when spawned?
NPC.spawn returns the NPC object. You can then immediately set it's direction field to player:mem(0x106, FIELD_WORD)
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?
P.S: Nice profile picture 
How long have you been searching for the answer to that? Months? All of your posts have been ignored... anyway
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 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.
|
|
|
|
|
|
|
|
|
-
erkyp3rky
- Ninji

- Posts: 934
- Joined: Fri Apr 15, 2016 1:41 am
- Flair: formerly theloaflord
Postby erkyp3rky » Wed Apr 04, 2018 1:34 am
WildWEEGEE wrote:The_Loaf_Lord wrote:PixelPest wrote:
NPC.spawn returns the NPC object. You can then immediately set it's direction field to player:mem(0x106, FIELD_WORD)
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?
P.S: Nice profile picture 
How long have you been searching for the answer to that? Months? All of your posts have been ignored... anyway
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 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.
Ah, I got one answer! Thank you!
|
|
|
|
|
|
|
|
|
-
WildW
- Rocky Wrench

- Posts: 676
- Joined: Thu Dec 14, 2017 2:21 pm
- Flair: C# more like Db
- Pronouns: he/him
Postby WildW » Wed Apr 04, 2018 1:41 am
No problem 
|
|
|
|
|
|
|
|
|
-
Taycamgame
- Gold Yoshi Egg

- Posts: 1483
- Joined: Mon Jun 19, 2017 11:35 am
- Flair: Stargard
-
Contact:
Postby Taycamgame » Wed Apr 04, 2018 5:37 am
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.
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.
If that doesn't work, then maybe you would have to make the npc hit blocks? What i mean is, try putting this code in your npc text file:
What this does is make it so that the NPC will not actually go through blocks. This may not be exactly what you wanted, but it's the best i can offer i'm afraid.
Hope i could help!
|
|
|
|
|
|
|
|
|
-
Emral
- Cute Yoshi Egg

- Posts: 9887
- Joined: Mon Jan 20, 2014 12:58 pm
- Flair: Phoenix
Postby Emral » Wed Apr 04, 2018 5:41 am
Vegetables already have block collision. That's how they don't fall through the ground when simply placed.
|
|
|
|
|
|
|
|
|
-
erkyp3rky
- Ninji

- Posts: 934
- Joined: Fri Apr 15, 2016 1:41 am
- Flair: formerly theloaflord
Postby erkyp3rky » Wed Apr 04, 2018 6:59 am
Enjl wrote:Vegetables already have block collision. That's how they don't fall through the ground when simply placed.
Yes but when throwing them, they pass right through blocks.
|
|
|
|
|
Return to “LunaLua”
Users browsing this forum: No registered users and 2 guests
|