Need help with lua? - LunaLua General Help

Post here for help and support regarding LunaLua and SMBX2's libraries and features.

Moderator: Userbase Moderators

Goldenemerl64
Fighter Fly
Fighter Fly
Posts: 38
Joined: Tue Jul 07, 2020 3:50 pm

Re: Need help with lua? - LunaLua General Help

Postby Goldenemerl64 » Sun Jul 26, 2020 6:44 pm

oh ok, Thanks Again

Goldenemerl64
Fighter Fly
Fighter Fly
Posts: 38
Joined: Tue Jul 07, 2020 3:50 pm

Re: Need help with lua? - LunaLua General Help

Postby Goldenemerl64 » Wed Jul 29, 2020 3:26 am

Quick Question: can i add harm types in Npc.txt?

Trying to make the spark slime not be killed by a spinjump.
Image

Sorry for the Terrible Gif

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 29, 2020 4:18 am

Harm types can only be set in lua. Think for example:
NPC.config[id].vulnerableharmtypes = {whatever you'd also put here in an npc-n.lua}
Also worth noting is that for IDs under 292, harm types can only be added, not replaced.

Goldenemerl64
Fighter Fly
Fighter Fly
Posts: 38
Joined: Tue Jul 07, 2020 3:50 pm

Re: Need help with lua? - LunaLua General Help

Postby Goldenemerl64 » Wed Jul 29, 2020 8:46 am

ok, Thanks

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 Jul 31, 2020 7:22 am

Goldenemerl64 wrote:
Wed Jul 29, 2020 8:46 am
ok, Thanks
Quick addendum: I was wrong in my previous message. The table isn't actually what you put in lua.
Basically, you know about npcManager.registerHarmTypes(id, harmList, effectTable), right?
The value contained in vulnerableharmtypes would be the harmList. If you also want to manipulate the effectTable, you have to use registerHarmTypes instead.

Goldenemerl64
Fighter Fly
Fighter Fly
Posts: 38
Joined: Tue Jul 07, 2020 3:50 pm

Re: Need help with lua? - LunaLua General Help

Postby Goldenemerl64 » Sat Aug 01, 2020 10:16 am

Quick addendum: I was wrong in my previous message. The table isn't actually what you put in lua.
Basically, you know about npcManager.registerHarmTypes(id, harmList, effectTable), right?
The value contained in vulnerableharmtypes would be the harmList. If you also want to manipulate the effectTable, you have to use registerHarmTypes instead.
Oh ok, Thanks for the Information.
Basically, you know about npcManager.registerHarmTypes(id, harmList, effectTable), right?
I Actually kinda know about that, but not to much about it.
The value contained in vulnerableharmtypes would be the harmList. If you also want to manipulate the effectTable, you have to use registerHarmTypes instead.
Where are those Located?

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 » Sat Aug 01, 2020 10:22 am

Goldenemerl64 wrote:
Sat Aug 01, 2020 10:16 am
Where are those Located?
They are located in the previous quote. You can look at any npc-n.lua file for reference. registerHarmTypes gets the npc's ID, a list of harm types, and then a table of effect ids mapped to the respective harm type. Those correspond to the arguments and function in the previous quote.

lolcode
Hoopster
Hoopster
Posts: 41
Joined: Sat Jul 11, 2020 7:55 pm

Re: Need help with lua? - LunaLua General Help

Postby lolcode » Sat Aug 08, 2020 7:40 am

so... how do i make multi hp npcs?

Fuyu
Fry Guy
Fry Guy
Posts: 3137
Joined: Sat Dec 21, 2013 2:40 pm
Pronouns: He/Him

Re: Need help with lua? - LunaLua General Help

Postby Fuyu » Sat Aug 08, 2020 9:00 am

I don't know if I should make a thread for this or not since this is more of a suggestion rather than me asking for help. I've been playing Celeste lately, and I think it shows considering my last two levels, but something caught my attention and that is how it handles beat blocks.

If the player is colliding with the off version of the beat block said block doesn't turn solid until the player stops colliding with it. This of course in tandem with the music rhythm. I thought maybe the blinking blocks we have in SMBX 2.0 could work the same way, since I want to believe I am not alone when I think the player being pushed upon having the blocks become solid looks weird and wrong.

Keep in mind Celeste doesn't just not switch the blocks, it only switches those where the player isn't colliding with, and as soon as the player stops colliding with them it becomes solid.

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 » Sat Aug 08, 2020 9:37 am

Might be fun as an optional flag. By default I personally wouldn't wanna remove the possibilities in design put forth by killing players by crushing them in a timer challenge.
If you wanna do it on your own time, you can do a getIntersecting check over overlapping blocks to tag them with a variable that prevents them from transforming, and turning them into what they're supposed to be when the overlap stops (if the block was in the list from last frame but not the list from this frame). A way to blacklist such blocks from transforming that would work with an unmodified basegame beat block system might be to change their IDs temporarily to ones not registered to the transformation table, that merely look the same as the ones that actually switch. To figure out what Id they SHOULD have when overlap ends, I think there are some switch state variables you can use in the library that manages the beat rhythm.

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 » Sat Aug 08, 2020 10:39 am

Enjl wrote:
Sat Aug 08, 2020 9:37 am
you can do a getIntersecting check over overlapping blocks to tag them with a variable that prevents them from transforming
No you can't. Beat blocks don't "transform" between different IDs, they change their state, so you'd have to prevent the state from changing for all blocks of this type, which is much more complicated and will drastically throw off the timing.

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 » Sat Aug 08, 2020 10:57 am

Hoeloe wrote:
Sat Aug 08, 2020 10:39 am
Enjl wrote:
Sat Aug 08, 2020 9:37 am
you can do a getIntersecting check over overlapping blocks to tag them with a variable that prevents them from transforming
No you can't. Beat blocks don't "transform" between different IDs, they change their state, so you'd have to prevent the state from changing for all blocks of this type, which is much more complicated and will drastically throw off the timing.
Ah, well, in that case, what I described is probably doable with the older library at the very least.

MarioLover64
Spike
Spike
Posts: 259
Joined: Fri Apr 26, 2019 6:09 pm

Re: Need help with lua? - LunaLua General Help

Postby MarioLover64 » Tue Aug 25, 2020 7:06 pm

MarioLover64 wrote:
Thu Aug 22, 2019 9:11 pm
ok so camLock refuses to work at all. it does absolutely nothing. There aren't even any errors.

Added in 36 seconds:
Oh yeah, here's my code

Code: Select all

--------------------------------------------------
-- World map code
-- Created 10:40 2020-8-25
--------------------------------------------------
extMap = require("extended_map")
camLock = require("camLock")
-- Run code on first frame of the world map
function onStart()
    --Your code here
	camLock.addZone(96,320,1216,864,1)
end

-- Run code every frame (~1/65 second)
-- (code will be executed before game logic will be processed)
function onTick()
    --Your code here
end

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 Aug 26, 2020 12:58 am

96,320,1216,864´are coordinates somewhere in section 11. Is that intentional? Right-click an object in the editor in the top left corner of where you want the zone and copy the X/Y coordinates to check.

MarioLover64
Spike
Spike
Posts: 259
Joined: Fri Apr 26, 2019 6:09 pm

Re: Need help with lua? - LunaLua General Help

Postby MarioLover64 » Wed Aug 26, 2020 1:58 am

What sections? This is for the world map

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 Aug 26, 2020 2:42 am

You didn't say so I didn't know, sorry.
Depending on which version of camlock this is, it might not work on the map. Does the script file have an "onDrawWorld" function?
If yes, you can try inserting Text.print statements in camlock to see what parts of the code run and what variables display what. The for loop in checkVolumes should have a zone that passes the position if statement.

MarioLover64
Spike
Spike
Posts: 259
Joined: Fri Apr 26, 2019 6:09 pm

Re: Need help with lua? - LunaLua General Help

Postby MarioLover64 » Wed Aug 26, 2020 9:14 am

1) I did

