(shouting)

LunaDLL/LunaLUA help thread

The second SMBX collab!
User avatar
Hoeloe
A2XT person
Posts: 1016
Joined: 12 years ago
Pronouns: she/her
Location: Spaaace

Re: LunaDLL/LunaLUA help thread

Post by Hoeloe »

Axon wrote:
Louiejub wrote: This was the code that SAJewers gave me:

Code: Select all

function onLoad()
   if (player.isValid) then
      player.character = CHARACTER_TOAD;
   end

end
Try replacing the two "player" with two "Player(1)", maybe.
Don't do that. It makes no difference and is less readable.
Image
Image
Image
Image
Image
User avatar
GenesisJames
Music reviewer and drawer of cute girls.
Posts: 529
Joined: 10 years ago
Location: United States

Re: LunaDLL/LunaLUA help thread

Post by GenesisJames »

Alrighty, I'll try a few of these things out. Thanks for the help, guys!
User avatar
docopoper
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla non pharetra enim, nec maximus odio.
Posts: 78
Joined: 12 years ago
First name: Shane Farrell
Pronouns: they/he
Location: Ireland

Re: LunaDLL/LunaLUA help thread

Post by docopoper »

Is it possible to do simple networking? I want to see if it's possible to store a replay of everyone playing on a server and have players race ghosts of each other.
The first thing I would do with infinite power would be to make myself a cave where I could look at my shadow forever.

Image <- Go team Yeah Doctor Shemp.!
Image <- That's everyone being nice to me. ^^

I made a game called Utter Confusion! Play it! :D
It's a lot of fun and has been incredibly popular at every indie game dev party I've brought it to.
User avatar
Kevsoft
LunaLua Master Developer
Posts: 83
Joined: 9 years ago

Re: LunaDLL/LunaLUA help thread

Post by Kevsoft »

docopoper wrote:Is it possible to do simple networking? I want to see if it's possible to store a replay of everyone playing on a server and have players race ghosts of each other.
I could add simple networking... It depends on what kind of networking you need. For simple HTTP GET request, I already have a system but it is not bound to lua yet.
User avatar
docopoper
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla non pharetra enim, nec maximus odio.
Posts: 78
Joined: 12 years ago
First name: Shane Farrell
Pronouns: they/he
Location: Ireland

Re: LunaDLL/LunaLUA help thread

Post by docopoper »

Yeah, that could work. Ideally both GET and POST for retrieving and submitting replays, if there is some way of me sending large amounts of data through the GET request then it will work. I think I recall something about a character limit on GET requests though, so that would make submitting a bit more awkward if it existed. That limit might just have been in a specific API I was using though.

Either way though, no need for sockets or anything like that.
The first thing I would do with infinite power would be to make myself a cave where I could look at my shadow forever.

Image <- Go team Yeah Doctor Shemp.!
Image <- That's everyone being nice to me. ^^

I made a game called Utter Confusion! Play it! :D
It's a lot of fun and has been incredibly popular at every indie game dev party I've brought it to.
User avatar
Kevsoft
LunaLua Master Developer
Posts: 83
Joined: 9 years ago

Re: LunaDLL/LunaLUA help thread

Post by Kevsoft »

Okay, I added that request to the LunaLua Whishlist
User avatar
GenesisJames
Music reviewer and drawer of cute girls.
Posts: 529
Joined: 10 years ago
Location: United States

Re: LunaDLL/LunaLUA help thread

Post by GenesisJames »

Sooo, notepad is only letting me save my code as a txt file, and there's no other options. Anything that I'm doing wrong? This lua stuff is confusing, haha~
User avatar
Wohlstand
Moondust and TheXTech developer
Posts: 186
Joined: 10 years ago
First name: Vitaly
Pronouns: he/him/his
Location: Moscow, Russia

Re: LunaDLL/LunaLUA help thread

Post by Wohlstand »

Louiejub wrote:Sooo, notepad is only letting me save my code as a txt file, and there's no other options. Anything that I'm doing wrong? This lua stuff is confusing, haha~
While you "saving as" youe file, type your filename in quities:
you typed

Code: Select all

meow.lua
but type this:

Code: Select all

"meow.lua"
instead of previous

Note: in the file type combo-box choice "All files" :P
User avatar
GenesisJames
Music reviewer and drawer of cute girls.
Posts: 529
Joined: 10 years ago
Location: United States

