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
DeMuZ
Bob-omb
Bob-omb
Posts: 37
Joined: Thu Aug 18, 2016 2:35 pm

Re: Need help with lua? - LunaLua General Help

Postby DeMuZ » Sat Dec 24, 2016 3:32 pm

Enjl wrote:That won't work. Instead, pick spawn coordinates and after that do a getIntersecting check around that box and spawn the NPC only if the returned list is empty:

local spawnX, spawnY = rng.random(a,b), rng.random(c,d)
local collidingBlocks = Block.getIntersecting(spawnX - 16, spawnY - 16, spawnX + 16, spawnY + 16)
if #collidingBlocks == 0 then
local spawnedNPC = NPC.spawn(id, spawnX, spawnY, section, false, true)
end
Ok, thank you. You saved my time from being wasted! :)

User avatar
darkhog
Rex
Rex
Posts: 87
Joined: Sat Dec 10, 2016 11:17 pm

Re: Need help with lua? - LunaLua General Help

Postby darkhog » Sun Dec 25, 2016 2:01 pm

What about my speed issue?

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

Re: Need help with lua? - LunaLua General Help

Postby Enjl » Sun Dec 25, 2016 3:21 pm

darkhog wrote:What about my speed issue?
Check the posts in the thread more carefully.
Ideas are useless if you can't make them real.
Image

User avatar
darkhog
Rex
Rex
Posts: 87
Joined: Sat Dec 10, 2016 11:17 pm

Re: Need help with lua? - LunaLua General Help

Postby darkhog » Sun Dec 25, 2016 4:47 pm

Kinda hard for 40+ pages long thread, now is It? And smbx and lunalua isn't nearly popular enough for me to be easily able to google the answer, which I usually do for other frameworks/libraries/languages. Also you've completely missed the point. The walking right is already done, but player is walking too fast (at the normal speed, which is fine for gameplay, but not for the "cutscene mode" where it should be about 50% slower). Your code is about locking player movement so it will walk right, not about setting the speeds/restoring it. Re-read my question and the code I've provided.

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

Re: Need help with lua? - LunaLua General Help

Postby PixelPest » Sun Dec 25, 2016 9:30 pm

You really don't need to be so rude to Enjl; he's just trying to help and he doesn't have to, but does anyway. He never said read all of the pages in the thread and he hasn't missed the point, you just haven't explained yourself very well. And he answered your question if you read one of the posts on the last page:
it sets the speed for one frame.
You want to set player.speedX to a certain value onTick(), not onLoad()

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

Re: Need help with lua? - LunaLua General Help

Postby Enjl » Sun Dec 25, 2016 9:45 pm

darkhog wrote:Kinda hard for 40+ pages long thread, now is It? And smbx and lunalua isn't nearly popular enough for me to be easily able to google the answer, which I usually do for other frameworks/libraries/languages. Also you've completely missed the point. The walking right is already done, but player is walking too fast (at the normal speed, which is fine for gameplay, but not for the "cutscene mode" where it should be about 50% slower). Your code is about locking player movement so it will walk right, not about setting the speeds/restoring it. Re-read my question and the code I've provided.
First off, my reply is literally the post below the one where you asked the question.
Secondly, sorry for misreading your post but you could've maybe addressed that directly rather than asking into the open "oh what about my issue".
Thirdly, Defines.player_walkspeed.
http://wohlsoft.ru/pgewiki/SMBX_Fields
Ideas are useless if you can't make them real.
Image

User avatar
darkhog
Rex
Rex
Posts: 87
Joined: Sat Dec 10, 2016 11:17 pm

Re: Need help with lua? - LunaLua General Help

Postby darkhog » Sun Dec 25, 2016 10:45 pm

I see. Though IMO stuff like walkspeed should be inside Player class. Would make more sense than if it is in defines (and you could make it so players 1 and 2 have different speed, e.g. as part of a powerup).

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

Re: Need help with lua? - LunaLua General Help

Postby PixelPest » Sun Dec 25, 2016 10:48 pm

It makes perfect sense where it is; defines objects are set once and act as a setting that lasts until it is modified at a later time or the process is restarted (level, episode, etc.) while the Player class manages things during a single tick during runtime. As I mentioned before though, you can always just modify speedX as player1.speedX and player2.speedX

User avatar
Fuyu
Wart
Wart
Posts: 3059
Joined: Sat Dec 21, 2013 2:40 pm

Re: Need help with lua? - LunaLua General Help

Postby Fuyu » Mon Dec 26, 2016 7:18 pm

Is it possible to use arabsalmon's SMWcamera.lua to resize the screen width and height to that of the original SMW? If not, is there a way to do this?
Image

