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?
|
|
|
|
-
timocomsmbx2345
- Foo

- Posts: 853
- Joined: Sat Feb 06, 2016 1:44 pm
-
Contact:
Postby timocomsmbx2345 » Sat Jan 28, 2017 8:57 pm
Hoeloe wrote:The "corrupted" thing clearly comes from the download stopping early, meaning you only have half the file (hence the "unexpected end of file" error). Why it's doing that I'm not sure, but since you are the only person to have this issue, I'm pretty sure it's not the file that is the problem.
I'm having that issue too when i was downloading an episode. . . . .
|
|
|
|
|
|
|
|
|
-
DeMuZ
- Fighter Fly

- Posts: 37
- Joined: Thu Aug 18, 2016 2:35 pm
Postby DeMuZ » Sun Jan 29, 2017 9:43 am
Is there any way to respawn (only) killed npcs?
|
|
|
|
|
|
|
|
|
-
Phazon1111
- Buster Beetle

- Posts: 83
- Joined: Fri Dec 27, 2013 5:24 pm
Postby Phazon1111 » Mon Feb 06, 2017 7:00 pm
I'm trying to make it that when NPC 178 (The SMB1 axe) is collected, 30 seconds is added to the level's timer in similar fashion to the speed run levels from SMG2/SM3DL/SM3DW
via leveltimer.lua.
Code: Select all timerApi = loadAPI("leveltimer");
function onLoad()
--But now in the onLoad override, we set a few values
timerApi.setSecondsLeft(30);
--For one, we need to set the timer value. No greater than 999
timerApi.setTimerState(true);
--Then, we need to make sure we enable it. It's not enabled by default
end
function onNPCKill(eventObj,npcID,killReason)
if npcID == 178 then
getSecondsLeft()
timerApi.setSecondsLeft(timerApi.secondsleft + 10)
end
end
No error messages pop up upon starting the level or collect the axe.
|
|
|
|
|
|
|
|
|
-
Fuyu
- Fry Guy

- Posts: 3137
- Joined: Sat Dec 21, 2013 2:40 pm
- Pronouns: He/Him
Postby Fuyu » Mon Feb 06, 2017 10:41 pm
Is that all the code there is? There is no "getSecondsLeft" function anywhere in there. We also don't know what is it that you get. Does it not increase? Does the increased amount not match what you want (which judging by the code you posted seems to be the case, it's increasing 10 and not 30)?
|
|
|
|
|
|
|
|
|
-
Emral
- Cute Yoshi Egg

- Posts: 9890
- Joined: Mon Jan 20, 2014 12:58 pm
- Flair: Phoenix
Postby Emral » Tue Feb 07, 2017 12:47 am
Phazon1111 wrote:I'm trying to make it that when NPC 178 (The SMB1 axe) is collected, 30 seconds is added to the level's timer in similar fashion to the speed run levels from SMG2/SM3DL/SM3DW
via leveltimer.lua.
Code: Select all timerApi = loadAPI("leveltimer");
function onLoad()
--But now in the onLoad override, we set a few values
timerApi.setSecondsLeft(30);
--For one, we need to set the timer value. No greater than 999
timerApi.setTimerState(true);
--Then, we need to make sure we enable it. It's not enabled by default
end
function onNPCKill(eventObj,npcID,killReason)
if npcID == 178 then
getSecondsLeft()
timerApi.setSecondsLeft(timerApi.secondsleft + 10)
end
end
No error messages pop up upon starting the level or collect the axe.
Many things wrong:
-getSecondsLeft is a function from leveltimer so you have to prefix it with timerApi. like you did for the others
-npcID is a misnomer because the variable contains the killed npc. I prefer to call it killedNPC. You can cet the ID with killedNPC.id (or right now npcID.id which is silly)
-you should seriously use onStart in favour of onLoop. The latter has been deprecated for over a year.
-you sould make the timerApi variable local so only this file can access it.
-loadAPI has been deprecated for over a year and replaced with API.load. Use that.
|
|
|
|
|
|
|
|
|
-
Phazon1111
- Buster Beetle

