Page 39 of 76

Re: Need help with lua? - LunaLua General Help

Posted: Sun Dec 11, 2016 3:51 pm
by Angelus
So, I'm supposed to write it this way, right?
Spoiler: show
local HealthPoint = API.load("HealthPoint")
HealthPoint.setNPCHealth(47, 3)
HealthPoint.setNPCDamage(47, 8, 1)

Re: Need help with lua? - LunaLua General Help

Posted: Sun Dec 11, 2016 6:44 pm
by PixelPest
Looks right

Re: Need help with lua? - LunaLua General Help

Posted: Sun Dec 11, 2016 6:47 pm
by Angelus
Sadly it just gives me an error. I've read somewhere that we shouldn't use HealthPoint because it's old and broken or something alike. Is that right?

Re: Need help with lua? - LunaLua General Help

Posted: Sun Dec 11, 2016 6:49 pm
by PixelPest
Quite possibly. What's the error?

Re: Need help with lua? - LunaLua General Help

Posted: Sun Dec 11, 2016 7:25 pm
by Angelus
Something among these lines: "attempt to index field 'data' (a nil value)".

Re: Need help with lua? - LunaLua General Help

Posted: Mon Dec 12, 2016 3:00 am
by underFlo
Could you please either take a screenshot or paste the whole error? That makes it easier to troubleshoot the problem.

Re: Need help with lua? - LunaLua General Help

Posted: Wed Dec 14, 2016 10:33 pm
by senpaizuri
I'm new to LunaLua and I downloaded the LunaLua with the SMBX application. When I test my script (it is just a simple timer counting upwards per frame), nothing appears in the standard SMBX level editor. Is there something I'm doing wrong? I put the "lunadll.lua" file in my "test" folder in my "worlds" folder, where I also have the level I'm testing it with. Is this wrong?

Re: Need help with lua? - LunaLua General Help

Posted: Thu Dec 15, 2016 2:57 am
by Hoeloe
senpaizuri wrote:I'm new to LunaLua and I downloaded the LunaLua with the SMBX application. When I test my script (it is just a simple timer counting upwards per frame), nothing appears in the standard SMBX level editor. Is there something I'm doing wrong? I put the "lunadll.lua" file in my "test" folder in my "worlds" folder, where I also have the level I'm testing it with. Is this wrong?
Yes, that is wrong. You need your level file in the same location as your folder. The level file must not be inside that folder.

For example, if your level is called "myLevel.lvl", then you should have, in your episode folder, "myLevel.lvl", and a folder called "myLevel", inside which should be your lunadll.lua file.

Re: Need help with lua? - LunaLua General Help

Posted: Thu Dec 15, 2016 3:23 pm
by senpaizuri
Hoeloe wrote:For example, if your level is called "myLevel.lvl", then you should have, in your episode folder, "myLevel.lvl", and a folder called "myLevel", inside which should be your lunadll.lua file.
So the tree (file structure) should be the following, correct? If so, do I have to copy the lunalua.dll to other folders if I want the same to apply to other levels?
SMBX
-|Worlds
---|Test
------|MyLevel
---------|MyLevel.lvl
---------|lunadll.lua

Re: Need help with lua? - LunaLua General Help

Posted: Thu Dec 15, 2016 3:32 pm
by Emral
senpaizuri wrote:
Hoeloe wrote:For example, if your level is called "myLevel.lvl", then you should have, in your episode folder, "myLevel.lvl", and a folder called "myLevel", inside which should be your lunadll.lua file.
So the tree (file structure) should be the following, correct? If so, do I have to copy the lunalua.dll to other folders if I want the same to apply to other levels?
SMBX
-|Worlds
---|Test
------|MyLevel
---------|MyLevel.lvl
---------|lunadll.lua
No. MyLevel.lvl needs to be outside the folder. An episode setup would look like this:
SMBX
-|Worlds
---|Test
------|lunaworld.lua //affects all levels in the episode
------|MyLevel.lvl
------|MyLevel
---------|lunadll.lua
------|MyLevel2.lvl
------|MyLevel2
---------|lunadll.lua
------|MyLevel3.lvl
------|MyLevel3
---------|lunadll.lua
etc

