Need help with lua? - LunaLua General Help

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?
WildW
Rocky Wrench
Rocky Wrench
Posts: 676
Joined: Thu Dec 14, 2017 2:21 pm
Flair: C# more like Db
Pronouns: he/him

Re: Need help with lua? - LunaLua General Help

Postby WildW » Wed Apr 04, 2018 12:52 pm

The_Loaf_Lord wrote:
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.
Image
the shyguys would be the exact same gfx as a bgo placed behind them. simple


If you want to do it this way ill tell you how just ask me to

The0x539
Eerie
Eerie
Posts: 751
Joined: Fri Jan 22, 2016 8:02 pm

Re: Need help with lua? - LunaLua General Help

Postby The0x539 » Wed Apr 04, 2018 12:57 pm

WildWEEGEE wrote:
snip: show
The_Loaf_Lord wrote:
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.
Image
the shyguys would be the exact same gfx as a bgo placed behind them. simple


If you want to do it this way ill tell you how just ask me to
This looks like excessive use of generators compared to spawning using NPC.spawn()

WildW
Rocky Wrench
Rocky Wrench
Posts: 676
Joined: Thu Dec 14, 2017 2:21 pm
Flair: C# more like Db
Pronouns: he/him

Re: Need help with lua? - LunaLua General Help

Postby WildW » Wed Apr 04, 2018 1:02 pm

The0x539 wrote:
WildWEEGEE wrote:
snip: show
The_Loaf_Lord wrote:
Yes but when throwing them, they pass right through blocks.
Image
the shyguys would be the exact same gfx as a bgo placed behind them. simple


If you want to do it this way ill tell you how just ask me to
This looks like excessive use of generators compared to spawning using NPC.spawn()
Well, yea... it's a bit excessive but all of the other events that take place are usable and fix the problem

EDIT: Can someone help me with this?

Code: Select all

local playerDirection = 0

function onLoop()
    playerDirection = player:mem(0x106,FIELD_WORD)

function onTick()
	if player.powerup == PLAYER_FIRE then
		if player.character == CHARACTER_MARIO then
			 if(player.runKeyPressing) then
				a = NPC.spawn(108,player.x,player.y - 48,player.section)
				a.speedX = 6 * playerDirection
				end
			end
		end
	end

end
I've done all sorts of different things to get fire Mario just to shoot the fireball from the flamethrower as a special attack but nothing happens.

Emral
Cute Yoshi Egg
Cute Yoshi Egg
Posts: 9887
Joined: Mon Jan 20, 2014 12:58 pm
Flair: Phoenix

Re: Need help with lua? - LunaLua General Help

Postby Emral » Thu Apr 05, 2018 1:18 pm

First step: Don't define onTick inside of onLoop. Your indenting is completely misleading.
Second step: Consider calling v:transform(newID) on player fireballs instead of spawning a new npc in addition to the fireballs.

Hoeloe
Phanto
Phanto
Posts: 1465
Joined: Sat Oct 03, 2015 6:18 pm
Flair: The Codehaus Girl
Pronouns: she/her

Re: Need help with lua? - LunaLua General Help

Postby Hoeloe » Thu Apr 05, 2018 1:43 pm

Enjl wrote:First step: Don't define onTick inside of onLoop. Your indenting is completely misleading.
Also don't use onLoop at all. onLoop is an old function that was replaced by onTick, so you should only use onTick.

WildW
Rocky Wrench
Rocky Wrench
Posts: 676
Joined: Thu Dec 14, 2017 2:21 pm
Flair: C# more like Db
Pronouns: he/him

Re: Need help with lua? - LunaLua General Help

Postby WildW » Thu Apr 05, 2018 1:45 pm

Hoeloe wrote:
Enjl wrote:First step: Don't define onTick inside of onLoop. Your indenting is completely misleading.
Also don't use onLoop at all. onLoop is an old function that was replaced by onTick, so you should only use onTick.
Can I use the same lines of code underneath onTick that worked using onLoop?

Emral
Cute Yoshi Egg
Cute Yoshi Egg
Posts: 9887
Joined: Mon Jan 20, 2014 12:58 pm
Flair: Phoenix

Re: Need help with lua? - LunaLua General Help

Postby Emral » Thu Apr 05, 2018 1:51 pm

i mean... why would you? The one line you had in onLoop just stores the player direction, and since you only need that once anyway, no need to even store it in a variable.
onTick generally is the same as onLoop, except it runs in a more favourable spot in execution order. It runs after onInputUpdate (unlike onLoop), which means that character inputs are updated properly in it. Basically, within onTick information isn't potentially outdated.

WildW
Rocky Wrench
Rocky Wrench
Posts: 676
Joined: Thu Dec 14, 2017 2:21 pm
Flair: C# more like Db
Pronouns: he/him

