Post here for help and support regarding LunaLua and SMBX2's libraries and features.
Moderator: Userbase Moderators
|
|
|
|
-
Hoeloe
- Phanto

- Posts: 1465
- Joined: Sat Oct 03, 2015 6:18 pm
- Flair: The Codehaus Girl
- Pronouns: she/her
Postby Hoeloe » Mon Jun 20, 2022 4:33 pm
TRUE. I did make the docs after reading this post because I thought they might help, and forgot to link them once I was done haha.
|
|
|
|
|
|
|
|
|
-
deice
- Rocky Wrench

- Posts: 606
- Joined: Fri Jul 23, 2021 7:35 am
Postby deice » Mon Jun 20, 2022 5:33 pm
Hoeloe wrote:
I did make the docs after reading this post
damn, you guys should post questions here more often

(kidding of course, the docs are actually pretty good atm)
|
|
|
|
|
|
|
|
|
-
Daring Tombstone
- Blooper

- Posts: 160
- Joined: Mon Aug 28, 2017 10:57 pm
- Flair: What? Not 1000 posts? That means I suck right?
Postby Daring Tombstone » Sat Jul 02, 2022 8:48 pm
I haven't been here in a while but I'm looking for a way to stop Link from being able to bounce on spikes. Not great at lua but thought there must be a way better than mine which was putting collider boxes a touch above spikes to harm the player.
|
|
|
|
|
|
|
|
|
-
deice
- Rocky Wrench

