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?
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 » Wed Apr 20, 2016 1:40 am

Just use Graphics.drawImageWP with the priority of the HUD - you can look up how to use it and what that priority is on the wiki.

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 » Wed Apr 20, 2016 11:57 pm

OK so i played some levels with custom HUD and this happens (I had this problem since i updated my Lunalua from 0.7.2.2 into 0.7.3) also this problem happens with Hudoftime and SMB3 Overhaul
Spoiler: show
Image

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 » Thu Apr 21, 2016 12:56 am

Looks like those levels used LunaDLL for the HUD. If you wanna replace the default HUD graphics, you can edit the hardcoded graphics using LunaLua, like h2643 did in his SMB2 HUD.

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 » Thu Apr 21, 2016 7:43 am

Camacho wrote:OK so i played some levels with custom HUD and this happens (I had this problem since i updated my Lunalua from 0.7.2.2 into 0.7.3) also this problem happens with Hudoftime and SMB3 Overhaul
Spoiler: show
Image

Invisible HUD icons happen to me too in level timer api. I have Lua 0.7.3.

RhysOwens
Nipper
Nipper
Posts: 423
Joined: Fri Apr 22, 2016 2:53 am

Re: Need help with lua? - LunaLua General Help

Postby RhysOwens » Fri Apr 22, 2016 3:05 am

I'm trying to give my enemies more health with the HealthPoint lua.
I've copied the HealthPoint.lua file into my level folder.
I'm experimenting using a Fighterfly and I'm giving him 2 more health points.
This is the code I'm using (excluding the spaces).
Spoiler: show
function onStart()
HealthPoint.setNPCHealth(54, 2)
end
When I test it, it gives me this error saying 'attempt to index global 'HealthPoint' (a nil value).'

My LunaLua isn't bugged (I think). I've tried the Red Birdo AI and it worked fine.
What am I missing here? :?

Hoeloe
Phanto
Phanto
Posts: 1465
Joined: Sat Oct 03, 2015 6:18 pm
Flair: The Codehaus Girl
Pronouns: she/her

Re: Need help with lua? - LunaLua General Help

Postby Hoeloe » Fri Apr 22, 2016 3:21 am

RhysOwens wrote: I've copied the HealthPoint.lua file into my level folder.
That's not how APIs work.
You don't need to copy anything. You just need to load the API in your Lua file using API.load, like this:

Code: Select all

local myAPI = API.load("myAPI");

lotus006
Spike
Spike
Posts: 284
Joined: Thu Sep 24, 2015 12:59 am

Re: Need help with lua? - LunaLua General Help

Postby lotus006 » Fri Apr 22, 2016 4:19 am

It is possible, a way to increment like a combustible a timer like +1 sec. each time I get a coins
and when the 1 sec is over the coin stocked disappear ?

Thanks

RhysOwens
Nipper
Nipper
Posts: 423
Joined: Fri Apr 22, 2016 2:53 am

Re: Need help with lua? - LunaLua General Help

Postby RhysOwens » Fri Apr 22, 2016 10:58 am

Hoeloe wrote:
RhysOwens wrote: I've copied the HealthPoint.lua file into my level folder.
That's not how APIs work.
You don't need to copy anything. You just need to load the API in your Lua file using API.load, like this:

Code: Select all

local myAPI = API.load("myAPI");
I changed my code to this:
Spoiler: show
local myAPI = API.load("HealthPoint");

function onStart()
HealthPoint.setNPCHealth(54, 2)
end
And it still says the HealthPoint is a nil value error.

Nat The Porcupine
Monty Mole
Monty Mole
Posts: 123
Joined: Tue Nov 10, 2015 2:55 pm

Re: Need help with lua? - LunaLua General Help

Postby Nat The Porcupine » Fri Apr 22, 2016 11:03 am

Has anyone else noticed that variables defined through pnpc's data property seem to have issues with generators & NPCs spawned from generators? Perhaps I'm using an outdated version?

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 » Fri Apr 22, 2016 11:08 am

RhysOwens wrote:
Hoeloe wrote:
RhysOwens wrote: I've copied the HealthPoint.lua file into my level folder.
That's not how APIs work.
You don't need to copy anything. You just need to load the API in your Lua file using API.load, like this:

Code: Select all

local myAPI = API.load("myAPI");
I changed my code to this:
Spoiler: show
local myAPI = API.load("HealthPoint");

function onStart()
HealthPoint.setNPCHealth(54, 2)
end
And it still says the HealthPoint is a nil value error.
nono, "myAPI" has to be "healthpoint".

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 » Fri Apr 22, 2016 11:25 am

Spinda wrote:
RhysOwens wrote:
Hoeloe wrote:
That's not how APIs work.
You don't need to copy anything. You just need to load the API in your Lua file using API.load, like this:

Code: Select all

local myAPI = API.load("myAPI");
I changed my code to this:
Spoiler: show
local myAPI = API.load("HealthPoint");

