(shouting)

LunaLua Offical Thread

The second SMBX collab!

Shall I stream some LunaLua live development?

Yes
23
92%
No
2
8%
 
Total votes: 25

User avatar
Kevsoft
LunaLua Master Developer
Posts: 83
Joined: 9 years ago

Re: Presenting: Lunadll for Lua!

Post by Kevsoft »

No, sorry for the misunderstanding. I meant with 'replace' that is should be used in the future.
User avatar
Hoeloe
A2XT person
Posts: 1022
Joined: 12 years ago
Pronouns: she/her
Location: Spaaace

Re: Presenting: Lunadll for Lua!

Post by Hoeloe »

Kevsoft wrote:No, sorry for the misunderstanding. I meant with 'replace' that is should be used in the future.
That's fine, just wanted to clear that up. It's always best to just mark old functions as "deprecated" rather than removing them for this reason, but that seems to be what's been done, which is good.
Image
Image
Image
Image
Image
User avatar
Hoeloe
A2XT person
Posts: 1022
Joined: 12 years ago
Pronouns: she/her
Location: Spaaace

Re: Presenting: Lunadll for Lua!

Post by Hoeloe »

I'm having some problems with pnpc. I've used spawnNPC to create a new NPC, and am storing it by wrapping it up with pnpc:

Code: Select all

local effect = pnpc.wrap(spawnNPC(165, x, y, player.section));
effect:mem(0x46,FIELD_WORD,-1);
effect.speedX = 0;
effect.speedY = 0;
Qs[i] = { e = effect, x = x, y = y };
This seems to work, but I get an "invalid access" error on the next bit (line 84 of pnpc):

Code: Select all

	for _,v in pairs(Qs) do
		v.e.x = v.x;
		v.e.y = v.y;
	end
And if I add a validity check around those, I get "attempt to index field '__ref' (a number value)".
Image
Image
Image
Image
Image
User avatar
Hoeloe
A2XT person
Posts: 1022
Joined: 12 years ago
Pronouns: she/her
Location: Spaaace

Re: Presenting: Lunadll for Lua!

Post by Hoeloe »

Horikawa Otane wrote:Wohl seems to use ticks to determine song stuff. Would it be possible to use the new isplaying stuff to detect when a song ends and switch to a new random one?
Could you not check for whether the current time from Audio.MusicClock() has decreased? That would imply either a song changing or the music looping.
Image
Image
Image
Image
Image
User avatar
Rednaxela
Maker of Shenanigans
Posts: 897
Joined: 10 years ago
Pronouns: they/them
https://rednaxela.talkhaus.com

Re: Presenting: Lunadll for Lua!

Post by Rednaxela »

Horikawa Otane wrote:
Hoeloe wrote:
Horikawa Otane wrote:Wohl seems to use ticks to determine song stuff. Would it be possible to use the new isplaying stuff to detect when a song ends and switch to a new random one?
Could you not check for whether the current time from Audio.MusicClock() has decreased? That would imply either a song changing or the music looping.
I must have missed that! When it becomes zero, the song is over.

It'd be nice if we had something to return the length of the song so we could calculate how long it has until the end (and then do a fade out).
Actually you can't use Audio.MusicClock() to detect when it loops, pretty sure it'll just keep counting up through the loop. I don't *think* the the SDL audio API gives a way to hook when it loops at all. There's Mix_HookMusicFinished but pretty sure that won't get called upon a loop. A better alternative to implementing detection of when it loops, is if the LunaLua Audio API was simply extended to allow you to run a play music call that doesn't automatically loop. If I add that, all you need to do is call the "is music stopped" function each tick and if so start the next track. As far as fading out is concerned, perhaps just edit it into the audio files?

Querying the length of a song is also not something that's particularly easy. The SDL API doesn't give a way to query music length. For some audio formats (i.e. .ogg, .wav, etc) I could implement something that loads the music file as a sound effect temporarily instead and queries it's length that way, but for other audio formats that it supports (i.e. xm, midi, etc) that method would fail. It would be a messy way to do things.

If you hardcode song lengths, I do suggest you still use Audio.MusicClock() do compare against though as that's guaranteed to stay in sync with the audio engine unlike other timekeeping methods.
User avatar
Rednaxela
Maker of Shenanigans
Posts: 897
Joined: 10 years ago
Pronouns: they/them
https://rednaxela.talkhaus.com

Re: Presenting: Lunadll for Lua!

Post by Rednaxela »

