Need help with lua? - LunaLua General Help

This is the place for discussion and support for LunaLua and related modifications and libraries.
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?
User avatar
Daring Tombstone
Rex
Rex
Posts: 95
Joined: Mon Aug 28, 2017 10:57 pm
Flair: Sad I didn't fight Jirachi
Current Project: Something Maybe
Chat Username: Chaperone

Re: Need help with lua? - LunaLua General Help

Postby Daring Tombstone » Fri Jan 25, 2019 5:45 pm

The marginx and marginy was my problem. It is caused by misinformation and is actually supposed to be xMargin and yMargin. The words no longer bleed into the borders now. I will be wary when using textblox. Are the crashes just random or are they consistent?
Accurate representation of me after seeing the new SMBX version right after posting my new episode.
Image
Check out my completed episode
Spoiler: show
Image

User avatar
Hoeloe
Grinder
Grinder
Posts: 1026
Joined: Sat Oct 03, 2015 6:18 pm
Flair: The Codehaus Girl
Current Project: A2XT Episode 2

Re: Need help with lua? - LunaLua General Help

Postby Hoeloe » Fri Jan 25, 2019 7:03 pm

They're fairly consistent, but it's hard to know what will cause them.

User avatar
FireyPaperMario
Luigi
Luigi
Posts: 4985
Joined: Sat Sep 27, 2014 1:39 pm
Flair: 90's kid born in 1993 ^_^
Current Project: As of now: SEGA Mega Drive/Genesis GFXs in SMBX
Chat Username: Shin FireyPaperMario
Contact:

Re: Need help with lua? - LunaLua General Help

Postby FireyPaperMario » Sun Feb 03, 2019 7:49 am

I got a question about this Lunalua idea:

Is it even possible for the Hadouken* to be a Lunalua script for the player to use if the playable is in a certain form? Because I had this idea for a while, and I'd like to heard opinions. ^_^"
*Not just the Hadouken, but also the Shoryuken, and other special attacks from various fighting games. And the commands for these should be the same as their original commands in fighting games. :geek:

User avatar
PixelPest
Link
Link
Posts: 7118
Joined: Sun Jul 12, 2015 5:38 pm
Flair: Tamer of Boom Booms
Current Project: Boom Boom Evolution
Chat Username: PixelPest
Contact:

Re: Need help with lua? - LunaLua General Help

Postby PixelPest » Sun Feb 03, 2019 11:52 am

FireyPaperMario wrote:
Sun Feb 03, 2019 7:49 am
I got a question about this Lunalua idea:

Is it even possible for the Hadouken* to be a Lunalua script for the player to use if the playable is in a certain form? Because I had this idea for a while, and I'd like to heard opinions. ^_^"
*Not just the Hadouken, but also the Shoryuken, and other special attacks from various fighting games. And the commands for these should be the same as their original commands in fighting games. :geek:
I'm sure it's possible it would just be the logistics that would be tough to work out

User avatar
Daring Tombstone
Rex
Rex
Posts: 95
Joined: Mon Aug 28, 2017 10:57 pm
Flair: Sad I didn't fight Jirachi
Current Project: Something Maybe
Chat Username: Chaperone

Re: Need help with lua? - LunaLua General Help

Postby Daring Tombstone » Mon Feb 04, 2019 6:52 pm

Very trivial question. Maybe I'm just being dumb today but can't figure out how to activate smoke using the Layer class. Wiki has it like this Layer:show(boolean noSmoke). So layer:show(true) but where to set noSmoke to false?
Accurate representation of me after seeing the new SMBX version right after posting my new episode.
Image
Check out my completed episode
Spoiler: show
Image

User avatar
Hoeloe
Grinder
Grinder
Posts: 1026
Joined: Sat Oct 03, 2015 6:18 pm
Flair: The Codehaus Girl
Current Project: A2XT Episode 2

Re: Need help with lua? - LunaLua General Help

Postby Hoeloe » Mon Feb 04, 2019 7:21 pm

Boolean values can be either true or false. When calling a function, you can pass in arguments. By writing, as you have there, myLayer:show(true), you are assigning "true" to the argument called "noSmoke". You can happily substitute that "true" for a "false" to assign "false" to the argument called "noSmoke".

User avatar
Daring Tombstone
Rex
Rex
Posts: 95
Joined: Mon Aug 28, 2017 10:57 pm
Flair: Sad I didn't fight Jirachi
Current Project: Something Maybe
Chat Username: Chaperone

