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 » Tue Jun 28, 2016 12:32 pm

Mario_and_Luigi_55 wrote:Would it be possible to make a health bar like on this picture:
Image
for both player and a boss?
They both involve using a counter that decreases every time the boss or Mario is hurt and drawing images (Graphics.drawImageWP) to the screen of the counters. What I use to replicate Super Mario Galaxy's HUD in my Super Mario Galaxy Modder API is the same idea, if you want to check that out as an example

Mario_and_Luigi_55
Spike
Spike
Posts: 270
Joined: Sat Feb 27, 2016 12:01 pm

Re: Need help with lua? - LunaLua General Help

Postby Mario_and_Luigi_55 » Tue Jun 28, 2016 12:37 pm

PixelPest wrote:
Mario_and_Luigi_55 wrote:Would it be possible to make a health bar like on this picture:
Image
for both player and a boss?
They both involve using a counter that decreases every time the boss or Mario is hurt and drawing images (Graphics.drawImageWP) to the screen of the counters. What I use to replicate Super Mario Galaxy's HUD in my Super Mario Galaxy Modder API is the same idea, if you want to check that out as an example
OK. Thanks

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 » Tue Jun 28, 2016 3:42 pm

If I'm doing:

Code: Select all

for i = 1, #table do
Is there any way to find out which row of the table satisfies table ? Been wondering this for a while but haven't asked and can't find it anywhere

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 » Tue Jun 28, 2016 3:56 pm

PixelPest wrote:If I'm doing:

Code: Select all

for i = 1, #table do
Is there any way to find out which row of the table satisfies table ? Been wondering this for a while but haven't asked and can't find it anywhere

Row of the table? Your code is a loop which goes over each element in your table. Frame table[1] to table[#table]. What kind of rows are you talking about?

Alagirez
Ludwig von Koopa
Ludwig von Koopa
Posts: 3617
Joined: Tue Dec 02, 2014 2:28 am
Flair: Legalize Awooo!
Pronouns: He/Him/That wolf
Contact:

Re: Need help with lua? - LunaLua General Help

Postby Alagirez » Tue Jun 28, 2016 8:29 pm

HenryRichard wrote:You have to put calledEvent between the first pair of parenthesis.
Like this?

Code: Select all

function onEvent(calledEvent)
	if calledEvent =="KILLPlayer" then
		player:kill()
	end
end

HenryRichard
Reznor
Reznor
Posts: 2843
Joined: Mon Dec 23, 2013 12:09 pm
Flair: Is this where I type my password?
Contact:

Re: Need help with lua? - LunaLua General Help

Postby HenryRichard » Tue Jun 28, 2016 8:30 pm

yes

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 Jun 29, 2016 2:44 am

Enjl wrote:There's a player offset for link carrying a key. You can keep track of when he picks it up and when he loses it.
http://wohlsoft.ru/pgewiki/SMBX_Player_Offsets
Thank you so much, got it to work with Link! Probably not the most effective way of coding it but it works.
Spoiler: show
function onTick()
if player:mem(0x12,FIELD_WORD) < 0 then
key=1
end

if (player:mem(0x12,FIELD_WORD) == 0) and (key == 1) then
triggerEvent("Exit level")
key=2
end

end
In addition I noticed that for the other characters, throwing the key to lava or to a pit does not trigger the death-event, only using it on a door does. So I can use this code for the Link levels and the death-trigger for the other characters. 8-)

seiteom
Goomba
Goomba
Posts: 4
Joined: Mon Jun 27, 2016 5:59 pm

Re: Need help with lua? - LunaLua General Help

Postby seiteom » Fri Jul 01, 2016 8:59 am

S1eth wrote:
seiteom wrote:
I wish S1eths code was still available. Anyway, if we look past the problem that all npcs are assigned 3 health points by default by the HealthPoint API, it is also true that setNPCHealth cannot be called within the onLoop function. If you call it in the onLoad function it works well however, and healthPoint.setNPCHealth(1, 1) will make Goombas die after only one hit.

Hope this helps someone!
https://www.mediafire.com/?ue6293oz6dm7id3
Thank you so much S1eth! I have now got it to work. It should be added though that the user still have to use HealthPoint.MakeNPCNormal(id) to return all npcs' health to normal. Now however, that function does not remove all the npcs from the array that HealthPoint uses to keep track of all modifications, but rather set them to nil. If I had any suggestion, it would be to call MakeNPCNormal from inside the HealthPoint itself, or simply set all npcs to nil initially.

Again, thank you S1eth!

Quantumenace
Chain Chomp
Chain Chomp
Posts: 308
Joined: Mon Dec 28, 2015 2:17 am

Re: Need help with lua? - LunaLua General Help

Postby Quantumenace » Mon Jul 11, 2016 3:26 pm

I tried updating Lunalua on my 2.0 beta version recently and I keep getting this annoying error every time I start a game, load a world in game (or sometimes a level), or load a level in the legacy editor:

Errors while loading sound files
Some audio files failed to load:
C:\...\SMBX2\sound\fireball.mp3

All those sound files are .ogg. I tried converting an mp3 of the fireball sound but it still gives the error. Everything in the game appears to work, it's just irritating.
I followed the instructions on the first post, are there other Lunalua files I need to replace?

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

Re: Need help with lua? - LunaLua General Help

Postby S1eth » Wed Jul 13, 2016 5:53 am

