Page 21 of 76

Re: Need help with lua? - LunaLua General Help

Posted: Sat May 07, 2016 6:43 pm
by PixelPest
Enjl wrote:does "hint-coin-counter.png" exist?
Yes. It's in the same folder as the lunaworld.lua

Re: Need help with lua? - LunaLua General Help

Posted: Sat May 07, 2016 6:47 pm
by Emral
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.

Re: Need help with lua? - LunaLua General Help

Posted: Mon May 09, 2016 1:20 am
by MECHDRAGON777
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...

Re: Need help with lua? - LunaLua General Help

Posted: Mon May 09, 2016 8:21 am
by PixelPest
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()

Re: Need help with lua? - LunaLua General Help

Posted: Mon May 09, 2016 9:40 am
by Kevsoft
PixelPest wrote: Try onKeyBoardPress()

Code: Select all

onKeyboardPress(vk)
case sensitive matters

Re: Need help with lua? - LunaLua General Help

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

Re: Need help with lua? - LunaLua General Help

Posted: Mon May 09, 2016 11:07 am
by S1eth
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"

Re: Need help with lua? - LunaLua General Help

Posted: Mon May 09, 2016 11:11 am
by Nerx
Can I include APIs in an episode folder so I can distribute and episode/level without having a seperate download for APIs?

Re: Need help with lua? - LunaLua General Help

Posted: Mon May 09, 2016 11:12 am
by Emral
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.

Re: Need help with lua? - LunaLua General Help

Posted: Mon May 09, 2016 11:17 am
by mariogeek2
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?

Re: Need help with lua? - LunaLua General Help

Posted: Mon May 09, 2016 11:19 am
by S1eth
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.

Re: Need help with lua? - LunaLua General Help

Posted: Mon May 09, 2016 11:25 am
by mariogeek2
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.

Re: Need help with lua? - LunaLua General Help

Posted: Mon May 09, 2016 11:39 am
by Nerx
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!

Re: Need help with lua? - LunaLua General Help

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

Re: Need help with lua? - LunaLua General Help

Posted: Mon May 09, 2016 12:28 pm
by S1eth
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.

Re: Need help with lua? - LunaLua General Help

Posted: Wed May 11, 2016 11:47 am
by Reign
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

Re: Need help with lua? - LunaLua General Help

Posted: Wed May 11, 2016 11:51 am
by Emral
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

Re: Need help with lua? - LunaLua General Help

Posted: Wed May 11, 2016 12:15 pm
by PixelPest
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

Re: Need help with lua? - LunaLua General Help

Posted: Wed May 11, 2016 12:57 pm
by Reign
Thanks, guys. :)
Spoiler: show
function onInputUpdate()
if(player.altJumpKeyPressing) then
player.altJumpKeyPressing = false;
end
end
This one works.

Re: Need help with lua? - LunaLua General Help

Posted: Wed May 11, 2016 4:51 pm
by PixelPest
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.