(shouting)

LunaDLL/LunaLUA help thread

The second SMBX collab!
User avatar
Karatekid5
Welcome to the resort!
Posts: 78
Joined: 14 years ago
Location: Pennsylvania
Contact:

Re: LunaDLL/LunaLUA help thread

Post by Karatekid5 »

I just tried that but I got the same error.
Yoshi Ambassador!
Image
User avatar
Kevsoft
LunaLua Master Developer
Posts: 83
Joined: 9 years ago

Re: LunaDLL/LunaLUA help thread

Post by Kevsoft »

The error says that the function does not exists. Either you have typo or a too old version of cinematX.
User avatar
Karatekid5
Welcome to the resort!
Posts: 78
Joined: 14 years ago
Location: Pennsylvania
Contact:

Re: LunaDLL/LunaLUA help thread

Post by Karatekid5 »

I update my copy of LunaLUA whenever an update is released, but I redownloaded/installed the most recent version just in case. I tried it out and still got the same error.

For reference, here's the current code:

Code: Select all

cinematX = loadSharedAPI("cinematX")

cinematX.configExt ({hudBox=false, overrideNpcText=true, imageUi=false, textbloxSub=true})

function scene_1 ()
    cinematX.startDialogExt (bellossom1, Bellossom, "Hello there! Welcome to the Starlight Resort!")
  cinematX.waitForDialog()
end
Yoshi Ambassador!
Image
Rixithechao
https://www.youtube.com/watch?v=BODxOghVmko
Posts: 1811
Joined: 10 years ago
First name: Mack
https://rixithechao.talkhaus.com/

Re: LunaDLL/LunaLUA help thread

Post by Rixithechao »

Are you using the latest version of cinematX from the github repo (0.0.8l5) or the latest stable/devkit version (0.0.7)?
0.0.7 didn't have configExt () along with a ton of other features I've been adding to simplify things.
Delightful Adventure Enhanced is out now!

Image

There's an official ASMT Discord server! Check it out to discuss Demo games and follow their development! thread, invite link

(Entry requires verification, either with a connected Youtube/Twitter/Twitch/etc account or manually by the server staff.)


Itch.io (albums and eventually games), Youtube (dofur pass and I guess other videos)
User avatar
Karatekid5
Welcome to the resort!
Posts: 78
Joined: 14 years ago
Location: Pennsylvania
Contact:

Re: LunaDLL/LunaLUA help thread

Post by Karatekid5 »

Ah, that must be the problem! I have the latest devkit version but not the github repo version. Where can I download that version of CinematX?

EDIT: I found the Github link and installed that version, so the error disappeared!

Though, I've run into some new problems. When trying to play my level I got this odd error that mentions the Multipoints LUA file. After this error, my level's LUA won't run either.

EDIT 2: Actually, it seems like this problem isn't specific to my level, as I get this error when I try to load any level using LUA but not using multipoints.
Attachments
multipoints.png
multipoints.png (13.57 KiB) Viewed 7398 times
Yoshi Ambassador!
Image
User avatar
7NameSam
hey
Posts: 248
Joined: 9 years ago
Pronouns: they/them

Re: LunaDLL/LunaLUA help thread

Post by 7NameSam »

How do you use a PNG? I want to use one to make the screen darker in a section.
User avatar
Hoeloe
A2XT person
Posts: 1016
Joined: 12 years ago
Pronouns: she/her
Location: Spaaace

Re: LunaDLL/LunaLUA help thread

Post by Hoeloe »

Karatekid5 wrote: EDIT 2: Actually, it seems like this problem isn't specific to my level, as I get this error when I try to load any level using LUA but not using multipoints.
I think I may know what the problem is.

Could you find your multipoints.lua file in the LuaScriptsLib folder and check the version number? If it's not 3.0.11, then you'll need to download the newest version from the wiki.
Image
Image
Image
Image
Image
User avatar
Karatekid5
Welcome to the resort!
Posts: 78
Joined: 14 years ago
Location: Pennsylvania
Contact:

Re: LunaDLL/LunaLUA help thread

Post by Karatekid5 »

Hoeloe wrote:I think I may know what the problem is.

Could you find your multipoints.lua file in the LuaScriptsLib folder and check the version number? If it's not 3.0.11, then you'll need to download the newest version from the wiki.
There we go, that fixed it! ^_^ (I had version 3.0.6)

So, going back to CinematX, the NPC gives me the "press up to talk" message at the bottom of the screen when touching them, but pressing up does nothing.

The code is in an earlier post, and here are the NPC tags:

Code: Select all

{key=bellossom1, name=Bellossom, routine=function_scene1}
Yoshi Ambassador!
Image
User avatar
Holy
Posts: 133
Joined: 12 years ago

Re: LunaDLL/LunaLUA help thread

Post by Holy »

So I'm trying to save a number to the local data, and then I want to get that number back next time and add it to another number. But Mr. Lua keeps telling me I'm trying to add a string, and I've tried a buncha stuff but none of it seems to work. HELP MEEEEEE

edit: yeah no matter how many ways I shove it in tonumber() don't work none.
User avatar
Wohlstand
Moondust and TheXTech developer
Posts: 186
Joined: 10 years ago
First name: Vitaly
Pronouns: he/him/his
Location: Moscow, Russia

Re: LunaDLL/LunaLUA help thread

Post by Wohlstand »

7NameSam wrote:How do you use a PNG? I want to use one to make the screen darker in a section.
For this case you don't need for PNG BGO's, you can apply fader library and set black screen with half alpha-channel. However you still can make some foreground BGO with semitransparency and save it into PNG format (LunaLUA-SMBX supports mask-less true-transparency PNG images)
User avatar
Kevsoft
LunaLua Master Developer
Posts: 83
Joined: 9 years ago

Re: LunaDLL/LunaLUA help thread

Post by Kevsoft »

Holy wrote:So I'm trying to save a number to the local data, and then I want to get that number back next time and add it to another number. But Mr. Lua keeps telling me I'm trying to add a string, and I've tried a buncha stuff but none of it seems to work. HELP MEEEEEE

edit: yeah no matter how many ways I shove it in tonumber() don't work none.
Could you paste the code, which throws the error?
User avatar
gameguy888
Man, I dunno.
Posts: 28
Joined: 9 years ago

Re: LunaDLL/LunaLUA help thread

Post by gameguy888 »