Re: Need help with lua? - LunaLua General Help

Postby WildW » Thu Apr 05, 2018 2:00 pm

Sooo... remove the first onLoop and piece of code underneath it?

SoulForTruth41
Cheep-Cheep
Cheep-Cheep
Posts: 11
Joined: Fri Apr 06, 2018 6:50 pm

Re: Need help with lua? - LunaLua General Help

Postby SoulForTruth41 » Tue Apr 10, 2018 11:28 pm

[deleted post]
Last edited by SoulForTruth41 on Wed Apr 11, 2018 1:20 pm, edited 1 time in total.

PixelPest
Link
Link
Posts: 7111
Joined: Sun Jul 12, 2015 5:38 pm
Flair: Tamer of Boom Booms
Contact:

Re: Need help with lua? - LunaLua General Help

Postby PixelPest » Wed Apr 11, 2018 6:36 am

SoulForTruth41 wrote:
Hani wrote:I'll just ask 2 questions at a time.
Would it be possible to make an npc deadly? Like instead of just hurting you, you get instant death.
And, how do I make particles / or set up particles? Like this kind of particle.
Spoiler: show
Image
The lava specks rising into the air.
Well I hope you guys get an answer for these.. Thank you. :)
I realize that this answer is about 2 years too late, but I only recently found out about SMBX and joined your forum. I am working on my own project using SMBX version 1.4.4, and I often find things out through trial and error, and so I wanted to provide what is possibly an easier (albeit less powerful) solution to your question than the one that was provided to you. In the Level Editor, right-click the NPC that you want to modify, to bring up the Custom NPC Code Editor. On the "Graphics" tab, select either "Level Graphics" if you want this rule to apply to just the one level, or "World Graphics" if you want the rule to be universal to your game. Click the tab at the top to get to "Physics/Property". Scroll down to "InstantKill" and put a check mark by it. Nothing changes in the True or False column, it should still read False. Click "Save" at the bottom to save your apparent failed attempt to change the NPC. Save any changes to your level if needed, then close the level (not the Editor), by selecting "New" from the drop-down list under "File". There will now be a TXT file named after the PNG graphic file for the NPC that you modified. If you picked Level Graphics, it will be in the folder associated with the level that you saved. If you picked World Graphics, it will be in the world folder where your WLD file is. Open that TXT file. Look for a line that should read "instantkill=0". 0 means it is False, so change the 0 to a 1 (to make it True), then save the TXT File. Go back to the Level Editor, and re-open your level. Press F5 to test your level, and touch the NPC to find that it will now be Instant Death for your character. I suppose that you could use this method to change the other settings under the "Physics/Property" tab. I hope that this helps someone. ;)
This thread and subforum is about LunaLua, a feature of SMBX2 (and 1.3.0.2). Please do not discuss 38A here. Furthermore please don't respond to really old posts like this; it's very unnecessary

SoulForTruth41
Cheep-Cheep
Cheep-Cheep
Posts: 11
Joined: Fri Apr 06, 2018 6:50 pm

Re: Need help with lua? - LunaLua General Help

Postby SoulForTruth41 » Wed Apr 11, 2018 1:33 pm

My apologies. I didn't know that LunaLua was something separate from SMBX 38A; I thought they were somehow cohesive. I deleted the post.

Hoeloe
Phanto
Phanto
Posts: 1465
Joined: Sat Oct 03, 2015 6:18 pm
Flair: The Codehaus Girl
Pronouns: she/her

Re: Need help with lua? - LunaLua General Help

Postby Hoeloe » Wed Apr 11, 2018 2:08 pm

SoulForTruth41 wrote:My apologies. I didn't know that LunaLua was something separate from SMBX 38A; I thought they were somehow cohesive. I deleted the post.
SMBX38A actually has very little to do with SMBX at all, it's a completely different engine that just happens to look similar.

SMBX2 is the original SMBX, extended with LunaLua and other features.

Murphmario
2025 Egg Hunter
2025 Egg Hunter
Posts: 2389
Joined: Fri Dec 20, 2013 7:07 pm
Pronouns: he/him

Re: Need help with lua? - LunaLua General Help

Postby Murphmario » Sun Apr 22, 2018 8:50 pm

Could I have some code that disables the trails for the Boo Snake? It's for a graphic(s) that I'm working on, and I'm not very good at LunaLua.

And yes, I tried to replace the Podoboo. It doesn't work.

Hoeloe
Phanto
Phanto
Posts: 1465
Joined: Sat Oct 03, 2015 6:18 pm
Flair: The Codehaus Girl
Pronouns: she/her

Re: Need help with lua? - LunaLua General Help