Re: Need help with lua? - LunaLua General Help

Postby Daring Tombstone » Mon Feb 04, 2019 7:55 pm

Oh jeez yeah I should have figured. The whole time I've been using layers I've been thinking the boolean value as true was just saying *yes show the layer* as opposed to *yes don't show smoke*. Been using layers wrong this whole time. So dumb of me. Appreciate the help.

Actual question this time. With colliders can I make an npc die if it touches a certain background? More specifically, can I make a rinka die if it touches the smw background bubble? I tried this but I'm unfamiliar with colliders.

Code: Select all

function onTick()
	local bubble = BGO.get(173)
	local rinka = NPC.get(146)
	for k,v in pairs(rinka) do
        if (colliders.collide(bubble, rinka)) then
            rinka:kill()
        end
    end
end
Accurate representation of me after seeing the new SMBX version right after posting my new episode.
Image
Check out my completed episode
Spoiler: show
Image

User avatar
Enjl
Cute Yoshi Egg
Cute Yoshi Egg
Posts: 7490
Joined: Mon Jan 20, 2014 12:58 pm
Flair: Orphion Egamalenitar Osmos IV, Esq.

Re: Need help with lua? - LunaLua General Help

Postby Enjl » Tue Feb 05, 2019 1:10 am

Daring Tombstone wrote:
Mon Feb 04, 2019 7:55 pm
Oh jeez yeah I should have figured. The whole time I've been using layers I've been thinking the boolean value as true was just saying *yes show the layer* as opposed to *yes don't show smoke*. Been using layers wrong this whole time. So dumb of me. Appreciate the help.

Actual question this time. With colliders can I make an npc die if it touches a certain background? More specifically, can I make a rinka die if it touches the smw background bubble? I tried this but I'm unfamiliar with colliders.

Code: Select all

function onTick()
	local bubble = BGO.get(173)
	local rinka = NPC.get(146)
	for k,v in pairs(rinka) do
        if (colliders.collide(bubble, rinka)) then
            rinka:kill()
        end
    end
end
Colliders doesn't cover BGOs. You can use a BGO.getIntersecting loop and then filter for ID and layer visibility afterwards. You need to do this in a for loop over your active Rinkas, and check for getIntersecting relative to each one's hitbox.

colliders.collide in general doesn't accept lists but only single collider objects. This includes blocks, npcs and standalone colliders.
ImageImageImageImage
ImageImageImageImageImageImage

User avatar
Daring Tombstone
Rex
Rex
Posts: 95
Joined: Mon Aug 28, 2017 10:57 pm
Flair: Sad I didn't fight Jirachi
Current Project: Something Maybe
Chat Username: Chaperone

Re: Need help with lua? - LunaLua General Help

Postby Daring Tombstone » Tue Feb 05, 2019 1:52 pm

Ah okay thanks. After looking through the colliders API after posting I figured it didn't cover BGO's. I could use colliders to destroy an NPC if it touches another NPC though right?
Accurate representation of me after seeing the new SMBX version right after posting my new episode.
Image
Check out my completed episode
Spoiler: show
Image

a23_2kud12
Goomba
Goomba
Posts: 1
Joined: Wed Feb 06, 2019 9:44 am

Re: Need help with lua? - LunaLua General Help

Postby a23_2kud12 » Wed Feb 06, 2019 10:41 am

When i try to play any level which uses Parralax Scrolling, like the paralx.lua level by rockythechao:
Image
The backgrounds layers are high up.

User avatar
Daring Tombstone
Rex
Rex
Posts: 95
Joined: Mon Aug 28, 2017 10:57 pm
Flair: Sad I didn't fight Jirachi
Current Project: Something Maybe
Chat Username: Chaperone

Re: Need help with lua? - LunaLua General Help

Postby Daring Tombstone » Fri Feb 08, 2019 8:47 pm

I've used parallax in a few of my levels and they've turned out fine. I do believe that particular level though it does the same as the screenshot. Perhaps the level was made in an older version on smbx 2.0. I remember it working properly on an earlier version.
Accurate representation of me after seeing the new SMBX version right after posting my new episode.
Image
Check out my completed episode
Spoiler: show
Image

MidiGuyDP
Bit
Bit
Posts: 147
Joined: Fri Jan 17, 2014 2:28 am