Enjl
Cute Yoshi Egg
Cute Yoshi Egg
Posts: 8737
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 Dec 27, 2016 9:27 am

Intuition wrote:Is it possible to use arabsalmon's SMWcamera.lua to resize the screen width and height to that of the original SMW? If not, is there a way to do this?
SMWcamera.lua is for the movements of the camera. You CAN draw a black box around the SMW camera's resolution, but the issue with that is NPC spawn range. I don't know if there's a way to modify that yet.
Ideas are useless if you can't make them real.
Image

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

Re: Need help with lua? - LunaLua General Help

Postby PixelPest » Tue Dec 27, 2016 9:33 am

You could try checking if an NPC is fully underneath the black box and if so set its mem value for offscreen to (-1) and also set the player's speedX to 0 if they are touching it

Enjl
Cute Yoshi Egg
Cute Yoshi Egg
Posts: 8737
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 Dec 27, 2016 9:34 am

PixelPest wrote:You could try checking if an NPC is fully underneath the black box and if so set its mem value for offscreen to (-1) and also set the player's speedX to 0 if they are touching it
3 second despawn rule though?
Ideas are useless if you can't make them real.
Image

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

Re: Need help with lua? - LunaLua General Help

Postby PixelPest » Tue Dec 27, 2016 9:36 am

You could use pnpc.lua to set a despawn timer

Enjl
Cute Yoshi Egg
Cute Yoshi Egg
Posts: 8737
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 Dec 27, 2016 9:40 am

PixelPest wrote:You could use pnpc.lua to set a despawn timer
And then you have to account for npcs that enter the old screen but are still despawning on the newer one... should be doable, but it looks like a big pile of spaghetticode in my mind :p
Ideas are useless if you can't make them real.
Image

User avatar
Fuyu
Wart
Wart
Posts: 3059
Joined: Sat Dec 21, 2013 2:40 pm

Re: Need help with lua? - LunaLua General Help

Postby Fuyu » Tue Dec 27, 2016 10:35 am

That seems to be kind of a lame way to execute it, and zoom wouldn't work properly either. I might as well just give up then. :V
Image

User avatar
Fuyu
Wart
Wart
Posts: 3059
Joined: Sat Dec 21, 2013 2:40 pm

Re: Need help with lua? - LunaLua General Help

Postby Fuyu » Fri Dec 30, 2016 4:29 pm

So I have a question, do onTick functions work in the overworld? If so, is it possible to print text in the overworld? Because I'm trying display some simple text in the overworld and I can't.

EDIT: Nevermind, found the stupid problem, me.
Image

User avatar
Angelus
Bit
Bit
Posts: 129
Joined: Tue Jun 21, 2016 9:38 am

Re: Need help with lua? - LunaLua General Help

Postby Angelus » Mon Jan 02, 2017 7:21 pm

Is there any way of disabling the climbing without having to disable the Up key? Or, maybe, to turn a climbable NPC into something that the player can't interact with, while NPCs such as Hoopsters still can? Similar to the SMB2 trees, which a Hoopster can climb but not the player.

PixelPest
Link
Link
Posts: 7116
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 Jan 02, 2017 9:59 pm

http://wohlsoft.ru/pgewiki/SMBX_Player_Offsets

0x40 is climbing state. You should be able to force it to a certain value to prevent the player from ever climbing

User avatar
King of GETs
Spiny
Spiny
Posts: 48
Joined: Sat Jan 16, 2016 8:17 pm

Re: Need help with lua? - LunaLua General Help

Postby King of GETs » Tue Jan 03, 2017 1:50 am

So I was diving into LunaLua, and I got it to work in the editor, but it only works with "Test -> LunaTest -> Run testing" and NOT "Test Level <Alpha>" or "Test a saved file".

Is this normal?

User avatar
Hoeloe
Kamikaze Koopa
Kamikaze Koopa
Posts: 1240
Joined: Sat Oct 03, 2015 6:18 pm
Flair: The Codehaus Girl

Re: Need help with lua? - LunaLua General Help

Postby Hoeloe » Tue Jan 03, 2017 3:04 am

King of GETs wrote:So I was diving into LunaLua, and I got it to work in the editor, but it only works with "Test -> LunaTest -> Run testing" and NOT "Test Level <Alpha>" or "Test a saved file".

Is this normal?
Yes. "Test Level <Alpha>" is the alpha PGE engine, not SMBX.

You can also hit F5 as a shortcut, though, so I suggest trying that.


Return to “LunaLua”

Who is online

Users browsing this forum: No registered users and 2 guests