- Posts: 606
- Joined: Fri Jul 23, 2021 7:35 am
Postby deice » Sun Jul 03, 2022 9:36 am
Daring Tombstone wrote: ↑Sat Jul 02, 2022 8:48 pm
I haven't been here in a while but I'm looking for a way to stop Link from being able to bounce on spikes. Not great at lua but thought there must be a way better than mine which was putting collider boxes a touch above spikes to harm the player.
technically you don't need any custom lua for that. there's already block 672 which is a solid hurt block that link cannot bounce off.
i guess a slightly cleaner solution if you absolutely need to use the vanilla spikes would be to make a custom block that mimics them? i don't know of a documented memory offset that lets you control link's down stab (and even if there was it would probably make you unable to down stab npcs as well, and i assume you don't want that)
|
|
|
|
|
|
|
|
|
-
Daring Tombstone
- Blooper

- Posts: 160
- Joined: Mon Aug 28, 2017 10:57 pm
- Flair: What? Not 1000 posts? That means I suck right?
Postby Daring Tombstone » Sun Jul 03, 2022 11:45 am
Never thought about using the hurt block. I could try that instead of some lua solution. Thanks.
|
|
|
|
|
|
|
|
|
-
LunarCatUSA
- Monty Mole

- Posts: 115
- Joined: Sat Mar 06, 2021 9:56 am
- Flair: Soda-Butler
Postby LunarCatUSA » Sat Jul 23, 2022 11:51 am
Any way I could make an NPC chase the player?
Just along the ground, not in the sky as if it were a parakoopa, I mean.
Added in 2 hours 19 minutes 5 seconds:
In this case, I have a JSON field for all NPCs:
Code: Select all {
"control": "checkbox",
"name": "chasesMe",
"title": "Chase Player?",
"tooltip": "Do you chase the player?",
"value-default": false
}
So now, the game is intended to override the NPCs current speed and direction with this:
Code: Select all function onStart()
Hostiles = NPC.get()
end
function onTick()
-- Chase Player --
for k,v in ipairs(Hostiles) do
if v.data._settings._global.chasesMe then
local cx = v.x + 0.5 * v.width
local p = player
local d = -vector(v.x - p.x + p.width):normalize() * 0.1
local speed = NPC.config[v.id].speed
v.speedX = v.speedX + d.x * NPC.config[v.id].speed
v.speedX = math.clamp(v.speedX, -4, 4)
end
end
end
|
|
|
|
|
|
|
|
|
-
LunarCatUSA
- Monty Mole

- Posts: 115
- Joined: Sat Mar 06, 2021 9:56 am
- Flair: Soda-Butler
Postby LunarCatUSA » Sun Jul 24, 2022 2:11 am
Okay, so I just updated it so that the NPC follows the player.
Code: Select all function onTick()
Hostiles = NPC.get()
-- Chase Player --
for k,v in ipairs(Hostiles) do
if v.data._settings._global.chasesMe then
Text.print(Distance, 70, 70)
Text.print(v.direction, 70, 90)
closeplayer = Player.getNearest(v.x,v.y)
Distance = closeplayer.x - v.x
if Distance < 0 then
v.direction = -1
end
if Distance >= 0 then
v.direction = 1
end
end
end
end
Problem is, they'll change direction initially, but if you go past them, they don't change direction. I'm not sure, but they seem to remain going in one direction regardless.
|
|
|
|
|
|
|
|
|
-
BrokenAce
- Bot

- Posts: 51
- Joined: Sat Feb 06, 2016 11:48 am
Postby BrokenAce » Tue Aug 09, 2022 7:09 am
I'm having two problems setting up my custom HUD.
1. I can't remove the weird 2-pixel spacing between numbers
2. For some reason, the coin counter uses vanilla graphics for its numbers despite the fact I have replaced the hardcoded number graphics with SMB3 style ones in my episode folder
Basically, right now it looks like this:

but I want it to look like this:
Hoping this won't be too difficult to fix.
|
|
|
|
|
|
|
|
|
-
Marioman2007
- 2025 Egg Hunter

- Posts: 543
- Joined: Tue Aug 25, 2020 3:19 am
- Flair: Dr. Bones
- Pronouns: He/Him
Postby Marioman2007 » Tue Aug 09, 2022 8:03 am
BrokenAce wrote: ↑Tue Aug 09, 2022 7:09 am
2. For some reason, the coin counter uses vanilla graphics for its numbers despite the fact I have replaced the hardcoded number graphics with SMB3 style ones in my episode folder
Create folder called "textplus" and then another folder inside it "font"
then copy 1.png from "SMBX2 > data > scripts > textplus > font" and then you can edit it
|
|
|
|
|
|
|
|
|
-
BrokenAce
- Bot

- Posts: 51
- Joined: Sat Feb 06, 2016 11:48 am
Postby BrokenAce » Tue Aug 09, 2022 11:32 am
Marioman2007 wrote: ↑Tue Aug 09, 2022 8:03 am
BrokenAce wrote: ↑Tue Aug 09, 2022 7:09 am
2. For some reason, the coin counter uses vanilla graphics for its numbers despite the fact I have replaced the hardcoded number graphics with SMB3 style ones in my episode folder
Create folder called "textplus" and then another folder inside it "font"
then copy 1.png from "SMBX2 > data > scripts > textplus > font" and then you can edit it
Thanks, this does the trick perfectly for the coins. Now, if only I could also remove the spacing in the lives/stars counters or replace those with textplus font1 as well. Afaik, there is nothing in huboberride.lua that determines which counters are displayed as textplus, so this is probably not going to be easy to solve.
|
|
|
|
|
|
|
|
|
-
LunarCatUSA
- Monty Mole

- Posts: 115
- Joined: Sat Mar 06, 2021 9:56 am
- Flair: Soda-Butler
Postby LunarCatUSA » Fri Aug 19, 2022 11:42 pm
I'm trying to make a layer disappear but it's not working.
Code: Select all for k,w in ipairs(Layer.get("WallsafeLock")) do
w:hide(false)
end
What am I doing wrong? The event that would normally hide the layer occurs just fine so something's wrong with the layer visibility command I guess.
|
|
|
|
|
|
|
|
|
-
Emral
- Cute Yoshi Egg

- Posts: 9886
- Joined: Mon Jan 20, 2014 12:58 pm
- Flair: Phoenix
Postby Emral » Sat Aug 20, 2022 12:01 am
https://docs.codehaus.moe/#/reference/layer
Layer.get(name) returns the layer with that name, not a list of layers. Store it into a local variable and call :hide() on that local variable. No need for a for loop.
|
|
|
|
|
|
|
|
|
-
BrokenAce
- Bot

- Posts: 51
- Joined: Sat Feb 06, 2016 11:48 am
Postby BrokenAce » Sat Aug 20, 2022 6:28 am
A quick question - is it possible to modify the game's slippery/ice physics? I'd like to change the acceleration/deceleration properties of slippery blocks to better fit Enjl's playerphysicspatch.lua, if possible.
|
|
|
|
|
|
|
|
|
-
LunarCatUSA
- Monty Mole

- Posts: 115
- Joined: Sat Mar 06, 2021 9:56 am
- Flair: Soda-Butler
Postby LunarCatUSA » Sun Aug 21, 2022 10:30 pm
Question,
Is there a way to call a random variable everytime a new episode is started?
This is to give a certain item a randomized location and give the game some replay value.
Like this,
Upon starting a game in the episode, var will randomly equal 1, 2, or 3.
if var = 1:
Item goes to level 1 as opposed to level 2 or level 3
if var = 2:
item goes to level 2 as opposed to level 1 or level 3
if var = 3:
item goes to level 3 as opposed to level 1 or level 2
|
|
|
|
|
|
|
|
|
-
Marioman2007
- 2025 Egg Hunter

- Posts: 543
- Joined: Tue Aug 25, 2020 3:19 am
- Flair: Dr. Bones
- Pronouns: He/Him
Postby Marioman2007 » Mon Aug 22, 2022 1:07 am
LunarCatUSA wrote: ↑Sun Aug 21, 2022 10:30 pm
Question,
Is there a way to call a random variable everytime a new episode is started?
This is to give a certain item a randomized location and give the game some replay value.
Like this,
Upon starting a game in the episode, var will randomly equal 1, 2, or 3.
if var = 1:
Item goes to level 1 as opposed to level 2 or level 3
if var = 2:
item goes to level 2 as opposed to level 1 or level 3
if var = 3:
item goes to level 3 as opposed to level 1 or level 2
https://docs.codehaus.moe/#/reference/rng
|
|
|
|
|
|
|
|
|
-
LunarCatUSA
- Monty Mole

- Posts: 115
- Joined: Sat Mar 06, 2021 9:56 am
- Flair: Soda-Butler
Postby LunarCatUSA » Mon Aug 22, 2022 9:43 am
Oh, I know how to use a random variable, calling it when the episode first starts is the thing, like maybe when the overworld loads for the first time and then done.
Although, I guess I can also load a random global variable to save on the intro level. Maybe that'll be easier.
|
|
|
|
|
|
|
|
|
-
deice
- Rocky Wrench

- Posts: 606
- Joined: Fri Jul 23, 2021 7:35 am
Postby deice » Mon Aug 22, 2022 12:30 pm
LunarCatUSA wrote: ↑Mon Aug 22, 2022 9:43 am
Oh, I know how to use a random variable, calling it when the episode first starts is the thing, like maybe when the overworld loads for the first time and then done.
Although, I guess I can also load a random global variable to save on the intro level. Maybe that'll be easier.
if you do use an overworld, putting this in your map.lua should do the trick:
Code: Select all function onStart()
if(SaveData.randomGlobalVar == nil) then
SaveData.randomGlobalVar = RNG.randomInt(1, 3)
end
end
then, you can spawn items accordingly by checking in each level's luna.lua:
Code: Select all function onStart()
local seekValue = 1 -- value corresponding to this level
if(SaveData.randomGlobalVar == seekValue) then
-- do stuff here
end
end
|
|
|
|
|
|
|
|
|
-
LunarCatUSA
- Monty Mole

- Posts: 115
- Joined: Sat Mar 06, 2021 9:56 am
- Flair: Soda-Butler
Postby LunarCatUSA » Tue Aug 23, 2022 1:10 pm
Is there a way to trigger an event upon warping through a specific door?
Or at least manually trigger a warp upon an event occurring?
|
|
|
|
|
|
|
|
|
-
LunarCatUSA
- Monty Mole

- Posts: 115
- Joined: Sat Mar 06, 2021 9:56 am
- Flair: Soda-Butler
Postby LunarCatUSA » Wed Aug 24, 2022 4:35 pm
Okay, here's another question.
I put various image files into another folder within my episode folder to make a less crowded library. The thing is,
Item = Graphics.loadImage(Misc.resolveFile("MyItem.png")) returns an error message. Isn't the resolve supposed to load this folder on its own?
Is there something I should add the Graphics.loadImage command?
|
|
|
|
|
|
|
|
|
-
deice
- Rocky Wrench

- Posts: 606
- Joined: Fri Jul 23, 2021 7:35 am
Postby deice » Wed Aug 24, 2022 4:43 pm
LunarCatUSA wrote: ↑Wed Aug 24, 2022 4:35 pm
Okay, here's another question.
I put various image files into another folder within my episode folder to make a less crowded library. The thing is,
Item = Graphics.loadImage(Misc.resolveFile("MyItem.png")) returns an error message. Isn't the resolve supposed to load this folder on its own?
Is there something I should add the Graphics.loadImage command?
it's always best to read the fine print. resolveFile won't look absolutely everywhere, and has a strictly defined search pattern. if the file is in an arbitrary folder, you have to also include the folder name:
Code: Select all Graphics.loadImage(Misc.resolveFile("Folder/MyItem.png"))
however, if the lua file itself is right in your episode folder too (as opposed to a level's custom folder), the resolveFile() call is superfluous and can be removed:
Code: Select all Graphics.loadImage("Folder/MyItem.png")
|
|
|
|
|
Return to “LunaLua Help”
Users browsing this forum: Petal [Bot] and 0 guests
|