Page 17 of 32
Re: Need help with lua? - LunaLua General Help
Posted: Tue Mar 02, 2021 8:49 am
by MrDoubleA
Goldenemerl64 wrote: ↑Tue Mar 02, 2021 6:59 am
I'm having problems with Activating auto-scroll on a Collectable Trigger.
Code: Select all
local autoscroll = require("autoscroll")
function onEvent(Fast)
if eventName == "Fast" then
autoscroll.scrollRight(3.0)
elseif eventName == "Fast" then
autoscroll.scrollRight(3.0)
end
end
am I doing it correctly?
onEvent does not work like that. "eventName" at the top doesn't mean "replace this", you're supposed to keep it as eventName.
Re: Need help with lua? - LunaLua General Help
Posted: Tue Mar 02, 2021 9:50 am
by Lucario
General help, right? Well, what can I do to code a Piranha Creeper. I mean, I'll have to do stalk's AI and Piranha Creeper's AI, and I don't know how to make an AI!
Re: Need help with lua? - LunaLua General Help
Posted: Tue Mar 02, 2021 12:41 pm
by MrDoubleA
Lucario wrote: ↑Tue Mar 02, 2021 9:50 am
General help, right? Well, what can I do to code a Piranha Creeper. I mean, I'll have to do stalk's AI and Piranha Creeper's AI, and I don't know how to make an AI!
I'm working on one, but this is REALLY not something you should start into as a beginner.
Re: Need help with lua? - LunaLua General Help
Posted: Tue Mar 02, 2021 9:57 pm
by Goldenemerl64
MrDoubleA wrote: ↑Tue Mar 02, 2021 8:49 am
Goldenemerl64 wrote: ↑Tue Mar 02, 2021 6:59 am
I'm having problems with Activating auto-scroll on a Collectable Trigger.
Code: Select all
local autoscroll = require("autoscroll")
function onEvent(Fast)
if eventName == "Fast" then
autoscroll.scrollRight(3.0)
elseif eventName == "Fast" then
autoscroll.scrollRight(3.0)
end
end
am I doing it correctly?
onEvent does not work like that. "eventName" at the top doesn't mean "replace this", you're supposed to keep it as eventName.
ooooh, Ok then. Thanks!
Re: Need help with lua? - LunaLua General Help
Posted: Sat Mar 06, 2021 8:04 am
by BlueStaggo
I would like to be big every time I either play my episode for the first time or die, just like in Super Mario 3D World. Anybody know how to do that? I've been using a variable with SaveData to keep track of whether the player has died or not. I want this to be an episode-wide feature.
Re: Need help with lua? - LunaLua General Help
Posted: Sat Mar 06, 2021 2:01 pm
by LunarCatUSA
Hello there, I would like to be able to script a quiz game. For this game, there are 4 blocks. One block has the right answer, and three blocks give the wrong answer. Here’s how it would work:
- Make a variable that’s the player score and set it to 0 initially.
- Make a variable that’s the player’s miss score and set it to 0 initially.
- Make the boxes increment to these scores depending on right or wrong. (Should this be done via “hit” and event?)
- How to display a message via script. (In this case, the question)
- 10 questions and it would help if I could know how to randomize their order.
- If the player gets a right answer, it adds 1 to score.
- If the player gets a wrong answer, it adds 1 to miss score.
- If the player has more points than miss points, they win.
- If the player has less than or equal points to miss points, they die instantly.
I’m very new to Lua so it would help if you all could give tips and some understanding to this variable and message display system and how it all connects to what’s in game.
Re: Need help with lua? - LunaLua General Help
Posted: Sat Mar 06, 2021 3:00 pm
by MrDoubleA
BlueStag wrote: ↑Sat Mar 06, 2021 8:04 am
I would like to be big every time I either play my episode for the first time or die, just like in Super Mario 3D World. Anybody know how to do that? I've been using a variable with SaveData to keep track of whether the player has died or not. I want this to be an episode-wide feature.
Code: Select all
SaveData.startedEpisode = SaveData.startedEpisode or false
function onStart()
if not SaveData.startedEpisode then
for _,p in ipairs(Player.get()) do
p.powerup = PLAYER_BIG
end
SaveData.startedEpisode = true
end
end
function onExitLevel(exitType)
if exitType == 0 then
-- Is everybody dead?
local allDead = true
for _,p in ipairs(Player.get()) do
if not p:mem(0x13C,FIELD_BOOL) then -- not dead
allDead = false
break
end
end
if allDead then
-- Make everybody big
for _,p in ipairs(Player.get()) do
p.powerup = PLAYER_BIG
end
end
end
end
Here (should be multiplayer compatible).
Re: Need help with lua? - LunaLua General Help
Posted: Wed Mar 10, 2021 7:58 am
by LunarCatUSA
So let’s say the player’s controls are dropped in-game. I wanted for them to press some button on their keyboard to trigger something. Is there a Lua command or code for that?
Re: Need help with lua? - LunaLua General Help
Posted: Thu Mar 11, 2021 2:25 pm
by LunarCatUSA
Okay quick question:
My program seems to think there’s an index present I deleted from the code sometime ago. I guess there’s some index present in the cache unused. How would I delete it? Or clear the code cache entirely?
Re: Need help with lua? - LunaLua General Help
Posted: Thu Mar 11, 2021 2:26 pm
by Emral
There's no such a thing as a "code cache"
Re: Need help with lua? - LunaLua General Help
Posted: Thu Mar 11, 2021 2:28 pm
by LunarCatUSA
Well it seems to think the index I got rid of is still there so I don’t know. I didn’t know if it had a cache present like MatLab.
Added in 14 minutes 20 seconds:
Oh nevermind, I just had to make a clear table. Nothing wrong with memory.
Re: Need help with lua? - LunaLua General Help
Posted: Sat Mar 13, 2021 4:32 pm
by LunarCatUSA
If I wanted an npc to be killed a certain way that would trigger an event, how would I got about it? Like say I wanted an npc to be killed by spin jumping to avoid triggering an event, is there a certain way to define a death from spin-jumping verses a normal death by stomping?
Re: Need help with lua? - LunaLua General Help
Posted: Thu Mar 25, 2021 3:15 pm
by timocomsmbx2345
I was attempting to make a custom npc for a long while now, where it was like, npc-147, but with more varied veggies. I have already made my own custom veggie without replacing an existing one, but I don't know how to make a new npc-147-like npc for it.
Added in 4 hours 51 minutes 23 seconds:
timocomsmbx2345 wrote: ↑Thu Mar 25, 2021 3:15 pm
I was attempting to make a custom npc for a long while now, where it was like, npc-147, but with more varied veggies. I have already made my own custom veggie without replacing an existing one, but I don't know how to make a new npc-147-like npc for it.
Ok but seriously, I have wasted 12 hours trying to know what I did wrong, and all I've been getting was an error about ")"
Re: Need help with lua? - LunaLua General Help
Posted: Sat Mar 27, 2021 8:38 am
by Emral
timocomsmbx2345 wrote: ↑Thu Mar 25, 2021 8:06 pm
Ok but seriously, I have wasted 12 hours trying to know what I did wrong, and all I've been getting was an error about ")"
This indicates a syntax error. Programming applications such as vscode or notepad++ should highlight them for you.
Re: Need help with lua? - LunaLua General Help
Posted: Sat Mar 27, 2021 10:11 am
by timocomsmbx2345
Enjl wrote: ↑Sat Mar 27, 2021 8:38 am
timocomsmbx2345 wrote: ↑Thu Mar 25, 2021 8:06 pm
Ok but seriously, I have wasted 12 hours trying to know what I did wrong, and all I've been getting was an error about ")"
This indicates a syntax error. Programming applications such as vscode or notepad++ should highlight them for you.
I didn't even realize there was a highlight feature, plus I never knew how to turn that on in notepad++.
Re: Need help with lua? - LunaLua General Help
Posted: Sat Mar 27, 2021 12:03 pm
by Emral
timocomsmbx2345 wrote: ↑Sat Mar 27, 2021 10:11 am
Enjl wrote: ↑Sat Mar 27, 2021 8:38 am
timocomsmbx2345 wrote: ↑Thu Mar 25, 2021 8:06 pm
Ok but seriously, I have wasted 12 hours trying to know what I did wrong, and all I've been getting was an error about ")"
This indicates a syntax error. Programming applications such as vscode or notepad++ should highlight them for you.
I didn't even realize there was a highlight feature, plus I never knew how to turn that on in notepad++.
It should just do it for lua files automatically. If not, you can
use the "Language" dropdown and select "Lua".
Re: Need help with lua? - LunaLua General Help
Posted: Sun Mar 28, 2021 1:42 pm
by LunarCatUSA
Anyway I can alter the graphical pixel size of the small/1 heart Mario? I’m trying to make a horror-themed episode and instead of shrinking, the character will retain the size, yet looked tired and depressed on their lowest health level. Any script I should look for? Or a txt file I should make?
Re: Need help with lua? - LunaLua General Help
Posted: Wed Apr 14, 2021 1:35 am
by Murphmario
Is there a tutorial for using NPCUtils getTotalFramesByFramestyle anywhere? I feel like that'd help me out a lot.
Re: Need help with lua? - LunaLua General Help
Posted: Wed Apr 14, 2021 2:49 am
by MrDoubleA
Murphmario wrote: ↑Wed Apr 14, 2021 1:35 am
Is there a tutorial for using NPCUtils getTotalFramesByFramestyle anywhere? I feel like that'd help me out a lot.
You just do npcutils.getToyalFramesByFramestyle(v), and it gives you the total frames. I don't think am entire tutorial is necessary lol
Re: Need help with lua? - LunaLua General Help
Posted: Fri Apr 23, 2021 10:11 am
by TheGameyFireBro105
Can I use Lua code to have auto scroll outside the main area? I'm going for the basic SMB3 Normal scroll speed, like that seen in the 1st airship and the tanks. I have no knowledge of lua, aside from how to make a level use the code.