- Posts: 83
- Joined: Fri Dec 27, 2013 5:24 pm
Postby Phazon1111 » Tue Feb 07, 2017 4:24 pm
Intuition wrote:Is that all the code there is? There is no "getSecondsLeft" function anywhere in there. We also don't know what is it that you get. Does it not increase? Does the increased amount not match what you want (which judging by the code you posted seems to be the case, it's increasing 10 and not 30)?
Oh, whoops. I meant to write 10 seconds on my post.
The problem is that it's not increasing.
Enjl wrote:Phazon1111 wrote:I'm trying to make it that when NPC 178 (The SMB1 axe) is collected, 30 seconds is added to the level's timer in similar fashion to the speed run levels from SMG2/SM3DL/SM3DW
via leveltimer.lua.
Code: Select all timerApi = loadAPI("leveltimer");
function onLoad()
--But now in the onLoad override, we set a few values
timerApi.setSecondsLeft(30);
--For one, we need to set the timer value. No greater than 999
timerApi.setTimerState(true);
--Then, we need to make sure we enable it. It's not enabled by default
end
function onNPCKill(eventObj,npcID,killReason)
if npcID == 178 then
getSecondsLeft()
timerApi.setSecondsLeft(timerApi.secondsleft + 10)
end
end
No error messages pop up upon starting the level or collect the axe.
Many things wrong:
-getSecondsLeft is a function from leveltimer so you have to prefix it with timerApi. like you did for the others
-npcID is a misnomer because the variable contains the killed npc. I prefer to call it killedNPC. You can cet the ID with killedNPC.id (or right now npcID.id which is silly)
-you should seriously use onStart in favour of onLoop. The latter has been deprecated for over a year.
-you sould make the timerApi variable local so only this file can access it.
-loadAPI has been deprecated for over a year and replaced with API.load. Use that.
When your sources are outdated.
Also, where do I put the "killedNPC.id" part?
|
|
|
|
|
|
|
|
|
-
Emral
- Cute Yoshi Egg

- Posts: 9890
- Joined: Mon Jan 20, 2014 12:58 pm
- Flair: Phoenix
Postby Emral » Tue Feb 07, 2017 4:28 pm
npcID should be killedNPC. killedNPC is an object of type NPC. You use killedNPC.id where you want to get the id of the killed npc.
|
|
|
|
|
|
|
|
|
-
Phazon1111
- Buster Beetle

- Posts: 83
- Joined: Fri Dec 27, 2013 5:24 pm
Postby Phazon1111 » Tue Feb 07, 2017 4:35 pm
OK, so now this happens when the axe is collected.

|
|
|
|
|
|
|
|
|
-
Emral
- Cute Yoshi Egg

- Posts: 9890
- Joined: Mon Jan 20, 2014 12:58 pm
- Flair: Phoenix
Postby Emral » Tue Feb 07, 2017 4:36 pm
timerApi.secondsLeft doesn't exist. Double-check the spelling in your code.
|
|
|
|
|
|
|
|
|
-
Phazon1111
- Buster Beetle

- Posts: 83
- Joined: Fri Dec 27, 2013 5:24 pm
Postby Phazon1111 » Tue Feb 07, 2017 6:53 pm
I think I might have found the problem.

I'm just not sure how to solve it.
|
|
|
|
|
|
|
|
|
-
PixelPest
- Link

- Posts: 7111
- Joined: Sun Jul 12, 2015 5:38 pm
- Flair: Tamer of Boom Booms
-
Contact:
Postby PixelPest » Tue Feb 07, 2017 7:03 pm
There's a function as a part of leveltimer.lua which returns that variable:
Code: Select all function lf_levelTimerApi.getSecondsLeft()
return secondsleft;
end
Also remember that onNPCKill() does not return the killed NPC's ID, but the object itself. (See the documentation.)
Therefore, you need to do something like:
Code: Select all function onNPCKill(_, killedNPC, _)
if killedNPC.id == 178 then
timerApi.setSecondsLeft(timerApi.getSecondsLeft() + 10);
end
end
|
|
|
|
|
|
|
|
|
-
Phazon1111
- Buster Beetle

