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?
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 » Sat May 07, 2016 6:43 pm

Enjl wrote:does "hint-coin-counter.png" exist?
Yes. It's in the same folder as the lunaworld.lua

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

Re: Need help with lua? - LunaLua General Help

Postby Emral » Sat May 07, 2016 6:47 pm

do a Misc.resolveFile("hint-coin-counter.png") search then. Of course it doesn't find it because it's only looking in the level custom graphics folder.

MECHDRAGON777
Pink Yoshi Egg
Pink Yoshi Egg
Posts: 6422
Joined: Fri Dec 20, 2013 6:40 pm
Flair: Nuclear Queen of Reversion.
Contact:

Re: Need help with lua? - LunaLua General Help

Postby MECHDRAGON777 » Mon May 09, 2016 1:20 am

How would you lock the player's controls on the world map? I am asking since

Code: Select all

function onKeyDown(keycode)
and

Code: Select all

function onInputUpdate()
do not work in lunaoverworld.lua files...

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 » Mon May 09, 2016 8:21 am

MECHDRAGON777 wrote:How would you lock the player's controls on the world map? I am asking since

Code: Select all

function onKeyDown(keycode)
and

Code: Select all

function onInputUpdate()
do not work in lunaoverworld.lua files...
Try onKeyBoardPress()

Kevsoft
Ripper II
Ripper II
Posts: 375
Joined: Sun Jul 27, 2014 8:03 am

Re: Need help with lua? - LunaLua General Help

Postby Kevsoft » Mon May 09, 2016 9:40 am

PixelPest wrote: Try onKeyBoardPress()

Code: Select all

onKeyboardPress(vk)
case sensitive matters

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 » Mon May 09, 2016 10:07 am

I'm working on a script for a HUD, however I've encountered an issue. Here's the script: https://hastebin.com/wokusecepo.lua

