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?
Angelus
Tweeter
Tweeter
Posts: 132
Joined: Tue Jun 21, 2016 9:38 am

Re: Need help with lua? - LunaLua General Help

Postby Angelus » Sun Dec 11, 2016 3:51 pm

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)

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 » Sun Dec 11, 2016 6:44 pm

Looks right

Angelus
Tweeter
Tweeter
Posts: 132
Joined: Tue Jun 21, 2016 9:38 am

Re: Need help with lua? - LunaLua General Help

Postby Angelus » Sun Dec 11, 2016 6:47 pm

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?

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 » Sun Dec 11, 2016 6:49 pm

Quite possibly. What's the error?

Angelus
Tweeter
Tweeter
Posts: 132
Joined: Tue Jun 21, 2016 9:38 am

Re: Need help with lua? - LunaLua General Help

Postby Angelus » Sun Dec 11, 2016 7:25 pm

Something among these lines: "attempt to index field 'data' (a nil value)".

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 » Mon Dec 12, 2016 3:00 am

Could you please either take a screenshot or paste the whole error? That makes it easier to troubleshoot the problem.

senpaizuri
Cheep-Cheep
Cheep-Cheep
Posts: 14
Joined: Thu Sep 24, 2015 4:27 pm

Re: Need help with lua? - LunaLua General Help

Postby senpaizuri » Wed Dec 14, 2016 10:33 pm

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?

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 » Thu Dec 15, 2016 2:57 am

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.

senpaizuri
Cheep-Cheep
Cheep-Cheep
Posts: 14
Joined: Thu Sep 24, 2015 4:27 pm

Re: Need help with lua? - LunaLua General Help

Postby senpaizuri » Thu Dec 15, 2016 3:23 pm

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

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 » Thu Dec 15, 2016 3:32 pm

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

senpaizuri
Cheep-Cheep
Cheep-Cheep
Posts: 14
Joined: Thu Sep 24, 2015 4:27 pm

Re: Need help with lua? - LunaLua General Help

Postby senpaizuri » Thu Dec 15, 2016 3:40 pm

I understand it now. Thanks, Enjl!

senpaizuri
Cheep-Cheep
Cheep-Cheep
Posts: 14
Joined: Thu Sep 24, 2015 4:27 pm

Re: Need help with lua? - LunaLua General Help

Postby senpaizuri » Fri Dec 16, 2016 6:07 am

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.

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 Dec 16, 2016 10:15 am

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

timocomsmbx2345
Foo
Foo
Posts: 853
Joined: Sat Feb 06, 2016 1:44 pm
Contact:

Re: Need help with lua? - LunaLua General Help

Postby timocomsmbx2345 » Fri Dec 16, 2016 4:42 pm

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?

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 Dec 16, 2016 4:49 pm

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.

timocomsmbx2345
Foo
Foo
Posts: 853
Joined: Sat Feb 06, 2016 1:44 pm
Contact:

Re: Need help with lua? - LunaLua General Help

Postby timocomsmbx2345 » Fri Dec 16, 2016 5:00 pm

in 2 weeks or so?

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 Dec 16, 2016 5:11 pm

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.

timocomsmbx2345
Foo
Foo
Posts: 853
Joined: Sat Feb 06, 2016 1:44 pm
Contact:

Re: Need help with lua? - LunaLua General Help

Postby timocomsmbx2345 » Fri Dec 16, 2016 7:47 pm

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?

RPG_Magician
Snifit
Snifit
Posts: 216
Joined: Tue Sep 06, 2016 7:22 am

Re: Need help with lua? - LunaLua General Help

Postby RPG_Magician » Fri Dec 16, 2016 10:21 pm

Can someone give me an idea of how to get an npc to move (like a big leap) to one position to another?

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 » Sat Dec 17, 2016 8:46 am

(This is why I'm no longer to write code before breakfast)
Last edited by PixelPest on Sat Dec 17, 2016 9:53 am, edited 2 times in total.


Return to “LunaLua”

Who is online

Users browsing this forum: No registered users and 1 guest

SMWCentralTalkhausMario Fan Games GalaxyKafukaMarioWikiSMBXEquipoEstelari