- Posts: 83
- Joined: Fri Dec 27, 2013 5:24 pm
Postby Phazon1111 » Tue Feb 07, 2017 7:19 pm
Current Code:
Code: Select all local timerApi = API.load("leveltimer");
function onStart()
--But now in the onLoad override, we set a few values
timerApi.setSecondsLeft(30);
--For one, we need to set the timer value. No greater than 999
timerApi.setTimerState(true);
--Then, we need to make sure we enable it. It's not enabled by default
end
function onNPCKill(_, killedNPC, _)
if killedNPC.id == 178 then
timerApi.setSecondsLeft(timerApi.getSecondsLeft() + 10);
end
end
It's not crashing anymore, but it adds 10 seconds onto the starting time (30 seconds) rather than time the axe is collected.
|
|
|
|
|
|
|
|
|
-
Emral
- Cute Yoshi Egg

- Posts: 9890
- Joined: Mon Jan 20, 2014 12:58 pm
- Flair: Phoenix
Postby Emral » Tue Feb 07, 2017 7:22 pm
It appears that secondsLeft is never updated outside the setSecondsLeft function.
|
|
|
|
|
|
|
|
|
-
Angelus
- Tweeter

- Posts: 132
- Joined: Tue Jun 21, 2016 9:38 am
Postby Angelus » Fri Feb 10, 2017 4:25 pm
Does anyone know the exact jump height of Toad? If not, can someone tell me how to find it out?
|
|
|
|
|
|
|
|
|
-
PersonNamedUser
- Reznor

- Posts: 2882
- Joined: Fri Feb 27, 2015 8:07 pm
Postby PersonNamedUser » Tue Feb 14, 2017 1:08 am
How do i make a string of text with a lua code? I'm putting in this
code:
Code: Select all function onMessageBox(eventObj, msgStr)
if msgStr = "CutsceneTalk1" then
eventObj.cancelled == true
Text.showMessageBox("MosaicMario: Great job guys! We made it through the fortress!")
Text.showMessageBox("Rosy: I wonder why there were so many ninjis in there?")
end
end
function onMessageBox(eventObj, msgStr)
if msgStr = "CutsceneTalk2" then
eventObj.cancelled == true
Text.showMessageBox("Hoops: Hey guys, look at this bridge! Where could it lead?")
Text.showMessageBox("Berry: Yoshi!(I don't know, but i'm curious too!)")
Text.showMessageBox("MosaicMario: Hoops, I think that maybe you should slow dow-")
Text.showMessageBox("Hoops: Last one to the other side's a rotton mushroom!")
end
end
function onMessageBox(eventObj, msgStr)
if msgStr = "CutsceneTalk3" then
eventObj.cancelled == true
Text.showMessageBox("MosaicMario: Hoops! Wait up!")
end
end
function onMessageBox(eventObj, msgStr)
if msgStr = "CutsceneTalk4" then
eventObj.cancelled == true
Text.showMessageBox("Rosy:...Well, what do you say Berry? Should we catch up with them?")
Text.showMessageBox("Berry: Yoshi!(Yeah, sure!)")
Text.showMessageBox("Rosy: Let's go catch them i guess.")
end
end
But it won't work, what do i do about this?
While your at it, how do you set a boss's health?
|
|
|
|
|
|
|
|
|
-
Hoeloe
- Phanto