Re: LunaDLL/LunaLUA help thread

Post by GenesisJames »

Wohlstand wrote:
Louiejub wrote:Sooo, notepad is only letting me save my code as a txt file, and there's no other options. Anything that I'm doing wrong? This lua stuff is confusing, haha~
While you "saving as" youe file, type your filename in quities:
you typed

Code: Select all

meow.lua
but type this:

Code: Select all

"meow.lua"
instead of previous

Note: in the file type combo-box choice "All files" :P
Ahhh, thank you! That worked! :D
User avatar
Holy
Posts: 133
Joined: 12 years ago

Re: LunaDLL/LunaLUA help thread

Post by Holy »

Arright, what's the best way to do top/bottom wraparound? I'm guessing there's no way to link it up so the player can have like, half their body on top and half on the bottom at the same time.
User avatar
snoruntpyro
cutest girl 2023
Posts: 884
Joined: 9 years ago
Pronouns: she/her
Contact:

Re: LunaDLL/LunaLUA help thread

Post by snoruntpyro »

Holy wrote:Arright, what's the best way to do top/bottom wraparound? I'm guessing there's no way to link it up so the player can have like, half their body on top and half on the bottom at the same time.
The half and half thing, pretty sure it's not possible. But, funny story - a level I'm making did vertical wraparound as well. The way I did it was to do BGO.getIntersecting and if the player touched the background object (in my case, the square glass smb3 bgo), they would be warped to a Y-coordinate defined by the section. So like this:

Code: Select all

for _, b in pairs(BGO.getIntersecting(player.x, player.y, player.x + player.width, player.y + player.height)) do
	if b.id == 99 then
		player.y = wrapTable[player.section]-64;
	end
end
with wrapTable[0], wrapTable[1], etc being defined at the start of the line. I did the same for NPCs, the only changes were changing the BGO and removing the -64 because if they go where the player would normally go they'd get despawned.

You don't have to have the -64 but it looks way smoother if you respawn the player offscreen.
Image
Image
Image
Image
Image
User avatar
Alice
Posts: 2367
Joined: 12 years ago
Pronouns: Girl person
Location: Wonderland

Re: LunaDLL/LunaLUA help thread

Post by Alice »