Re: Need help with lua? - LunaLua General Help

Postby MidiGuyDP » Sat Feb 23, 2019 11:38 am

Hiya there. I have a need for some assistance, if anyone can help.

I'm currently trying to make an alternate look to the overworld using stuff like Graphics.DrawImageWP and Text.PrintWP

Here's an image of how I'm trying to use it to change things (Without spoiling too much):
Image

However, when I press the menu button, all my new stuff that I put in disappears, like so:
Image

Is there a way to prevent this from happening? I believe Enigmatic Mario has a custom overworld hub... however I cannot check that to find out how it was done

User avatar
Hoeloe
Grinder
Grinder
Posts: 1026
Joined: Sat Oct 03, 2015 6:18 pm
Flair: The Codehaus Girl
Current Project: A2XT Episode 2

Re: Need help with lua? - LunaLua General Help

Postby Hoeloe » Sat Feb 23, 2019 7:02 pm

This suggests you're using onTick to draw things. You should always use onDraw, since onTick will not run when the game is paused (thus anything you draw in onTick will not be drawn when the game is paused).

MidiGuyDP
Bit
Bit
Posts: 147
Joined: Fri Jan 17, 2014 2:28 am

Re: Need help with lua? - LunaLua General Help

Postby MidiGuyDP » Sat Feb 23, 2019 11:37 pm

Many thanks for the help, crazy thing is, I actually tried that for fun a little while back before checking for replies here, and too my surprise it did the trick, though it's even more reassuring to see someone confirm that that's the way to go, so many thanks there. (That's also probably gonna help me with another small issue I have ^^)

EDIT: Hmmm... I seem to be having another issue now, if I load the worldmap from the smbx menu while function onDraw is set, it works, however whenever I use the SMBX Launcher to load the episode directly, SMBX crashes... though when it's set to onTick it doesn't do that... wonder what I can do here..

EDIT2: I think I got something going for it now, thought I'm not sure if it's the best way, but it works, basically did something like this:

Code: Select all

	function onTick()
		count = count + 1
end
	function onDraw()
			if count > 0 then
		"Draw Hud Images etc.
So it seems that as long as the hud doesn't "onDraw" on the very first frame when I use the SMBX launcher, it doesn't crash, so I make it draw on the 2nd frame instead using a counter. Not perfect but it seems to work... though if anyone has another suggestion, let me know ^^

User avatar
Daring Tombstone
Rex
Rex
Posts: 95
Joined: Mon Aug 28, 2017 10:57 pm
Flair: Sad I didn't fight Jirachi
Current Project: Something Maybe
Chat Username: Chaperone

Re: Need help with lua? - LunaLua General Help

Postby Daring Tombstone » Sun Feb 24, 2019 3:40 am

I'm attempting to onDraw an image on screen but needs to be drawn when you talk to an npc. I have it set to look a little something like this.

Code: Select all

function onEvent(bub)
	if bub == "pic" then
		picture = true
		eventu.run(Talk)
	end
end

function Talk()
	Text.showMessageBox("Hello let's see if that picture is working properly!")
	Text.showMessageBox("Nope you're still an idiot!")
	picture = false
end


local backdrop = Graphics.loadImage("backdrop.png")
local pic = Graphics.loadImage("pic.png")
picture = false


function onDraw()
	if picture == true then
		Graphics.drawImage(backdrop, 70 - 0.5*backdrop.width, 530 - 0.5*backdrop.height, 6)
		Graphics.drawImage(pic, 70 - 0.5*pic.width, 530 - 0.5*pic.height, 5)
	end
end
What I want to happen works but not on the first messagebox when you initially talk to the npc.

First Message Box
Spoiler: show
Image
Second Message Box
Spoiler: show
Image
What I'm asking is if there is a way to have the icon picture drawn on the first message box. (yes I know the outline box on the picture is awful it's a placeholder)

Edit: Nevermind I seem to have found a solution using onMessageBox()
Accurate representation of me after seeing the new SMBX version right after posting my new episode.
Image
Check out my completed episode
Spoiler: show
Image

MidiGuyDP
Bit
Bit
Posts: 147
Joined: Fri Jan 17, 2014 2:28 am

Re: Need help with lua? - LunaLua General Help

Postby MidiGuyDP » Mon Feb 25, 2019 1:36 am

Had a question

Is there any way to call a function by "Selecting a level in the overworld"? (Example, adding a fade out)