Is there a way to trigger some code every time the player collects a powerup (even if they're already fully powered and it would thus "do nothing")?
Words go here sometimes.
User avatar
Duker
I post u2be tags I guess
Posts: 272
Joined: 13 years ago
Location: The Comment Section

Re: LunaDLL/LunaLUA help thread

Post by Duker »

gameguy888 wrote:Is there a way to trigger some code every time the player collects a powerup (even if they're already fully powered and it would thus "do nothing")?
You could probably use onNPCKill for that, I'll try it out once I get home from work.

Right-o, I probably overcomplicated it but it seems to work at least:

Code: Select all

local Cam
function onLoad()
	Cam = Camera.get()[1]
end

function onNPCKill(eventObj, killedNPC, killReason)
	--killreason 9 = "Despawn or NPC eaten (ie powerups) = Vanish"
	if (killReason == 9) then
		--Check if the NPC is on screen, otherwise it must have despawned
		if(killedNPC.x > Cam.x 
			and killedNPC.x < Cam.x+Cam.width 
			and killedNPC.y > Cam.y 
			and killedNPC.y < Cam.y+Cam.height) 
		then 
			--[[Code to run here]]
		end
	end
end
You might want to check the ID of the killedNPC too as 1-ups also "die" the same way as actual power-ups.
fart.
User avatar
Rednaxela
Maker of Shenanigans
Posts: 897
Joined: 10 years ago
Pronouns: they/them
https://rednaxela.talkhaus.com

Re: LunaDLL/LunaLUA help thread

Post by Rednaxela »

Duker wrote:
gameguy888 wrote:Is there a way to trigger some code every time the player collects a powerup (even if they're already fully powered and it would thus "do nothing")?
You could probably use onNPCKill for that, I'll try it out once I get home from work.

Right-o, I probably overcomplicated it but it seems to work at least:

Code: Select all

local Cam
function onLoad()
	Cam = Camera.get()[1]
end

function onNPCKill(eventObj, killedNPC, killReason)
	--killreason 9 = "Despawn or NPC eaten (ie powerups) = Vanish"
	if (killReason == 9) then
		--Check if the NPC is on screen, otherwise it must have despawned
		if(killedNPC.x > Cam.x 
			and killedNPC.x < Cam.x+Cam.width 
			and killedNPC.y > Cam.y 
			and killedNPC.y < Cam.y+Cam.height) 
		then 
			--[[Code to run here]]
		end
	end
end
You might want to check the ID of the killedNPC too as 1-ups also "die" the same way as actual power-ups.[/spoiler]
Less complicated and would probably work would be:

Code: Select all

function onNPCKill(eventObj, killedNPC, killReason)
   --killreason 9 = "Despawn or NPC eaten (ie powerups) = Vanish"
   if (killReason == 9) then
      --Check if the NPC is on screen, otherwise it must have despawned
      if killedNPC:mem(0x12A, FIELD_WORD) > 0 then
         --[[Code to run here]]
      end
   end
end
Don't need to be checking it's location, and that code you have to check that is slightly incorrect anyway due to the effect of height/width. Besides, at offset 0x12A there's a despawn countdown. Just check that hasn't triggered.

As a note, onNPCKill only works with very new versions of LunaLua.
User avatar
Duker
I post u2be tags I guess
Posts: 272
Joined: 13 years ago
Location: The Comment Section

Re: LunaDLL/LunaLUA help thread

Post by Duker »

Rednaxela wrote:
Duker wrote:
gameguy888 wrote:Is there a way to trigger some code every time the player collects a powerup (even if they're already fully powered and it would thus "do nothing")?
You could probably use onNPCKill for that, I'll try it out once I get home from work.

Right-o, I probably overcomplicated it but it seems to work at least:

Code: Select all

local Cam
function onLoad()
	Cam = Camera.get()[1]
end

function onNPCKill(eventObj, killedNPC, killReason)
	--killreason 9 = "Despawn or NPC eaten (ie powerups) = Vanish"
	if (killReason == 9) then
		--Check if the NPC is on screen, otherwise it must have despawned
		if(killedNPC.x > Cam.x 
			and killedNPC.x < Cam.x+Cam.width 
			and killedNPC.y > Cam.y 
			and killedNPC.y < Cam.y+Cam.height) 
		then 
			--[[Code to run here]]
		end
	end
end
You might want to check the ID of the killedNPC too as 1-ups also "die" the same way as actual power-ups.[/spoiler]
Less complicated and would probably work would be:

Code: Select all

function onNPCKill(eventObj, killedNPC, killReason)
   --killreason 9 = "Despawn or NPC eaten (ie powerups) = Vanish"
   if (killReason == 9) then
      --Check if the NPC is on screen, otherwise it must have despawned
      if killedNPC:mem(0x12A, FIELD_WORD) > 0 then
         --[[Code to run here]]
      end
   end
end
Don't need to be checking it's location, and that code you have to check that is slightly incorrect anyway due to the effect of height/width. Besides, at offset 0x12A there's a despawn countdown. Just check that hasn't triggered.

As a note, onNPCKill only works with very new versions of LunaLua.
It's new enough in the current devkit, though I did download it decently recently so worth checking yeah.

Anyway, that is absolutely better (forgot to check mem offsets for relevant stuff) but for whatever reason enemies falling out of the level (but not powerups) gets through that check. Easily solved with an ID check though so it's still the better solution.

Curious though, what part of it is incorrect? What exactly do you mean with "the effect of height/width"? Just trying to learn from my mistakes.
Last edited by Duker 8 years ago, edited 1 time in total.
fart.
User avatar
Holy
Posts: 133
Joined: 12 years ago

Re: LunaDLL/LunaLUA help thread

Post by Holy »

Kevsoft wrote:
Holy wrote:So I'm trying to save a number to the local data, and then I want to get that number back next time and add it to another number. But Mr. Lua keeps telling me I'm trying to add a string, and I've tried a buncha stuff but none of it seems to work. HELP MEEEEEE

edit: yeah no matter how many ways I shove it in tonumber() don't work none.
Could you paste the code, which throws the error?
Here's the relevant parts, I think

Code: Select all

local myLevelData = Data(Data.DATA_LEVEL, "myData")
coinCounted = 0
coinCounted2 = 0
coinAdd = 0

function onEvent(eventname)
	if eventname == "logFirst" then
		myLevelData:set("coyn",tostring(coinCount))
		myLevelData:save()
	end
end

function onLoadSection3()
	coinCounted = myLevelData:get("coyn");
end

function onLoopSection3()
	coinAdd = coinCounted2 + tonumber(coinCounted)
	Text.print(coinAdd,200,360)
end
User avatar
Kevsoft
LunaLua Master Developer
Posts: 83
Joined: 9 years ago

Re: LunaDLL/LunaLUA help thread

Post by Kevsoft »

Could you also copy the error or make a screenshot of it? Currently this code seems to be right, so the error message and especially the line number, where the error happend is important.
User avatar
Hoeloe
A2XT person
Posts: 1016
Joined: 12 years ago
Pronouns: she/her
Location: Spaaace

Re: LunaDLL/LunaLUA help thread

Post by Hoeloe »

Holy wrote:

Code: Select all

tostring(coinCount)
Is that supposed to be countCounted? Because if it is, that would mean you're storing "nil" in the data class, and it's failing when trying to convert it back to a number.
Image
Image
Image
Image
Image
User avatar
Holy
Posts: 133
Joined: 12 years ago

Re: LunaDLL/LunaLUA help thread

Post by Holy »

coinCount's a diff variable, from another part of the code. Anyway, it works now for some reason!! I think all my manual messing with the savefile was screwing with it or something.
User avatar
Karatekid5
Welcome to the resort!
Posts: 78
Joined: 14 years ago
Location: Pennsylvania
Contact:

Re: LunaDLL/LunaLUA help thread

Post by Karatekid5 »

An update on the CinematX issue I was having earlier, I tried a few things with the NPC's tags, and seems like the key was changing the NPC's routine tag to "routine=function scene_1". Now, when I press up to talk to the NPC, it seems to be running some code now, but instead of the intended message I just get this error. My LunaLUA is the most recent version and my version of CinematX is the most recent Github version.
Attachments
cinematxerror.png
cinematxerror.png (13.87 KiB) Viewed 7240 times
Yoshi Ambassador!
Image
Rixithechao
https://www.youtube.com/watch?v=BODxOghVmko
Posts: 1811
Joined: 10 years ago
First name: Mack
https://rixithechao.talkhaus.com/

Re: LunaDLL/LunaLUA help thread

Post by Rixithechao »

It should be just the name of the function, so routine=scene_1, though if you want it to play as a cutscene, I suggest using scene=scene_1 instead.
Delightful Adventure Enhanced is out now!

Image

There's an official ASMT Discord server! Check it out to discuss Demo games and follow their development! thread, invite link

(Entry requires verification, either with a connected Youtube/Twitter/Twitch/etc account or manually by the server staff.)


Itch.io (albums and eventually games), Youtube (dofur pass and I guess other videos)
User avatar
7NameSam
hey
Posts: 248
Joined: 9 years ago
Pronouns: they/them

Re: LunaDLL/LunaLUA help thread

Post by 7NameSam »

Wohlstand wrote:
7NameSam wrote:How do you use a PNG? I want to use one to make the screen darker in a section.
For this case you don't need for PNG BGO's, you can apply fader library and set black screen with half alpha-channel. However you still can make some foreground BGO with semitransparency and save it into PNG format (LunaLUA-SMBX supports mask-less true-transparency PNG images)
I'm sorry, but I'm unfamiliar with Fader Libraries, and google doesn't give me any good results.
User avatar
FrozenQuills
hehe haha 2024
Posts: 843
Joined: 9 years ago
Location: my skull

Re: LunaDLL/LunaLUA help thread

Post by FrozenQuills »

7NameSam wrote:I'm sorry, but I'm unfamiliar with Fader Libraries, and google doesn't give me any good results.
I just did something similar to this for one of my levels.
If you want a simple way to do it, make an 800x800 PNG image that's all black, then have this in the lua file:

Code: Select all

local black = Graphics.loadImage("black.png");
function onLoop()
  Graphics.drawImage(black,0,0,0.6);
end
Change 0.6 to whatever opacity you want. You can also use onLoopSection# where # is a section number to make it happen only for a section.
Image
Image
avatar by crayonchewer!
Image
Image
Image
SMBX Tileset Compiler and Separator
The boss entry that made me eat a shoe.

5th place counter: 5
(SMBX Forums CC11, SMBX Forums CC12, Endgame Madness Contest, SMWC Kaizo Contest 2016, SMWC 24hr Contest 2018)
User avatar
Karatekid5
Welcome to the resort!
Posts: 78
Joined: 14 years ago
Location: Pennsylvania
Contact:

Re: LunaDLL/LunaLUA help thread

Post by Karatekid5 »

Rockythechao wrote:It should be just the name of the function, so routine=scene_1, though if you want it to play as a cutscene, I suggest using scene=scene_1 instead.
I want it to be regular NPC dialogue, so I kept the routine tag. I added a line to the routine to print text to the screen, and when I press up the printed text appears, so talking to the NPC seems to be triggering the routine. Though, when I press up the NPC's CinematX dialogue still doesn't appear/activate.

Current code:

Code: Select all

cinematX = loadSharedAPI("cinematX")

cinematX.configExt ({hudBox=false, overrideNpcText=true, imageUi=false, textbloxSub=true})

function scene_1 ()
   Text.print("The routine is running",12,12)
   cinematX.startDialogExt (bellossom1, Bellossom, "Hello there! Welcome to the Starlight Resort!")
   cinematX.waitForDialog()
end
Yoshi Ambassador!
Image
Rixithechao
https://www.youtube.com/watch?v=BODxOghVmko
Posts: 1811
Joined: 10 years ago
First name: Mack
https://rixithechao.talkhaus.com/

Re: LunaDLL/LunaLUA help thread

Post by Rixithechao »

startDialogExt is just the text and a table of named arguments. Try this:

Code: Select all

cinematX = loadSharedAPI("cinematX")

cinematX.configExt ({hudBox=false, overrideNpcText=true, imageUi=false, textbloxSub=true})

function scene_1 ()
   local belActor1 = cinematX.getActorFromKey ("bellossom1")
   Text.print("The routine is running",12,12)
   cinematX.startDialogExt ("Hello there! Welcome to the Starlight Resort!", {actor=belActor1, name="Bellossom"})
   cinematX.waitForDialog()
end
Delightful Adventure Enhanced is out now!

Image

There's an official ASMT Discord server! Check it out to discuss Demo games and follow their development! thread, invite link

(Entry requires verification, either with a connected Youtube/Twitter/Twitch/etc account or manually by the server staff.)


Itch.io (albums and eventually games), Youtube (dofur pass and I guess other videos)
Post Reply