Hoeloe wrote:I'm having some problems with pnpc. I've used spawnNPC to create a new NPC, and am storing it by wrapping it up with pnpc:.
I think you're running an out-of-date version of the pnpc library. There was a bug causing the "attempt to index field '__ref' (a number value)" in an older version that I've fixed, and further line 84 has nothing to do with accessing __ref in the current version. The current version is both on the wiki and in the current LunaDLL download.
User avatar
Hoeloe
A2XT person
Posts: 1022
Joined: 12 years ago
Pronouns: she/her
Location: Spaaace

Re: Presenting: Lunadll for Lua!

Post by Hoeloe »

Rednaxela wrote:
Hoeloe wrote:I'm having some problems with pnpc. I've used spawnNPC to create a new NPC, and am storing it by wrapping it up with pnpc:.
I think you're running an out-of-date version of the pnpc library. There was a bug causing the "attempt to index field '__ref' (a number value)" in an older version that I've fixed, and further line 84 has nothing to do with accessing __ref in the current version. The current version is both on the wiki and in the current LunaDLL download.
Certainly possible. I'll give that a try.

On an unrelated note, since the latest update, setting the direction of an NPC doesn't appear to work any more. Both "npc.direction" and using the mem function have no effect.
Last edited by Hoeloe 9 years ago, edited 2 times in total.
Image
Image
Image
Image
Image
User avatar
Rednaxela
Maker of Shenanigans
Posts: 897
Joined: 10 years ago
Pronouns: they/them
https://rednaxela.talkhaus.com

Re: Presenting: Lunadll for Lua!

Post by Rednaxela »

Somewhat surprised you have the old version as there was only a 2-day window of time (March 1st to March 3rd) that was up that the fixed version wasn't. I blame Murphy.
User avatar
Rednaxela
Maker of Shenanigans
Posts: 897
Joined: 10 years ago
Pronouns: they/them
https://rednaxela.talkhaus.com

Re: Presenting: Lunadll for Lua!

Post by Rednaxela »

Hoeloe wrote:On an unrelated note, since the latest update, setting the direction of an NPC doesn't appear to work any more. Both "npc.direction" and using the mem function have no effect.
Doh. I realized what happened. I thought the direction field was accidentally changed at one point recently, and changed it "back" but was mistaken about the way it was originally. I probably did that on too little sleep. Now fixed.
User avatar
Kevsoft
LunaLua Master Developer
Posts: 83
Joined: 9 years ago

Re: Presenting: Lunadll for Lua!

Post by Kevsoft »

Hotfix (0.6.1.1) is out by fixing the direction bug and updating the eventu library.
User avatar
Kevsoft
LunaLua Master Developer
Posts: 83
Joined: 9 years ago

Re: Presenting: Lunadll for Lua!

Post by Kevsoft »

I updated the download link, it should be now easier to access LunaLua.
User avatar
Kevsoft
LunaLua Master Developer
Posts: 83
Joined: 9 years ago

Re: Presenting: Lunadll for Lua!

Post by Kevsoft »

I just added a poll to the main post.
User avatar
Wohlstand
Moondust and TheXTech developer
Posts: 186
Joined: 10 years ago
First name: Vitaly
Pronouns: he/him/his
Location: Moscow, Russia

Re: Presenting: Lunadll for Lua!

Post by Wohlstand »

Hey, I made a small autotool which will fix all non-44100hz musics in all subfolders where you will put them:
https://drive.google.com/open?id=0B3QNP ... authuser=0
I made this file to fix (especially in the previous episodes which made before LunaLUA got usage of SDL)

How to use:
1) unpack archive into "worlds" folder
2) run "MusicFixer.bat" file and wait while all musics will be fixed.
This thing will fix ALL musics in all installed SMBX episodes.
You also can edit "MusicFixer.bat" to define target episode folder which will be fixed.

Good Music Forever! Image
S1eth
Posts: 291
Joined: 9 years ago

Re: Presenting: Lunadll for Lua!

Post by S1eth »

I just updated from 6.0.3 to "Latest"(6.1.1) using the download link from the first post (full installation).

Using eventu.lua now causes the following error. This even happens when the lua file does absolutely nothing but load the API.

==> eventu.lua:79: bad argument #1 to 'pairs' (table expected, got nil)

What happened?
Image
User avatar
Wohlstand
Moondust and TheXTech developer
Posts: 186
Joined: 10 years ago
First name: Vitaly
Pronouns: he/him/his
Location: Moscow, Russia

