Page 65 of 76

Re: Need help with lua? - LunaLua General Help

Posted: Wed Apr 04, 2018 12:52 pm
by WildW
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

Re: Need help with lua? - LunaLua General Help

Posted: Wed Apr 04, 2018 12:57 pm
by The0x539
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()

Re: Need help with lua? - LunaLua General Help

Posted: Wed Apr 04, 2018 1:02 pm
by WildW
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.

Re: Need help with lua? - LunaLua General Help

Posted: Thu Apr 05, 2018 1:18 pm
by Emral
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.

Re: Need help with lua? - LunaLua General Help

Posted: Thu Apr 05, 2018 1:43 pm
by Hoeloe
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.

Re: Need help with lua? - LunaLua General Help

Posted: Thu Apr 05, 2018 1:45 pm
by WildW
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?

Re: Need help with lua? - LunaLua General Help

Posted: Thu Apr 05, 2018 1:51 pm
by Emral
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.

Re: Need help with lua? - LunaLua General Help

Posted: Thu Apr 05, 2018 2:00 pm
by WildW
Sooo... remove the first onLoop and piece of code underneath it?

Re: Need help with lua? - LunaLua General Help

Posted: Tue Apr 10, 2018 11:28 pm
by SoulForTruth41
[deleted post]

Re: Need help with lua? - LunaLua General Help

Posted: Wed Apr 11, 2018 6:36 am
by PixelPest
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

Re: Need help with lua? - LunaLua General Help

Posted: Wed Apr 11, 2018 1:33 pm
by SoulForTruth41
My apologies. I didn't know that LunaLua was something separate from SMBX 38A; I thought they were somehow cohesive. I deleted the post.

Re: Need help with lua? - LunaLua General Help

Posted: Wed Apr 11, 2018 2:08 pm
by Hoeloe
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.

Re: Need help with lua? - LunaLua General Help

Posted: Sun Apr 22, 2018 8:50 pm
by Murphmario
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.

Re: Need help with lua? - LunaLua General Help

Posted: Sun Apr 22, 2018 9:15 pm
by Hoeloe
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.

Re: Need help with lua? - LunaLua General Help

Posted: Mon Apr 23, 2018 8:29 am
by Murphmario
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.

Re: Need help with lua? - LunaLua General Help

Posted: Mon Apr 23, 2018 8:46 am
by Emral
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?

Re: Need help with lua? - LunaLua General Help

Posted: Mon Apr 23, 2018 11:11 am
by Murphmario
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.

Re: Need help with lua? - LunaLua General Help

Posted: Wed May 23, 2018 5:30 pm
by GforGoomba
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.

Re: Need help with lua? - LunaLua General Help

Posted: Wed May 23, 2018 10:30 pm
by PixelPest
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?

Re: Need help with lua? - LunaLua General Help

Posted: Thu May 24, 2018 5:58 am
by GforGoomba
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.