What I'm trying to do is make the HUD be shown for three seconds and then the main panel at the top moves up at a speed of two pixels per tick until it is off of the screen, while the bottom part moves down two pixels per tick until it is off of the screen. The HUD can be revealed by pressing the shift button and is automatically revealed when an achievement is presented to the player. My issue is that after three seconds of the HUD being shown, before it moves up it shakes up and down for about a second (looks like it's vibrating) before it moves off of the screen. I want to get rid of the shaking (I can't figure out what's causing it) and have the HUD move smoothly immediately after three seconds have passed. (It does move smoothly after it's done doing its strange shaking thing, but I want to get rid of the vibrating look.) Sorry, but I can't upload a video nor an animated gif because my school's wi-fi network blocks Imgur, YouTube, and uploading pictures (or downloading them) online

S1eth
Bot
Bot
Posts: 54
Joined: Sat Apr 23, 2016 10:44 am

Re: Need help with lua? - LunaLua General Help

Postby S1eth » Mon May 09, 2016 11:07 am

PixelPest wrote:I'm working on a script for a HUD, however I've encountered an issue. Here's the script: https://hastebin.com/wokusecepo.lua

What I'm trying to do is make the HUD be shown for three seconds and then the main panel at the top moves up at a speed of two pixels per tick until it is off of the screen, while the bottom part moves down two pixels per tick until it is off of the screen. The HUD can be revealed by pressing the shift button and is automatically revealed when an achievement is presented to the player. My issue is that after three seconds of the HUD being shown, before it moves up it shakes up and down for about a second (looks like it's vibrating) before it moves off of the screen. I want to get rid of the shaking (I can't figure out what's causing it) and have the HUD move smoothly immediately after three seconds have passed. (It does move smoothly after it's done doing its strange shaking thing, but I want to get rid of the vibrating look.) Sorry, but I can't upload a video nor an animated gif because my school's wi-fi network blocks Imgur, YouTube, and uploading pictures (or downloading them) online
You put all that code into onTick().
Every single frame in which drawHUD == true, you are calling eventu.setTimer(3, endHUDDraw, false);
Then, after 3 seconds, endHUDDraw is called 65*3 times in a row.

Also, you are calling endHUDDraw twice in a single tick. Once in "if player.dropItemKeyPressing then" and then another time in "if drawHUD then"

Nerx
Swooper
Swooper
Posts: 75
Joined: Thu Apr 14, 2016 12:57 pm

Re: Need help with lua? - LunaLua General Help

Postby Nerx » Mon May 09, 2016 11:11 am

Can I include APIs in an episode folder so I can distribute and episode/level without having a seperate download for APIs?

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

Re: Need help with lua? - LunaLua General Help

Postby Emral » Mon May 09, 2016 11:12 am

Nerx wrote:Can I include APIs in an episode folder so I can distribute and episode/level without having a seperate download for APIs?
Yes. Though I recommend renaming them to "local_*apiname*.lua", to have a better distinction.

mariogeek2
Rocky Wrench
Rocky Wrench
Posts: 697
Joined: Tue Jan 28, 2014 5:46 pm

Re: Need help with lua? - LunaLua General Help

Postby mariogeek2 » Mon May 09, 2016 11:17 am

Hey, guys, I'm having trouble getting LunaLua to work. I downloaded LunaLua by itself (hexed and vanilla + launcher), and that didn't work. So I downloaded LunaLua Vanilla + Launcher + Complete Standalone Base Game, and I got error code "unable to find msvcp140.dll", which I found on the internet, downloaded, and put in the LunaLua + SMBX folder. It then said, "unable to find vcruntime140.dll", which I also found on the internet, downloaded, and put in the LunaLua + SMBX folder. I then got error message "The application was unable to start correctly (0xc000007b). Click OK to close the application." I then downloaded the LunaLua Hexed version + stand alone base game, and put it in the LunaLua + SMBX folder, and overwrited all files with the same name. Still got the same (0xc00007b) error message. Do you guys have any advice?

S1eth
Bot
Bot
Posts: 54
Joined: Sat Apr 23, 2016 10:44 am

Re: Need help with lua? - LunaLua General Help

Postby S1eth » Mon May 09, 2016 11:19 am

mariogeek2 wrote:Hey, guys, I'm having trouble getting LunaLua to work. I downloaded LunaLua by itself (hexed and vanilla + launcher), and that didn't work. So I downloaded LunaLua Vanilla + Launcher + Complete Standalone Base Game, and I got error code "unable to find msvcp140.dll", which I found on the internet, downloaded, and put in the LunaLua + SMBX folder. It then said, "unable to find vcruntime140.dll", which I also found on the internet, downloaded, and put in the LunaLua + SMBX folder. I then got error message "The application was unable to start correctly (0xc000007b). Click OK to close the application." I then downloaded the LunaLua Hexed version + stand alone base game, and put it in the LunaLua + SMBX folder, and overwrited all files with the same name. Still got the same (0xc00007b) error message. Do you guys have any advice?
There is a file called vc_redist.x86.exe in your SMBX folder. Run that and it will install the required DLLs to your PC.

mariogeek2
Rocky Wrench
Rocky Wrench
Posts: 697
Joined: Tue Jan 28, 2014 5:46 pm

Re: Need help with lua? - LunaLua General Help

Postby mariogeek2 » Mon May 09, 2016 11:25 am

S1eth wrote:
mariogeek2 wrote:Hey, guys, I'm having trouble getting LunaLua to work. I downloaded LunaLua by itself (hexed and vanilla + launcher), and that didn't work. So I downloaded LunaLua Vanilla + Launcher + Complete Standalone Base Game, and I got error code "unable to find msvcp140.dll", which I found on the internet, downloaded, and put in the LunaLua + SMBX folder. It then said, "unable to find vcruntime140.dll", which I also found on the internet, downloaded, and put in the LunaLua + SMBX folder. I then got error message "The application was unable to start correctly (0xc000007b). Click OK to close the application." I then downloaded the LunaLua Hexed version + stand alone base game, and put it in the LunaLua + SMBX folder, and overwrited all files with the same name. Still got the same (0xc00007b) error message. Do you guys have any advice?
There is a file called vc_redist.x86.exe in your SMBX folder. Run that and it will install the required DLLs to your PC.
Ok, thanks. I'll try it and see if it works.

Edit: It did. Thanks. I never would've thought of doing that.
Last edited by mariogeek2 on Mon May 09, 2016 11:53 am, edited 1 time in total.

Nerx
Swooper
Swooper
Posts: 75
Joined: Thu Apr 14, 2016 12:57 pm

Re: Need help with lua? - LunaLua General Help

Postby Nerx » Mon May 09, 2016 11:39 am

Enjl wrote:
Nerx wrote:Can I include APIs in an episode folder so I can distribute and episode/level without having a seperate download for APIs?
Yes. Though I recommend renaming them to "local_*apiname*.lua", to have a better distinction.
Okay, thanks a ton!

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 » Mon May 09, 2016 12:02 pm

S1eth wrote:
PixelPest wrote:I'm working on a script for a HUD, however I've encountered an issue. Here's the script: https://hastebin.com/wokusecepo.lua

What I'm trying to do is make the HUD be shown for three seconds and then the main panel at the top moves up at a speed of two pixels per tick until it is off of the screen, while the bottom part moves down two pixels per tick until it is off of the screen. The HUD can be revealed by pressing the shift button and is automatically revealed when an achievement is presented to the player. My issue is that after three seconds of the HUD being shown, before it moves up it shakes up and down for about a second (looks like it's vibrating) before it moves off of the screen. I want to get rid of the shaking (I can't figure out what's causing it) and have the HUD move smoothly immediately after three seconds have passed. (It does move smoothly after it's done doing its strange shaking thing, but I want to get rid of the vibrating look.) Sorry, but I can't upload a video nor an animated gif because my school's wi-fi network blocks Imgur, YouTube, and uploading pictures (or downloading them) online
You put all that code into onTick().
Every single frame in which drawHUD == true, you are calling eventu.setTimer(3, endHUDDraw, false);
Then, after 3 seconds, endHUDDraw is called 65*3 times in a row.

Also, you are calling endHUDDraw twice in a single tick. Once in "if player.dropItemKeyPressing then" and then another time in "if drawHUD then"
Do you think this will resolve the issue then?: https://hastebin.com/oqecaxejad.lua
I added the variable "endHUDDrawTimer" to regulate the amount of times endHUDDraw is called

S1eth
Bot
Bot
Posts: 54
Joined: Sat Apr 23, 2016 10:44 am

Re: Need help with lua? - LunaLua General Help

Postby S1eth » Mon May 09, 2016 12:28 pm

PixelPest wrote:
S1eth wrote:
PixelPest wrote:I'm working on a script for a HUD, however I've encountered an issue. Here's the script: https://hastebin.com/wokusecepo.lua

What I'm trying to do is make the HUD be shown for three seconds and then the main panel at the top moves up at a speed of two pixels per tick until it is off of the screen, while the bottom part moves down two pixels per tick until it is off of the screen. The HUD can be revealed by pressing the shift button and is automatically revealed when an achievement is presented to the player. My issue is that after three seconds of the HUD being shown, before it moves up it shakes up and down for about a second (looks like it's vibrating) before it moves off of the screen. I want to get rid of the shaking (I can't figure out what's causing it) and have the HUD move smoothly immediately after three seconds have passed. (It does move smoothly after it's done doing its strange shaking thing, but I want to get rid of the vibrating look.) Sorry, but I can't upload a video nor an animated gif because my school's wi-fi network blocks Imgur, YouTube, and uploading pictures (or downloading them) online
You put all that code into onTick().
Every single frame in which drawHUD == true, you are calling eventu.setTimer(3, endHUDDraw, false);
Then, after 3 seconds, endHUDDraw is called 65*3 times in a row.

Also, you are calling endHUDDraw twice in a single tick. Once in "if player.dropItemKeyPressing then" and then another time in "if drawHUD then"
Do you think this will resolve the issue then?: https://hastebin.com/oqecaxejad.lua
I added the variable "endHUDDrawTimer" to regulate the amount of times endHUDDraw is called
Why are you asking me? Why don't you just try it out?

No, it won't work, because you are never setting endHUDDrawTimer to true after calling endHUDDraw().

And you're still calling it twice.
Not to mention, if you press shift again, you want to refresh the duration back to 3, but since you schedule endHUDDraw 3 seconds in advance, you'll start moving it away when you don't want to.
For example, you press SHIFT, and 2 seconds later you press SHIFT again. Then, after another second, the HUD starts moving away, and 2 seconds later, the HUD teleports back and starts moving away again because every time you press shift, you schedule another endHUDDraw().
You cannot predict the future, and don't know if the HUD needs to be drawn for longer than 3 seconds. So you should only call endHUDDraw when the 3 seconds have already passed.

Personally, I suggest you just replace the boolean "drawHUD" with an integer counter. For 65*3 ticks, you just draw the HUD normally, and when it goes to 0 and beyond, you draw the moving HUD.
Pressing shift resets the counter back to (65*3). You could also start at, for example 65*5 (3 seconds for normal HUD, 2 for moving HUD). Or start at 0 and count up? However you like it.

Reign
Chain Chomp
Chain Chomp
Posts: 327
Joined: Tue Jan 21, 2014 4:22 am

Re: Need help with lua? - LunaLua General Help

Postby Reign » Wed May 11, 2016 11:47 am

I'm afraid I'm back already. :mrgreen:

Is there a simple way to disable spin jump so that the button does not do anything (no jump sound, no nothing). Right now I'm just using it as a "suicide button" but I would prefer to just disable the spin jump and move the suicide to some less common key like "Drop item".

function onKeyDown(keycode)
if (keycode == KEY_SPINJUMP) then
player:kill()
end
end

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

Re: Need help with lua? - LunaLua General Help

Postby Emral » Wed May 11, 2016 11:51 am

Read the description for onInputUpdate
http://wohlsoft.ru/pgewiki/LunaLua_events
Check out some of the key press states here
http://wohlsoft.ru/pgewiki/Player_%28class%29

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 11, 2016 12:15 pm

Reign wrote:I'm afraid I'm back already. :mrgreen:

Is there a simple way to disable spin jump so that the button does not do anything (no jump sound, no nothing). Right now I'm just using it as a "suicide button" but I would prefer to just disable the spin jump and move the suicide to some less common key like "Drop item".
function onKeyDown(keycode)
if (keycode == KEY_SPINJUMP) then
player:kill()
end
end
I would recommend making it act like a normal jump key

Reign
Chain Chomp
Chain Chomp
Posts: 327
Joined: Tue Jan 21, 2014 4:22 am

Re: Need help with lua? - LunaLua General Help

Postby Reign » Wed May 11, 2016 12:57 pm

Thanks, guys. :)
Spoiler: show
function onInputUpdate()
if(player.altJumpKeyPressing) then
player.altJumpKeyPressing = false;
end
end
This one works.

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 11, 2016 4:51 pm

Reign wrote:Thanks, guys. :)
Spoiler: show
function onInputUpdate()
if(player.altJumpKeyPressing) then
player.altJumpKeyPressing = false;
end
end
If you want you could also add player.jumpKeyPressing = true; between the third and fourth lines. Then instead of being a dead key, it just makes the player do a normal jump
This one works.


Return to “LunaLua”

Who is online

Users browsing this forum: Ahrefs [Bot] and 1 guest

SMWCentralTalkhausMario Fan Games GalaxyKafukaMarioWikiSMBXEquipoEstelari