Re: Presenting: Lunadll for Lua!

Post by Wohlstand »

S1eth wrote:I just updated from 6.0.3 to "Latest"(6.1.1) using the download link from the first post (full installation).

Using eventu.lua now causes the following error. This even happens when the lua file does absolutely nothing but load the API.

==> eventu.lua:79: bad argument #1 to 'pairs' (table expected, got nil)

What happened?
Try to update with this: https://dl.dropboxusercontent.com/u/30847069/eventu.lua
User avatar
Rednaxela
Maker of Shenanigans
Posts: 897
Joined: 10 years ago
Pronouns: they/them
https://rednaxela.talkhaus.com

Re: Presenting: Lunadll for Lua!

Post by Rednaxela »

Anyone notice something different?
Image

(Hint: New feature implemented for the next LunaDLL release)
User avatar
Kevsoft
LunaLua Master Developer
Posts: 83
Joined: 9 years ago

Re: Presenting: Lunadll for Lua!

Post by Kevsoft »

You're just changing the game in every way. That's just amazing.
S1eth
Posts: 291
Joined: 9 years ago

Re: Presenting: Lunadll for Lua!

Post by S1eth »

Wohlstand wrote:
S1eth wrote:I just updated from 6.0.3 to "Latest"(6.1.1) using the download link from the first post (full installation).

Using eventu.lua now causes the following error. This even happens when the lua file does absolutely nothing but load the API.

==> eventu.lua:79: bad argument #1 to 'pairs' (table expected, got nil)

What happened?
Try to update with this: https://dl.dropboxusercontent.com/u/30847069/eventu.lua
This file is identical to the one I am already using.

From what I can tell, since I did not change anything at all, this error should happen to everyone using the 6.1.1 version, not just me.
Can you, or anyone else, reproduce this? Just make a test level with the example code from http://engine.wohlnet.ru/pgewiki/Eventu.lua and run it in the 6.1.1 full installation version from http://engine.wohlnet.ru/LunaLua/
Image
User avatar
Hoeloe
A2XT person
Posts: 1022
Joined: 12 years ago
Pronouns: she/her
Location: Spaaace

Re: Presenting: Lunadll for Lua!

Post by Hoeloe »

S1eth wrote: This file is identical to the one I am already using.
Ah. I think I know what the problem is, and it's my fault. It will probably do this if you trigger an SMBX event and don't have anything in eventu listening for it with waitEvent. I can fix it quite easily, let me just do that.

EDIT: Try redownloading now. The hotfix should be on the same link.
Image
Image
Image
Image
Image
S1eth
Posts: 291
Joined: 9 years ago

Re: Presenting: Lunadll for Lua!

Post by S1eth »

Hoeloe wrote:
S1eth wrote: This file is identical to the one I am already using.
Ah. I think I know what the problem is, and it's my fault. It will probably do this if you trigger an SMBX event and don't have anything in eventu listening for it with waitEvent. I can fix it quite easily, let me just do that.

EDIT: Try redownloading now. The hotfix should be on the same link.
Thank you, this appears to have fixed it. Now my MAFAB entry works again.
Image
User avatar
Wohlstand
Moondust and TheXTech developer
Posts: 186
Joined: 10 years ago
First name: Vitaly
Pronouns: he/him/his
Location: Moscow, Russia

Re: Presenting: Lunadll for Lua!

Post by Wohlstand »

Rednaxela wrote:Anyone notice something different?
Image

(Hint: New feature implemented for the next LunaDLL release)
Do you implementing the alpha-channel render feature?
By anyway you can apply mask as alpha-channel (which PGE Editor/Engine are doing)
User avatar
Rednaxela
Maker of Shenanigans
Posts: 897
Joined: 10 years ago
Pronouns: they/them
https://rednaxela.talkhaus.com

Re: Presenting: Lunadll for Lua!

Post by Rednaxela »

Wohlstand wrote:Do you implementing the alpha-channel render feature?
By anyway you can apply mask as alpha-channel (which PGE Editor/Engine are doing)
I might consider adding using the mask file as an alpha channel as well, but for now what it's loading PNGs (with alpha channel) for NPCs (will add blocks, effects, etc later) and overriding the default graphics bitblt using that, and leaving the mask rendering the normal smbx way for GIF file graphics, for compatibility.
User avatar
Wohlstand
Moondust and TheXTech developer
Posts: 186
Joined: 10 years ago
First name: Vitaly
Pronouns: he/him/his
Location: Moscow, Russia