Quantumenace wrote:I tried updating Lunalua on my 2.0 beta version recently and I keep getting this annoying error every time I start a game, load a world in game (or sometimes a level), or load a level in the legacy editor:

Errors while loading sound files
Some audio files failed to load:
C:\...\SMBX2\sound\fireball.mp3

All those sound files are .ogg. I tried converting an mp3 of the fireball sound but it still gives the error. Everything in the game appears to work, it's just irritating.
I followed the instructions on the first post, are there other Lunalua files I need to replace?
In your SMBX folder, open sounds.ini. Look for file="sound/fireball.mp3" and change that to ogg

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 Jul 13, 2016 7:27 am

S1eth wrote:
Quantumenace wrote:I tried updating Lunalua on my 2.0 beta version recently and I keep getting this annoying error every time I start a game, load a world in game (or sometimes a level), or load a level in the legacy editor:

Errors while loading sound files
Some audio files failed to load:
C:\...\SMBX2\sound\fireball.mp3

All those sound files are .ogg. I tried converting an mp3 of the fireball sound but it still gives the error. Everything in the game appears to work, it's just irritating.
I followed the instructions on the first post, are there other Lunalua files I need to replace?
In your SMBX folder, open sounds.ini. Look for file="sound/fireball.mp3" and change that to ogg
In the sounds.ini, the line already says .ogg. To fix the error specified, you'll have to uncomment the lines related to the fireball sound, because for whatever reason someone left semicolons in front of them.

Quantumenace
Chain Chomp
Chain Chomp
Posts: 308
Joined: Mon Dec 28, 2015 2:17 am

Re: Need help with lua? - LunaLua General Help

Postby Quantumenace » Wed Jul 13, 2016 1:40 pm

Thanks!

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 » Fri Jul 15, 2016 12:09 pm

I'm trying to get CinematX to work.

According to this (http://wohlsoft.ru/pgewiki/CinematX.lua - possibly outdated) article, you are supposed to just have these files installed

textblox.lua
GraphX.lua
Eventu.lua
Colliders.lua
Npcconfig.lua
Inputs.lua

And you are supposed to have this line in your lunalua.dll -file which I do.

cinematX = loadSharedAPI("cinematX")

And this happens, the default message UI is not replaced and instead there are two numbers displayed on top of the player and on top of an NPC that has a message. What could be causing this? I even reinstalled Lunalua to try to fix it. The graphic files are in the CinematX -folder.

Image

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 » Fri Jul 15, 2016 5:53 pm

Reign wrote:I'm trying to get CinematX to work.

According to this (http://wohlsoft.ru/pgewiki/CinematX.lua - possibly outdated) article, you are supposed to just have these files installed

textblox.lua
GraphX.lua
Eventu.lua
Colliders.lua
Npcconfig.lua
Inputs.lua

And you are supposed to have this line in your lunalua.dll -file which I do.

cinematX = loadSharedAPI("cinematX")

And this happens, the default message UI is not replaced and instead there are two numbers displayed on top of the player and on top of an NPC that has a message. What could be causing this? I even reinstalled Lunalua to try to fix it. The graphic files are in the CinematX -folder.

Image
Please correct me if I'm wrong, but I'm pretty sure CinematX is (or was at the release of SMBX 2.0 Beta) really heavy WIP, so maybe some aspects of it won't work. You can always take a look at the example episode though

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 » Sat Jul 16, 2016 2:04 am

Yeah, that's possible. :) I might just use the default message boxes instead, but which episode do you actually mean?

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 » Sat Jul 16, 2016 3:04 am

Reign wrote:Yeah, that's possible. :) I might just use the default message boxes instead, but which episode do you actually mean?
If you have 2.0, their is a little test episode that came with 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 » Sat Jul 16, 2016 5:14 am

I was using PGE+Luna-modified SMBX. Seems the fault might have been in that since I get the same error opening the example episode. I'll try to move on to SMBX 2 now then, however I already found some issues with that too... so moving on to complain in another thread.

Quantix
Chain Chomp
Chain Chomp
Posts: 333
Joined: Tue Jan 26, 2016 5:04 pm

Re: Need help with lua? - LunaLua General Help

Postby Quantix » Sat Jul 16, 2016 9:43 am

A question: is there a way to make all graphics of a certain type transparent with Lua?

underFlo
Wart
Wart
Posts: 4456
Joined: Mon Jul 14, 2014 10:44 am
Flair: sup im lesbiab
Pronouns: They/She
Contact:

Re: Need help with lua? - LunaLua General Help

Postby underFlo » Sat Jul 16, 2016 12:56 pm

Do you mean sprites you draw with Lua or built-in graphics like NPCs?

Yoshi021
Gold Yoshi Egg
Gold Yoshi Egg
Posts: 691
Joined: Thu Jan 21, 2016 9:06 pm
Flair: :)
Pronouns: He/Him

Re: Need help with lua? - LunaLua General Help

Postby Yoshi021 » Sat Jul 16, 2016 1:00 pm

Code: Select all

function onKeyUp(KEY_SPINJUMP)
 Counter = Counter + 1
end
I want to trigger an event, every time I press the "Spin Jump" button, but this script triggers the event everytime I press any button. How do I fix this?


Return to “LunaLua”

Who is online

Users browsing this forum: No registered users and 1 guest

SMWCentralTalkhausMario Fan Games GalaxyKafukaMarioWikiSMBXEquipoEstelari