- Posts: 1465
- Joined: Sat Oct 03, 2015 6:18 pm
- Flair: The Codehaus Girl
- Pronouns: she/her
Postby Hoeloe » Tue Feb 14, 2017 2:39 am
MosaicMario wrote:
Code: Select all function onMessageBox(eventObj, msgStr)
if msgStr = "CutsceneTalk1" then
function onMessageBox(eventObj, msgStr)
if msgStr = "CutsceneTalk2" then
function onMessageBox(eventObj, msgStr)
if msgStr = "CutsceneTalk3" then
function onMessageBox(eventObj, msgStr)
if msgStr = "CutsceneTalk4" then
Quick question:
When you display a message box, how do you think the code determines which of these it has to run? It can't be that if statement, because that only occurs after it's already started to run the function.
Basically, you can't have multiple definitions of the same function. You should be using elseif statements rather than trying to redefine the function.
|
|
|
|
|
|
|
|
|
-
PersonNamedUser
- Reznor

- Posts: 2882
- Joined: Fri Feb 27, 2015 8:07 pm
Postby PersonNamedUser » Tue Feb 14, 2017 9:17 pm
Hoeloe wrote:MosaicMario wrote:
Code: Select all function onMessageBox(eventObj, msgStr)
if msgStr = "CutsceneTalk1" then
function onMessageBox(eventObj, msgStr)
if msgStr = "CutsceneTalk2" then
function onMessageBox(eventObj, msgStr)
if msgStr = "CutsceneTalk3" then
function onMessageBox(eventObj, msgStr)
if msgStr = "CutsceneTalk4" then
Quick question:
When you display a message box, how do you think the code determines which of these it has to run? It can't be that if statement, because that only occurs after it's already started to run the function.
Basically, you can't have multiple definitions of the same function. You should be using elseif statements rather than trying to redefine the function.
So something like this?:
Code: Select all function onMessageBox(eventObj, msgStr)
if msgStr == "CutsceneTalk1" then
eventObj.cancelled === true
Text.showMessageBox("MosaicMario: Great job guys! We made it through the fortress!")
Text.showMessageBox("Rosy: I wonder why there were so many ninjis in there?")
elseif msgStr == "CutsceneTalk2" then
eventObj.cancelled === true
Text.showMessageBox("Hoops: Hey guys, look at this bridge! Where could it lead?")
Text.showMessageBox("Berry: Yoshi!(I don't know, but i'm curious too!)")
Text.showMessageBox("MosaicMario: Hoops, I think that maybe you should slow dow-")
Text.showMessageBox("Hoops: Last one to the other side's a rotton mushroom!")
elseif msgStr == "CutsceneTalk3" then
eventObj.cancelled === true
Text.showMessageBox("MosaicMario: Hoops! Wait up!")
elseif msgStr == "CutsceneTalk4" then
eventObj.cancelled === true
Text.showMessageBox("Rosy:...Well, what do you say Berry? Should we catch up with them?")
Text.showMessageBox("Berry: Yoshi!(Yeah, sure!)")
Text.showMessageBox("Rosy: Let's go catch them i guess.")
end
end
I actually tried using this, but it still didn't work.
|
|
|
|
|
|
|
|
|
-
PixelPest
- Link

- Posts: 7111
- Joined: Sun Jul 12, 2015 5:38 pm
- Flair: Tamer of Boom Booms
-
Contact:
Postby PixelPest » Tue Feb 14, 2017 10:05 pm
What in the world is === ? I'm pretty sure you got what Hoeloe was trying to get you to do though
|
|
|
|
|
|
|
|
|
-
PersonNamedUser
- Reznor

- Posts: 2882
- Joined: Fri Feb 27, 2015 8:07 pm
Postby PersonNamedUser » Tue Feb 14, 2017 10:17 pm
i removed the extra =, but it still doesn't work, what am i doing wrong?
|
|
|
|
|
|
|
|
|
-
PixelPest
- Link

- Posts: 7111
- Joined: Sun Jul 12, 2015 5:38 pm
- Flair: Tamer of Boom Booms
-
Contact:
Postby PixelPest » Tue Feb 14, 2017 10:22 pm
Post your code here again
|
|
|
|
|
Return to “LunaLua”
Users browsing this forum: Ahrefs [Bot] and 8 guests
|