Page 15 of 76

Re: Need help with lua? - LunaLua General Help

Posted: Wed Apr 20, 2016 1:40 am
by underFlo
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.

Re: Need help with lua? - LunaLua General Help

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

Re: Need help with lua? - LunaLua General Help

Posted: Thu Apr 21, 2016 12:56 am
by underFlo
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.

Re: Need help with lua? - LunaLua General Help

Posted: Thu Apr 21, 2016 7:43 am
by Mario_and_Luigi_55
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.

Re: Need help with lua? - LunaLua General Help

Posted: Fri Apr 22, 2016 3:05 am
by RhysOwens
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? :?

Re: Need help with lua? - LunaLua General Help

Posted: Fri Apr 22, 2016 3:21 am
by Hoeloe
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");

Re: Need help with lua? - LunaLua General Help

Posted: Fri Apr 22, 2016 4:19 am
by lotus006
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

Re: Need help with lua? - LunaLua General Help

Posted: Fri Apr 22, 2016 10:58 am
by RhysOwens
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.

Re: Need help with lua? - LunaLua General Help

Posted: Fri Apr 22, 2016 11:03 am
by Nat The Porcupine
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?

Re: Need help with lua? - LunaLua General Help

Posted: Fri Apr 22, 2016 11:08 am
by underFlo
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".

Re: Need help with lua? - LunaLua General Help

Posted: Fri Apr 22, 2016 11:25 am
by Emral
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"*

Re: Need help with lua? - LunaLua General Help

Posted: Fri Apr 22, 2016 12:01 pm
by underFlo
whoops, you're right. Didn't see that he capitalised it like that.

Re: Need help with lua? - LunaLua General Help

Posted: Fri Apr 22, 2016 12:04 pm
by Hoeloe
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.

Re: Need help with lua? - LunaLua General Help

Posted: Fri Apr 22, 2016 1:33 pm
by RhysOwens
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.

Re: Need help with lua? - LunaLua General Help

Posted: Fri Apr 22, 2016 1:38 pm
by Emral
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.

Re: Need help with lua? - LunaLua General Help

Posted: Fri Apr 22, 2016 2:24 pm
by Hoeloe
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.

Re: Need help with lua? - LunaLua General Help

Posted: Fri Apr 22, 2016 4:00 pm
by RhysOwens
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.

Re: Need help with lua? - LunaLua General Help

Posted: Fri Apr 22, 2016 5:45 pm
by Hoeloe
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.

Re: Need help with lua? - LunaLua General Help

Posted: Sat Apr 23, 2016 3:13 am
by Quantumenace
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?

Re: Need help with lua? - LunaLua General Help

Posted: Sat Apr 23, 2016 4:41 am
by RhysOwens
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.