Pyro wrote:The half and half thing, pretty sure it's not possible.
Collisions may not be possible (didn't someone do a collisions library though?) but the visual part should be at least just by placing an image with an offset of the screen size from the player's position according to the player's current sprite.
User avatar
Holy
Posts: 133
Joined: 12 years ago

Re: LunaDLL/LunaLUA help thread

Post by Holy »

Pyro wrote:

Code: Select all

for _, b in pairs(BGO.getIntersecting(player.x, player.y, player.x + player.width, player.y + player.height)) do
	if b.id == 99 then
		player.y = wrapTable[player.section]-64;
	end
end
Huh, I'll have to try this out in a sec. Here's what I came up with after messing with some of red's code from a ways back in the thread

Code: Select all

function onLoop()
	local sectBottom = player.sectionObj.boundary.bottom
	local sectTop = player.sectionObj.boundary.top

	if (player.speedY > 0) then
		if (player.y > sectBottom) then
			--bottom to top
			player.y = sectTop - 48
		end
	elseif (player.speedY < 0) then
		if (player.y < sectTop - 48) then
			--top to bottom
			player.y = sectBottom
		end
	end
end
Basically depending on if you're heading downwards or upwards it sends you around the right way. Seems to work alright so far.
Alice wrote:
Pyro wrote:The half and half thing, pretty sure it's not possible.
Collisions may not be possible (didn't someone do a collisions library though?) but the visual part should be at least just by placing an image with an offset of the screen size from the player's position according to the player's current sprite.
HMMM, yeah, and if you made sure no enemies could get to you along the screen boundary it might actually work really good. I might mess with that.
User avatar
Duker
I post u2be tags I guess
Posts: 272
Joined: 13 years ago
Location: The Comment Section

Re: LunaDLL/LunaLUA help thread

Post by Duker »

Edit: Mistake found, hiding in spoiler tags to remove the bloat.
So, I want to make the player invisible because reason, the only potential way I've found in the documentation would be to set the sprite offset to an empty area but the function doesn't match the documentation...

http://engine.wohlnet.ru/pgewiki/PlayerSettings_(class) says:

Code: Select all

PlayerSettings:setSpriteOffsetX(number indexX, number indexY, number value)
But the debug error says:
Image
What the hell? Where do I even get a lua_State pointer from?

Edit: Figured out another easier way, I'll just take the spritesheet for a powerup I'm not gonna use and empty it and force that powerup for the duration I need the effect. Still wondering what's up with the mismatch though.[/spoiler]

In other news, Misc.doBombExplosion doesn't seem to exist. It's a 7.2.3 thing apparently, the dev kit is 7.2.2.
Last edited by Duker 8 years ago, edited 2 times in total.
fart.
User avatar
Rednaxela
Maker of Shenanigans
Posts: 897
Joined: 10 years ago
Pronouns: they/them
https://rednaxela.talkhaus.com

Re: LunaDLL/LunaLUA help thread

Post by Rednaxela »

Duker wrote:

Code: Select all

PlayerSettings:setSpriteOffsetX(number indexX, number indexY, number value)
But the debug error says:
Image
What the hell? Where do I even get a lua_State pointer from?.[/spoiler]
Could you post your code? You don't need lua_State, that's automatic, and I'm pretty sure the documentation is correct. There's some other mistake you're making.
User avatar
Duker
I post u2be tags I guess
Posts: 272
Joined: 13 years ago
Location: The Comment Section

Re: LunaDLL/LunaLUA help thread

Post by Duker »

Rednaxela wrote:
Duker wrote:

Code: Select all

PlayerSettings:setSpriteOffsetX(number indexX, number indexY, number value)
But the debug error says:
Image
What the hell? Where do I even get a lua_State pointer from?.[/spoiler]
Could you post your code? You don't need lua_State, that's automatic, and I'm pretty sure the documentation is correct. There's some other mistake you're making.

Code: Select all

local PlrSet = PlayerSettings.get(CHARACTER_TOAD, PLAYER_BIG)
PlrSet.setSpriteOffsetX(0, 0, 0)
Not much room for mistakes when it's only two short and simple lines... So it needed to be a ':' not a '.', well sheisse mistakes was had anyway. Mistake found, moving along.
Last edited by Duker 8 years ago, edited 1 time in total.
fart.
User avatar
Hoeloe
A2XT person
Posts: 1016
Joined: 12 years ago
Pronouns: she/her
Location: Spaaace

Re: LunaDLL/LunaLUA help thread

Post by Hoeloe »

Duker wrote:
Rednaxela wrote:
Duker wrote:

Code: Select all

PlayerSettings:setSpriteOffsetX(number indexX, number indexY, number value)
But the debug error says:
Image
What the hell? Where do I even get a lua_State pointer from?.[/spoiler]
Could you post your code? You don't need lua_State, that's automatic, and I'm pretty sure the documentation is correct. There's some other mistake you're making.

Code: Select all

local PlrSet = PlayerSettings.get(CHARACTER_TOAD, PLAYER_BIG)
PlrSet.setSpriteOffsetX(0, 0, 0)
Not much room for mistakes when it's only two short and simple lines...
There is a difference between . and :

: fills the first argument automatically, so

Code: Select all

obj:func(args)
Is the same as

Code: Select all

obj.func(obj, args)
Image
Image
Image
Image
Image
User avatar
Duker
I post u2be tags I guess
Posts: 272
Joined: 13 years ago
Location: The Comment Section

Re: LunaDLL/LunaLUA help thread

Post by Duker »

Hoeloe wrote:
Duker wrote:
Rednaxela wrote:Could you post your code? You don't need lua_State, that's automatic, and I'm pretty sure the documentation is correct. There's some other mistake you're making.

Code: Select all

local PlrSet = PlayerSettings.get(CHARACTER_TOAD, PLAYER_BIG)
PlrSet.setSpriteOffsetX(0, 0, 0)
Not much room for mistakes when it's only two short and simple lines...
There is a difference between . and :

: fills the first argument automatically, so

Code: Select all

obj:func(args)
Is the same as

Code: Select all

obj.func(obj, args)
[/spoiler]
Yeah I noticed that I had misread : for . and edited my post seconds before you posted. I thought for sure I tested PlrSet.setSpriteOffsetX(PlrSet, 0, 0, 0) which would have worked too but apparently I didn't.
fart.
User avatar
Karatekid5
Welcome to the resort!
Posts: 78
Joined: 14 years ago
Location: Pennsylvania
Contact:

Re: LunaDLL/LunaLUA help thread

Post by Karatekid5 »

This is my first time working with CinematX, and since my level uses a lot of friendly NPCs I thought it'd be cool to use CinematX NPC dialogue, since it looks more fluid than the default NPC dialogue. I'm not trying to do any fancy cutscenes or actor manipulation, I just want to do some simple dialogue like this. I have some code here but I have no idea how to connect the NPC to the routine I want it to run.

Code:

Code: Select all

cinematX = loadSharedAPI("cinematX")

cinematX.configExt ({"hudBox"=false, "overrideNpcText"=true, "imageUi"=false, "textbloxSub"=true})

function scene_1 ()
    cinematX.startDialogExt (bellossom1, Bellossom, "Hello there! Welcome to the Starlight Resort!")
    cinematX.waitForDialog()
    cinematX.endCutscene ()
end
NPC Tags:

Code: Select all

{key=bellossom1, name=Bellossom, routine=function_scene1}
Yoshi Ambassador!
Image
WasabiJellyfish
Posts: 117
Joined: 9 years ago

Re: LunaDLL/LunaLUA help thread

Post by WasabiJellyfish »

Karatekid5 wrote:This is my first time working with CinematX, and since my level uses a lot of friendly NPCs I thought it'd be cool to use CinematX NPC dialogue, since it looks more fluid than the default NPC dialogue. I'm not trying to do any fancy cutscenes or actor manipulation, I just want to do some simple dialogue like this. I have some code here but I have no idea how to connect the NPC to the routine I want it to run.

Code:

Code: Select all

cinematX = loadSharedAPI("cinematX")

cinematX.configExt ({"hudBox"=false, "overrideNpcText"=true, "imageUi"=false, "textbloxSub"=true})

function scene_1 ()
    cinematX.startDialogExt (bellossom1, Bellossom, "Hello there! Welcome to the Starlight Resort!")
    cinematX.waitForDialog()
    cinematX.endCutscene ()
end
NPC Tags:

Code: Select all

{key=bellossom1, name=Bellossom, routine=function_scene1}
Routine = should just be scene1
Also don't use end cutscene for a coroutine
User avatar
Karatekid5
Welcome to the resort!
Posts: 78
Joined: 14 years ago
Location: Pennsylvania
Contact:

Re: LunaDLL/LunaLUA help thread

Post by Karatekid5 »

I fixed the mistakes, but I now get an error upon loading the level. What exactly does this mean?
Attachments
lunaerror.png
lunaerror.png (3.75 KiB) Viewed 5687 times
Yoshi Ambassador!
Image
WasabiJellyfish
Posts: 117
Joined: 9 years ago

Re: LunaDLL/LunaLUA help thread

Post by WasabiJellyfish »

I think you can just write cinematX.configExt(false,true,false,true) I mean you can just get rid of the config line completely too cause you aren't changing anything as far as I can see.
User avatar
Kevsoft
LunaLua Master Developer
Posts: 83
Joined: 9 years ago

Re: LunaDLL/LunaLUA help thread

Post by Kevsoft »

Try to remove the "

Code: Select all

 cinematX.configExt ({hudBox=false, overrideNpcText=true, imageUi=false, textbloxSub=true}) 
User avatar
Karatekid5
Welcome to the resort!
Posts: 78
Joined: 14 years ago
Location: Pennsylvania
Contact:

Re: LunaDLL/LunaLUA help thread

Post by Karatekid5 »

I tried removing the quotation marks and I ended up getting another error. Also, I do want to set a few things so removing the config line wouldn't be an option.
Attachments
lunaerror2.png
lunaerror2.png (5.12 KiB) Viewed 7098 times
Yoshi Ambassador!
Image
WasabiJellyfish
Posts: 117
Joined: 9 years ago

Re: LunaDLL/LunaLUA help thread

Post by WasabiJellyfish »

Okay what you have there is the basic true false thing that is prepackaged anyway but okay. Did you get rid of the cinematX before .configExt? Idk why that would happen otherwise
Post Reply