Re: Presenting: Lunadll for Lua!

Post by Wohlstand »

Rednaxela wrote:
Wohlstand wrote:Do you implementing the alpha-channel render feature?
By anyway you can apply mask as alpha-channel (which PGE Editor/Engine are doing)
I might consider adding using the mask file as an alpha channel as well, but for now what it's loading PNGs (with alpha channel) for NPCs (will add blocks, effects, etc later) and overriding the default graphics bitblt using that, and leaving the mask rendering the normal smbx way for GIF file graphics, for compatibility.
Good strategy: in the PGE Editor I made the bit-blit like mask applying to keep compatibility of some graphics and I was used bitblit as part of my lazy-fix tool which fixes incorrect masks (like copy-pasting of source sprite but with white color) and PGE Editor have a flag which toggles alpha-blending and bitblit mask applying in the "view -> Enable GFX Fix" menu:
It's a function which implementing the original bit-blit:
https://github.com/Wohlhabend-Networks/ ... cs.cpp#L65
BUT, it's an editor only thing, PGE Engine is uses the alpha-blending only

P.S. I think, we should hook the npc.txt parser and parse it we-self to prevent any dumb bugs (I have implemented parser of than format, I will need to port it into STL) like lines of spaces which causes crash. This way will give able to add the "image=" field which I will use in future with PGE to provide customization of image files
User avatar
Hoeloe
A2XT person
Posts: 1022
Joined: 12 years ago
Pronouns: she/her
Location: Spaaace

Re: Presenting: Lunadll for Lua!

Post by Hoeloe »

Rednaxela wrote:
Wohlstand wrote:Do you implementing the alpha-channel render feature?
By anyway you can apply mask as alpha-channel (which PGE Editor/Engine are doing)
I might consider adding using the mask file as an alpha channel as well, but for now what it's loading PNGs (with alpha channel) for NPCs (will add blocks, effects, etc later) and overriding the default graphics bitblt using that, and leaving the mask rendering the normal smbx way for GIF file graphics, for compatibility.
That's really neat! It's always been a pain dealing with masks, and pngs are a much more widely used format for this kind of thing.

I'd personally still like to see the placeSprite functions get a little more involved, too. As it stands, we can only draw bmps over the top of the game screen, but it would be nice to be able to draw into the game window alongside npcs and such, with extra features such as transparency, animation, scaling, etc. We could do so much with these additions, and if we could get a lightweight "drawPixel" function, we could pretty much render whatever we like, including 3D effects (though these would be limited since we're not using OpenGL as far as I'm aware).
Image
Image
Image
Image
Image
User avatar
FrozenQuills
hehe haha 2024
Posts: 843
Joined: 9 years ago
Location: my skull

Re: Presenting: Lunadll for Lua!

Post by FrozenQuills »

Hoeloe wrote:
Rednaxela wrote:
Wohlstand wrote:Do you implementing the alpha-channel render feature?
By anyway you can apply mask as alpha-channel (which PGE Editor/Engine are doing)
I might consider adding using the mask file as an alpha channel as well, but for now what it's loading PNGs (with alpha channel) for NPCs (will add blocks, effects, etc later) and overriding the default graphics bitblt using that, and leaving the mask rendering the normal smbx way for GIF file graphics, for compatibility.
That's really neat! It's always been a pain dealing with masks, and pngs are a much more widely used format for this kind of thing.

I'd personally still like to see the placeSprite functions get a little more involved, too. As it stands, we can only draw bmps over the top of the game screen, but it would be nice to be able to draw into the game window alongside npcs and such, with extra features such as transparency, animation, scaling, etc. We could do so much with these additions, and if we could get a lightweight "drawPixel" function, we could pretty much render whatever we like, including 3D effects (though these would be limited since we're not using OpenGL as far as I'm aware).
Oh man this is all super cool!
If we could just get a drawPixel function, we'll be able to build raytracers and FPS's with enough work... using SMBX of all things lol
But seriously though adjustable alpha channels with .pngs are super amazing enough.
Image
Image
avatar by crayonchewer!
Image
Image
Image
SMBX Tileset Compiler and Separator
The boss entry that made me eat a shoe.

5th place counter: 5
(SMBX Forums CC11, SMBX Forums CC12, Endgame Madness Contest, SMWC Kaizo Contest 2016, SMWC 24hr Contest 2018)
Post Reply