Re: Need help with lua? - LunaLua General Help

Posted: Thu Dec 15, 2016 3:40 pm
by senpaizuri
I understand it now. Thanks, Enjl!

Re: Need help with lua? - LunaLua General Help

Posted: Fri Dec 16, 2016 6:07 am
by senpaizuri
How can I script: "If a player starts this level with anything other than Small Mario, they become small Mario." (also in relarion to Peach/Toad/Link getting 1 heart piece thing)? Or would it be easier to script that you become small Mario at the start of the level regardless?
I assume that it's possible to script because of lua's flexibility from what I can tell, but if it isn't, then that's a shame.

Re: Need help with lua? - LunaLua General Help

Posted: Fri Dec 16, 2016 10:15 am
by Emral
senpaizuri wrote:How can I script: "If a player starts this level with anything other than Small Mario, they become small Mario." (also in relarion to Peach/Toad/Link getting 1 heart piece thing)? Or would it be easier to script that you become small Mario at the start of the level regardless?
I assume that it's possible to script because of lua's flexibility from what I can tell, but if it isn't, then that's a shame.

Code: Select all

function onStart() --runs when the level starts
	player.powerup= 1 --sets player to small (mario, luigi)
	player:mem(0x16,FIELD_WORD,1) --set hearts to 1 (for peach, toad, link)
	player.reservePowerup = 0 --optional, resets item in reserve powerup box to none
end

Re: Need help with lua? - LunaLua General Help

Posted: Fri Dec 16, 2016 4:42 pm
by timocomsmbx2345
Quantix wrote:
timocomsmbx2345 wrote:
Jayce 777 wrote: Use moarrinkas.lua and NPCParse.lua.
but that didnt work for me the engine doesnt know those files are in th folders
Well, you need to type it as ("NPCs//moarrinkas") for it to work. Though, the API's kinda broken as of now so you're better off not using it anyway.
So, when will the rewrite begin just out of curiosity?

Re: Need help with lua? - LunaLua General Help

Posted: Fri Dec 16, 2016 4:49 pm
by Emral
timocomsmbx2345 wrote:
Quantix wrote:
timocomsmbx2345 wrote: but that didnt work for me the engine doesnt know those files are in th folders
Well, you need to type it as ("NPCs//moarrinkas") for it to work. Though, the API's kinda broken as of now so you're better off not using it anyway.
So, when will the rewrite begin just out of curiosity?
It will begin not too long after the NPC array gets expanded and the rewritten version will be bundled with 2.0 full release.

Re: Need help with lua? - LunaLua General Help

Posted: Fri Dec 16, 2016 5:00 pm
by timocomsmbx2345
in 2 weeks or so?

Re: Need help with lua? - LunaLua General Help

Posted: Fri Dec 16, 2016 5:11 pm
by Emral
timocomsmbx2345 wrote:in 2 weeks or so?
There are no plans to release another update for 2.0 before the year is over. Please be patient.

Re: Need help with lua? - LunaLua General Help

Posted: Fri Dec 16, 2016 7:47 pm
by timocomsmbx2345
Enjl wrote:
timocomsmbx2345 wrote:in 2 weeks or so?
There are no plans to release another update for 2.0 before the year is over. Please be patient.
maybe 8 weeks?

Re: Need help with lua? - LunaLua General Help

Posted: Fri Dec 16, 2016 10:21 pm
by RPG_Magician
Can someone give me an idea of how to get an npc to move (like a big leap) to one position to another?

Re: Need help with lua? - LunaLua General Help

Posted: Sat Dec 17, 2016 8:46 am
by PixelPest
(This is why I'm no longer to write code before breakfast)