Code: Select all

--------------------------------------------------
-- World map code
-- Created 10:40 2020-8-25
--------------------------------------------------
2) it is the one included with Beta 4 patch 2 by default

baenyth
Koopa
Koopa
Posts: 16
Joined: Mon Sep 07, 2020 6:34 pm
Pronouns: she/her

Re: Need help with lua? - LunaLua General Help

Postby baenyth » Tue Sep 15, 2020 8:43 pm

Question: Is it possible to edit the score in lunalua? Add from it, subtract from it, etc. I looked on the wiki and found no variable or mem location for it.

ShadowXeldron
Snifit
Snifit
Posts: 232
Joined: Sun Dec 08, 2019 8:21 am
Flair: phpBB > ProBoards
Pronouns: He/Him
Contact:

Re: Need help with lua? - LunaLua General Help

Postby ShadowXeldron » Sat Sep 26, 2020 2:20 pm

I tried to load a font from this page, specificaly the Superstar Saga one and then I got an error.
Image

I am using this code to load it:

Code: Select all

textplus.loadFont("Fonts/superstarsaga-b.ini")
I also tried placing it in the root directory and ommiting the "Fonts/" and it still didn't load. What am I doing wrong?

Also, to solve Baemajinn's question while I'm at it:
Baemajinn wrote:
Tue Sep 15, 2020 8:43 pm
Question: Is it possible to edit the score in lunalua? Add from it, subtract from it, etc. I looked on the wiki and found no variable or mem location for it.
You can go here: https://docs.codehaus.moe/#/constants/score

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 » Sat Sep 26, 2020 2:54 pm

Dragon0307 wrote:
Sat Sep 26, 2020 2:20 pm
I tried to load a font from this page, specificaly the Superstar Saga one and then I got an error.
Image

I am using this code to load it:

Code: Select all

textplus.loadFont("Fonts/superstarsaga-b.ini")
I also tried placing it in the root directory and ommiting the "Fonts/" and it still didn't load. What am I doing wrong?

You need to use Misc.resolveFile on the path.
Dragon0307 wrote:
Sat Sep 26, 2020 2:20 pm
Also, to solve Baemajinn's question while I'm at it:
This is not an answer to that question. Those are just the constants for the score popup effect.

The real answer is to use Misc.score(newScore), as documented here: https://docs.codehaus.moe/#/reference/misc


Return to “LunaLua Help”

Who is online

Users browsing this forum: No registered users and 6 guests

SMWCentralTalkhausMario Fan Games GalaxyKafukaMarioWikiSMBXEquipoEstelari