Postby Hoeloe » Sun Apr 22, 2018 9:15 pm

Murphmario wrote:Could I have some code that disables the trails for the Boo Snake? It's for a graphic(s) that I'm working on, and I'm not very good at LunaLua.

And yes, I tried to replace the Podoboo. It doesn't work.
You could always just replace the trail graphic with a blank image.

This'll be even easier to do in Beta 4, when the trail isn't in its own file.

Murphmario
2025 Egg Hunter
2025 Egg Hunter
Posts: 2389
Joined: Fri Dec 20, 2013 7:07 pm
Pronouns: he/him

Re: Need help with lua? - LunaLua General Help

Postby Murphmario » Mon Apr 23, 2018 8:29 am

Hoeloe wrote:
Murphmario wrote:Could I have some code that disables the trails for the Boo Snake? It's for a graphic(s) that I'm working on, and I'm not very good at LunaLua.

And yes, I tried to replace the Podoboo. It doesn't work.
You could always just replace the trail graphic with a blank image.

This'll be even easier to do in Beta 4, when the trail isn't in its own file.
I mean to disable the hitboxes of the trail. They're still there even if the image is invisible.

Emral
Cute Yoshi Egg
Cute Yoshi Egg
Posts: 9887
Joined: Mon Jan 20, 2014 12:58 pm
Flair: Phoenix

Re: Need help with lua? - LunaLua General Help

Postby Emral » Mon Apr 23, 2018 8:46 am

Murphmario wrote:
Hoeloe wrote:
Murphmario wrote:Could I have some code that disables the trails for the Boo Snake? It's for a graphic(s) that I'm working on, and I'm not very good at LunaLua.

And yes, I tried to replace the Podoboo. It doesn't work.
You could always just replace the trail graphic with a blank image.

This'll be even easier to do in Beta 4, when the trail isn't in its own file.
I mean to disable the hitboxes of the trail. They're still there even if the image is invisible.
What's the problem with replacing the podoboo's sprite? IIRC you have to replace some file in a copy of the new_npcs folder, but then it should work?

Murphmario
2025 Egg Hunter
2025 Egg Hunter
Posts: 2389
Joined: Fri Dec 20, 2013 7:07 pm
Pronouns: he/him

Re: Need help with lua? - LunaLua General Help

Postby Murphmario » Mon Apr 23, 2018 11:11 am

Enjl wrote:
Murphmario wrote:
Hoeloe wrote:
You could always just replace the trail graphic with a blank image.

This'll be even easier to do in Beta 4, when the trail isn't in its own file.
I mean to disable the hitboxes of the trail. They're still there even if the image is invisible.
What's the problem with replacing the podoboo's sprite? IIRC you have to replace some file in a copy of the new_npcs folder, but then it should work?
Try using NPC codes with it.

Also it's too slow and I don't want it's sprite potentially flipping upside-down.

GforGoomba
Rocky Wrench
Rocky Wrench
Posts: 628
Joined: Sat May 05, 2018 11:08 am
Flair: It... it worked...

Re: Need help with lua? - LunaLua General Help

Postby GforGoomba » Wed May 23, 2018 5:30 pm

I want to make the money vault pool from DuckTales. It will be a pile of coins and the texture and water level changes depending on how many coins a player has.

PixelPest
Link
Link
Posts: 7111
Joined: Sun Jul 12, 2015 5:38 pm
Flair: Tamer of Boom Booms
Contact:

Re: Need help with lua? - LunaLua General Help

Postby PixelPest » Wed May 23, 2018 10:30 pm

GforGoomba wrote:
Wed May 23, 2018 5:30 pm
I want to make the money vault pool from DuckTales. It will be a pile of coins and the texture and water level changes depending on how many coins a player has.
Can the player interact with the pool? Like is it a liquid or is it a solid the cab stand on top of or is it just a decoration?

GforGoomba
Rocky Wrench
Rocky Wrench
Posts: 628
Joined: Sat May 05, 2018 11:08 am
Flair: It... it worked...

Re: Need help with lua? - LunaLua General Help

Postby GforGoomba » Thu May 24, 2018 5:58 am

PixelPest wrote:
Wed May 23, 2018 10:30 pm
GforGoomba wrote:
Wed May 23, 2018 5:30 pm
I want to make the money vault pool from DuckTales. It will be a pile of coins and the texture and water level changes depending on how many coins a player has.
Can the player interact with the pool? Like is it a liquid or is it a solid the cab stand on top of or is it just a decoration?
It is a liquid.


Return to “LunaLua”

Who is online

Users browsing this forum: No registered users and 1 guest

SMWCentralTalkhausMario Fan Games GalaxyKafukaMarioWikiSMBXEquipoEstelari