Though I wonder if it would do anything anyway since the game itself seems to freeze animations when loading the level, but eh, I still wonder despite that

User avatar
IttaBaby
Koopa Troopa
Koopa Troopa
Posts: 25
Joined: Sat Apr 08, 2017 8:19 pm
Chat Username: IttaBaby

Re: Need help with lua? - LunaLua General Help

Postby IttaBaby » Fri Mar 01, 2019 11:48 pm

I'm trying to make Bowser dash forwards when he punches.
Here's what I got so far:

Code: Select all

function onKeyDown(keycode)
    if keycode == KEY_X then
	
		player:mem(0xC0, FIELD_DFLOAT, (Movit + 1))
        
    end
end
Problem is that merely blinks me forward in a single frame, and only AFTER the punch is complete.
Not to mention I've tried to make it go left and right with a conditional branch, but everything I try crashes the game :V

User avatar
Daring Tombstone
Rex
Rex
Posts: 95
Joined: Mon Aug 28, 2017 10:57 pm
Flair: Sad I didn't fight Jirachi
Current Project: Something Maybe
Chat Username: Chaperone

Re: Need help with lua? - LunaLua General Help

Postby Daring Tombstone » Sun Mar 03, 2019 10:04 pm

I've been making a level that revolves around a timer where time is stopped and time is moving (time affects npc's and platforms not the player) and I've ran into a snag after finishing 2/3's of this level. When the player collects a power-up or gets hurt, it de-rails some platforms that's synced up with time. For instance, a platform falls but time freezes it in the air. But if the player happens to get hurt or collect an item box power-up during these moments the whole thing desyncs. I didn't realize this would happen. My question is if there is a way to disable the game pausing when a powerup is collected and the player is hurt.I've tried doing this
ImageImage

But it doesn't pause this eventu function at all. noPause isn't related to the problem but just to prevent the player from pausing the game in this particular area (because it breaks stuff).
By the way I had a problem using the [code] button so had to upload screenshots instead. Don't know why it kept saying page not found when I tried to post this with it.
Edit: Again I've found a solution to my own problem. Sorry for wasting time posting this stuff. Solved it by using colliders instead of having it on a timer.
Accurate representation of me after seeing the new SMBX version right after posting my new episode.
Image
Check out my completed episode
Spoiler: show
Image

User avatar
Lithobraker
Goomba
Goomba
Posts: 3
Joined: Sat Mar 09, 2019 1:41 am
Current Project: My first SMBX Episode

Re: Need help with lua? - LunaLua General Help

Postby Lithobraker » Sat Mar 09, 2019 1:51 am

Made an account just to post this- I'm trying to use lineguide.lua, and I've gotten the NPC I want added to the list, but I can't seem to figure out how to change its lineSpeed property.
I have little experience with lua at the moment, so this problem is probably obvious, but googling it didn't give me anything that seemed immediately relevant.
Image

The relevant code (lunadll.lua)

Code: Select all

-- apis --
local easyLuna = API.load("easyLuna")
local chucks = API.load("chucks")
local rng = API.load("rng")
local vectr = API.load ("vectr");
local colliders = API.load("colliders");
local pnpc = API.load("pnpc")
local bgofix = API.load("bgofix")
local lineguide = API.load("lineguide")
local walljumps = API.load("walljumps")

-- functions --
lineguide.lineNpcs = {164}
lineguide.properties[164].lineSpeed = {1}
Below this, lineguide is not used again. I've tried several different formats for changing lineSpeed, including:
lineguide.properties[164].lineSpeed = 1
lineguide.properties[164].lineSpeed = 1;
lineguide.properties[164].lineSpeed=1
lineguide.properties[164].lineSpeed(1)
lineguide.properties[164].lineSpeed{1}
And probably some other variations I don't remember. If anyone could help me with this, I'd appreciate it a lot!

User avatar
IttaBaby
Koopa Troopa
Koopa Troopa
Posts: 25
Joined: Sat Apr 08, 2017 8:19 pm
Chat Username: IttaBaby

Re: Need help with lua? - LunaLua General Help

Postby IttaBaby » Sat Mar 09, 2019 9:35 pm

This is in regards to SMBX2's Diagonal Podoboo. How can I increase it's speed. Should I manually load the api to the level just so I can set it's speed?


Return to “LunaLua”

Who is online

Users browsing this forum: No registered users and 1 guest