function onStart()
HealthPoint.setNPCHealth(54, 2)
end
And it still says the HealthPoint is a nil value error.
nono, "myAPI" has to be "healthpoint".
"HealthPoint"*

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 » Fri Apr 22, 2016 12:01 pm

whoops, you're right. Didn't see that he capitalised it like that.

Hoeloe
Phanto
Phanto
Posts: 1465
Joined: Sat Oct 03, 2015 6:18 pm
Flair: The Codehaus Girl
Pronouns: she/her

Re: Need help with lua? - LunaLua General Help

Postby Hoeloe » Fri Apr 22, 2016 12:04 pm

RhysOwens wrote: And it still says the HealthPoint is a nil value error.
I strongly suggest you read some Lua tutorials if you can't work out why this is happening. You're never going to be able to do anything if you have to resort to asking the forums for every small thing.

RhysOwens
Nipper
Nipper
Posts: 423
Joined: Fri Apr 22, 2016 2:53 am

Re: Need help with lua? - LunaLua General Help

Postby RhysOwens » Fri Apr 22, 2016 1:33 pm

Hoeloe wrote:
RhysOwens wrote: And it still says the HealthPoint is a nil value error.
I strongly suggest you read some Lua tutorials if you can't work out why this is happening. You're never going to be able to do anything if you have to resort to asking the forums for every small thing.
I'm copying from what it says in the HealthPoint lua.
I tired Misc.npctocoins and that's a nil value as well.

Next I tried putting local next to both Misc.npctocoins and HealthPoint.setNPCHealth and it says 'unexpected symbol near '.''
The Fighterfly still dies in 1 hit and doesn't turn into coins.

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 » Fri Apr 22, 2016 1:38 pm

RhysOwens wrote:
Hoeloe wrote:
RhysOwens wrote: And it still says the HealthPoint is a nil value error.
I strongly suggest you read some Lua tutorials if you can't work out why this is happening. You're never going to be able to do anything if you have to resort to asking the forums for every small thing.
I'm copying from what it says in the HealthPoint lua.
I tired Misc.npctocoins and that's a nil value as well.

Next I tried putting local next to both Misc.npctocoins and HealthPoint.setNPCHealth and it says 'unexpected symbol near '.''
The Fighterfly still dies in 1 hit and doesn't turn into coins.
I suggest you listen to Hoeloe. For the record, Lua is case-sensitive.

Hoeloe
Phanto
Phanto
Posts: 1465
Joined: Sat Oct 03, 2015 6:18 pm
Flair: The Codehaus Girl
Pronouns: she/her

Re: Need help with lua? - LunaLua General Help

Postby Hoeloe » Fri Apr 22, 2016 2:24 pm

RhysOwens wrote: I'm copying from what it says in the HealthPoint lua.
That's not a Lua tutorial. You should learn the basics of how Lua works as a programming language if you need to do more than just copy and paste.

RhysOwens
Nipper
Nipper
Posts: 423
Joined: Fri Apr 22, 2016 2:53 am

Re: Need help with lua? - LunaLua General Help

Postby RhysOwens » Fri Apr 22, 2016 4:00 pm

Hoeloe wrote:
RhysOwens wrote: I'm copying from what it says in the HealthPoint lua.
That's not a Lua tutorial. You should learn the basics of how Lua works as a programming language if you need to do more than just copy and paste.
I was copying the functions in the lua file near the beginning.

Hoeloe
Phanto
Phanto
Posts: 1465
Joined: Sat Oct 03, 2015 6:18 pm
Flair: The Codehaus Girl
Pronouns: she/her

Re: Need help with lua? - LunaLua General Help

Postby Hoeloe » Fri Apr 22, 2016 5:45 pm

RhysOwens wrote: I was copying the functions in the lua file near the beginning.
But you didn't understand enough of what you were doing to know that you need to define variables before you use 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 » Sat Apr 23, 2016 3:13 am

Nat The Porcupine wrote:Has anyone else noticed that variables defined through pnpc's data property seem to have issues with generators & NPCs spawned from generators? Perhaps I'm using an outdated version?
Could you be more specific? Are the entries getting shuffled to the wrong NPC or something?

RhysOwens
Nipper
Nipper
Posts: 423
Joined: Fri Apr 22, 2016 2:53 am

Re: Need help with lua? - LunaLua General Help

Postby RhysOwens » Sat Apr 23, 2016 4:41 am

Hoeloe wrote:
RhysOwens wrote: I was copying the functions in the lua file near the beginning.
But you didn't understand enough of what you were doing to know that you need to define variables before you use them.
Do I call the variable HealthPoint?
I've abandoned the HealthPoint thing for now.


Return to “LunaLua”

Who is online

Users browsing this forum: No registered users and 3 guests

SMWCentralTalkhausMario Fan Games GalaxyKafukaMarioWikiSMBXEquipoEstelari