Page 4 of 76

Re: Need help with lua? - LunaLua General Help

Posted: Sat Mar 19, 2016 10:17 am
by Mario_and_Luigi_55
Enjl wrote:You can only have one function of each name in your lunadll.lua file.
Also, maximum player fall speed is 12, so even if it worked, it wouldn't be noticable if the player was already falling.
But will function for example onKeyDown work if I would rename IT?

Re: Need help with lua? - LunaLua General Help

Posted: Sat Mar 19, 2016 10:18 am
by Emral
Mario_and_Luigi_55 wrote:
Enjl wrote:You can only have one function of each name in your lunadll.lua file.
Also, maximum player fall speed is 12, so even if it worked, it wouldn't be noticable if the player was already falling.
But will function for example onKeyDown work if I would rename IT?
Just throw your two onKeyDown and onLoop functions into one each?

Re: Need help with lua? - LunaLua General Help

Posted: Sun Mar 20, 2016 8:21 am
by Mario_and_Luigi_55
Can I change things that volcano lotus shoots (for example can it shoot springs instead of fireballs)

Re: Need help with lua? - LunaLua General Help

Posted: Sun Mar 20, 2016 9:13 am
by Emral
Yeah, just change the ID of the NPC it's shooting.
http://wohlsoft.ru/pgewiki/NPC_%28class%29

Re: Need help with lua? - LunaLua General Help

Posted: Sun Mar 20, 2016 10:06 am
by Mario_and_Luigi_55
no static mem in NPC.

Thi error is boring. I get in millions of times when i try doing anything...

Code: Select all

function onLoop()
    for k,v in pairs(NPC.get(275,-1)) do
        NPC:mem(0xF8,FIELD_DFLOAT,26)
    end
end

Re: Need help with lua? - LunaLua General Help

Posted: Sun Mar 20, 2016 10:08 am
by Emral
Mario_and_Luigi_55 wrote:no static mem in NPC.

Thi error is boring. I get in millions of times when i try doing anything...

Code: Select all

function onLoop()
    for k,v in pairs(NPC.get(275,-1)) do
        NPC:mem(0xF8,FIELD_DFLOAT,26)
    end
end
NPC refers to your NPC object. If you wrap a table into a for loop which iterates over each object (v) with the key (k), you need to use v.

Code: Select all

function onTick()
   for k,v in ipairs(NPC.get(275, -1)) do
      v.id = 26
   end
end

Re: Need help with lua? - LunaLua General Help

Posted: Sun Mar 20, 2016 10:08 am
by Mario_and_Luigi_55
OK. Thanks

Re: Need help with lua? - LunaLua General Help

Posted: Sun Mar 20, 2016 8:34 pm
by Ness-Wednesday
I got a massive error saying that the overload matching candidates couldn't be found.

Is there something wrong here?
Spoiler: show

Code: Select all

function onLoopSection1()
	if(dialogueTime >= 0) then
    dialogueTime = dialogueTime - 1
	end
	local dialogueInSeconds = math.ceil(dialogueTime / 32)
	Graphics.drawImage(image, 0, 0)
		if(dialogueInSeconds <= 30 and dialogueInSeconds >= 27) then
		Graphics.drawImageWP(zlakerboy , 0, 472, 1)
		Text.printWP("Did you see him straining?", 126, 520, 2)
		Audio.playSFX("Zlakerboy quote.ogg")
		elseif(dialogueInSeconds <= 27 and dialogueInSeconds >= 24) then
		Graphics.drawImageWP(nude , 0, 472, 1)
		Text.printWP("Positivley awful design.", 126, 520, 2)
		Audio.playSFX("Bossedit8 quote.ogg")
		elseif(dialogueInSeconds <= 24 and dialogueInSeconds >= 19) then
		Graphics.drawImageWP(princess , 0, 472, 1)
		Text.printWP("Just some garbage.", 126, 520, 2)
		Text.printWP("He should give up and be", 126, 540, 2)
		Text.printWP("disqualified before it's too late.", 126, 560, 2)
		Audio.playSFX("Meme princess quote.ogg")
		elseif(dialogueInSeconds <= 19 and dialogueInSeconds >= 15) then
		Graphics.drawImageWP(sexy , 0, 472, 1)
		Text.printWP("Shut up! You're all jealous.", 126, 520, 2)
		Text.printWP("Wraith's better than any of you!", 126, 540, 2)
		Audio.playSFX("some sexy girl.ogg")
		elseif(dialogueInSeconds <= 15 and dialogueInSeconds >= 11) then
		Graphics.drawImageWP(meme , 0, 472, 1)
		Text.printWP("Yre right, Ski.", 126, 520, 2)
		Text.printWP("Wraith's awl but heil surprise aws all!", 126, 540, 2)
		Audio.playSFX("Sinda meme A.ogg")
		elseif(dialogueInSeconds <= 11 and dialogueInSeconds >= 9) then
		Graphics.drawImageWP(captain , 0, 472, 1)
		Text.printWP("If people are gonna....", 126, 520, 2)
		Audio.playSFX("Wraith 1.ogg")
		elseif(dialogueInSeconds <= 9 and dialogueInSeconds >= 4) then
		Graphics.drawImageWP(preach , 0, 472, 1)
		Text.printWP("Come on Wraith, don't let them think", 126, 520, 2)
		Text.printWP("you could never improve, you'll get back to", 126, 540, 2)
		Text.printWP("higher tiers someday.", 126, 560, 2)
		Audio.playSFX("NW Quote 1.ogg")
		elseif(dialogueInSeconds <= 4 and dialogueInSeconds >= 1) then
		Graphics.drawImageWP(captain , 0, 472, 1)
		Text.printWP("Then I'll prove so that I can", 126, 520, 2)
		Text.printWP("do well and take Lucas-Thursday with me.", 126, 540, 2)
		Audio.playSFX("Wraith 2.ogg")
		elseif(dialogueInSeconds <= 1) then
		Text.printWP("PRESS UP TO CONTINUE", 230, 150, 1)
		Graphics.drawImageWP(captain , 0, 472, 1)
		Text.printWP("Then I'll prove so that I can", 126, 520, 2)
		Text.printWP("do well and take Lucas-Thursday with me.", 126, 540, 2)
		end
end
Edit: SMBX crashes when I go to that same section it's set on.

Re: Need help with lua? - LunaLua General Help

Posted: Sun Mar 20, 2016 8:37 pm
by Quantix
So I've used this specific code from the wiki in a level:

Code: Select all

local SMWCam = loadAPI("SMWcamera")
local t = 0   -- Frame timer
 
function onTickEnd()
	-- Pans the camera to the right, wobbles the camera up and down (like on an airship)
	SMWCam.BeginAutoScroll(2, math.cos(t*math.pi/180))
 
	-- Increment frame timer
	t = t + 1
end
It's supposed to fiddle with the normal camera, but all it does is shove the player to the right. Am I missing something here?

By the way, apologies in advance for any further stupid questions I might make. I'm quite new to this whole thing. :?

Re: Need help with lua? - LunaLua General Help

Posted: Sun Mar 20, 2016 10:06 pm
by arabsalmon
Quantix wrote:So I've used this specific code from the wiki in a level:

Code: Select all

local SMWCam = loadAPI("SMWcamera")
local t = 0   -- Frame timer
 
function onTickEnd()
	-- Pans the camera to the right, wobbles the camera up and down (like on an airship)
	SMWCam.BeginAutoScroll(2, math.cos(t*math.pi/180))
 
	-- Increment frame timer
	t = t + 1
end
It's supposed to fiddle with the normal camera, but all it does is shove the player to the right. Am I missing something here?

By the way, apologies in advance for any further stupid questions I might make. I'm quite new to this whole thing. :?
This exact same code seems to work for me. Be sure that the section allows enough room for camera movement both vertically and horizontally.

Re: Need help with lua? - LunaLua General Help

Posted: Sun Mar 20, 2016 10:06 pm
by Eternity
Not really my code or anything but I'm having trouble getting ParalX.lua to work (even on the example level there) :v

Apparently I'm getting some error related to Graphics.draw - I really can't Lua (so it's likely it's just me being stupid lol) but I think it has to do with the version I'm using, the one that comes with SMBX 2.0.

Tried updating (dunno if that would actually change anything though ¯\_(ツ)_/¯) but it didn't work for some reason, it kills the sound and I'm pretty sure Lua completely stops working as well. Did pretty much what was on the first post.

So yeah, I'm super confused and I have no idea if anything here actually helps lol

Re: Need help with lua? - LunaLua General Help

Posted: Sun Mar 20, 2016 10:17 pm
by Emral
Eternity wrote:Not really my code or anything but I'm having trouble getting ParalX.lua to work (even on the example level there) :v

Apparently I'm getting some error related to Graphics.draw - I really can't Lua (so it's likely it's just me being stupid lol) but I think it has to do with the version I'm using, the one that comes with SMBX 2.0.

Tried updating (dunno if that would actually change anything though ¯\_(ツ)_/¯) but it didn't work for some reason, it kills the sound and I'm pretty sure Lua completely stops working as well. Did pretty much what was on the first post.

So yeah, I'm super confused and I have no idea if anything here actually helps lol
Your lua is likely out of date.

Re: Need help with lua? - LunaLua General Help

Posted: Mon Mar 21, 2016 6:25 am
by PixelPest
Ness-Wednesday wrote:I got a massive error saying that the overload matching candidates couldn't be found.

Is there something wrong here?
Spoiler: show

Code: Select all

function onLoopSection1()
	if(dialogueTime >= 0) then
    dialogueTime = dialogueTime - 1
	end
	local dialogueInSeconds = math.ceil(dialogueTime / 32)
	Graphics.drawImage(image, 0, 0)
		if(dialogueInSeconds <= 30 and dialogueInSeconds >= 27) then
		Graphics.drawImageWP(zlakerboy , 0, 472, 1)
		Text.printWP("Did you see him straining?", 126, 520, 2)
		Audio.playSFX("Zlakerboy quote.ogg")
		elseif(dialogueInSeconds <= 27 and dialogueInSeconds >= 24) then
		Graphics.drawImageWP(nude , 0, 472, 1)
		Text.printWP("Positivley awful design.", 126, 520, 2)
		Audio.playSFX("Bossedit8 quote.ogg")
		elseif(dialogueInSeconds <= 24 and dialogueInSeconds >= 19) then
		Graphics.drawImageWP(princess , 0, 472, 1)
		Text.printWP("Just some garbage.", 126, 520, 2)
		Text.printWP("He should give up and be", 126, 540, 2)
		Text.printWP("disqualified before it's too late.", 126, 560, 2)
		Audio.playSFX("Meme princess quote.ogg")
		elseif(dialogueInSeconds <= 19 and dialogueInSeconds >= 15) then
		Graphics.drawImageWP(sexy , 0, 472, 1)
		Text.printWP("Shut up! You're all jealous.", 126, 520, 2)
		Text.printWP("Wraith's better than any of you!", 126, 540, 2)
		Audio.playSFX("some sexy girl.ogg")
		elseif(dialogueInSeconds <= 15 and dialogueInSeconds >= 11) then
		Graphics.drawImageWP(meme , 0, 472, 1)
		Text.printWP("Yre right, Ski.", 126, 520, 2)
		Text.printWP("Wraith's awl but heil surprise aws all!", 126, 540, 2)
		Audio.playSFX("Sinda meme A.ogg")
		elseif(dialogueInSeconds <= 11 and dialogueInSeconds >= 9) then
		Graphics.drawImageWP(captain , 0, 472, 1)
		Text.printWP("If people are gonna....", 126, 520, 2)
		Audio.playSFX("Wraith 1.ogg")
		elseif(dialogueInSeconds <= 9 and dialogueInSeconds >= 4) then
		Graphics.drawImageWP(preach , 0, 472, 1)
		Text.printWP("Come on Wraith, don't let them think", 126, 520, 2)
		Text.printWP("you could never improve, you'll get back to", 126, 540, 2)
		Text.printWP("higher tiers someday.", 126, 560, 2)
		Audio.playSFX("NW Quote 1.ogg")
		elseif(dialogueInSeconds <= 4 and dialogueInSeconds >= 1) then
		Graphics.drawImageWP(captain , 0, 472, 1)
		Text.printWP("Then I'll prove so that I can", 126, 520, 2)
		Text.printWP("do well and take Lucas-Thursday with me.", 126, 540, 2)
		Audio.playSFX("Wraith 2.ogg")
		elseif(dialogueInSeconds <= 1) then
		Text.printWP("PRESS UP TO CONTINUE", 230, 150, 1)
		Graphics.drawImageWP(captain , 0, 472, 1)
		Text.printWP("Then I'll prove so that I can", 126, 520, 2)
		Text.printWP("do well and take Lucas-Thursday with me.", 126, 540, 2)
		end
end
Edit: SMBX crashes when I go to that same section it's set on.
Do you ever load all of those images anywhere?

Re: Need help with lua? - LunaLua General Help

Posted: Mon Mar 21, 2016 8:17 am
by Ness-Wednesday
PixelPest wrote:
Ness-Wednesday wrote:I got a massive error saying that the overload matching candidates couldn't be found.

Is there something wrong here?
Spoiler: show

Code: Select all

function onLoopSection1()
	if(dialogueTime >= 0) then
    dialogueTime = dialogueTime - 1
	end
	local dialogueInSeconds = math.ceil(dialogueTime / 32)
	Graphics.drawImage(image, 0, 0)
		if(dialogueInSeconds <= 30 and dialogueInSeconds >= 27) then
		Graphics.drawImageWP(zlakerboy , 0, 472, 1)
		Text.printWP("Did you see him straining?", 126, 520, 2)
		Audio.playSFX("Zlakerboy quote.ogg")
		elseif(dialogueInSeconds <= 27 and dialogueInSeconds >= 24) then
		Graphics.drawImageWP(nude , 0, 472, 1)
		Text.printWP("Positivley awful design.", 126, 520, 2)
		Audio.playSFX("Bossedit8 quote.ogg")
		elseif(dialogueInSeconds <= 24 and dialogueInSeconds >= 19) then
		Graphics.drawImageWP(princess , 0, 472, 1)
		Text.printWP("Just some garbage.", 126, 520, 2)
		Text.printWP("He should give up and be", 126, 540, 2)
		Text.printWP("disqualified before it's too late.", 126, 560, 2)
		Audio.playSFX("Meme princess quote.ogg")
		elseif(dialogueInSeconds <= 19 and dialogueInSeconds >= 15) then
		Graphics.drawImageWP(sexy , 0, 472, 1)
		Text.printWP("Shut up! You're all jealous.", 126, 520, 2)
		Text.printWP("Wraith's better than any of you!", 126, 540, 2)
		Audio.playSFX("some sexy girl.ogg")
		elseif(dialogueInSeconds <= 15 and dialogueInSeconds >= 11) then
		Graphics.drawImageWP(meme , 0, 472, 1)
		Text.printWP("Yre right, Ski.", 126, 520, 2)
		Text.printWP("Wraith's awl but heil surprise aws all!", 126, 540, 2)
		Audio.playSFX("Sinda meme A.ogg")
		elseif(dialogueInSeconds <= 11 and dialogueInSeconds >= 9) then
		Graphics.drawImageWP(captain , 0, 472, 1)
		Text.printWP("If people are gonna....", 126, 520, 2)
		Audio.playSFX("Wraith 1.ogg")
		elseif(dialogueInSeconds <= 9 and dialogueInSeconds >= 4) then
		Graphics.drawImageWP(preach , 0, 472, 1)
		Text.printWP("Come on Wraith, don't let them think", 126, 520, 2)
		Text.printWP("you could never improve, you'll get back to", 126, 540, 2)
		Text.printWP("higher tiers someday.", 126, 560, 2)
		Audio.playSFX("NW Quote 1.ogg")
		elseif(dialogueInSeconds <= 4 and dialogueInSeconds >= 1) then
		Graphics.drawImageWP(captain , 0, 472, 1)
		Text.printWP("Then I'll prove so that I can", 126, 520, 2)
		Text.printWP("do well and take Lucas-Thursday with me.", 126, 540, 2)
		Audio.playSFX("Wraith 2.ogg")
		elseif(dialogueInSeconds <= 1) then
		Text.printWP("PRESS UP TO CONTINUE", 230, 150, 1)
		Graphics.drawImageWP(captain , 0, 472, 1)
		Text.printWP("Then I'll prove so that I can", 126, 520, 2)
		Text.printWP("do well and take Lucas-Thursday with me.", 126, 540, 2)
		end
end
Edit: SMBX crashes when I go to that same section it's set on.
Do you ever load all of those images anywhere?
They're in the graphics folder of the level, I have them set, so I should add the name of the level next to them?
I have them set, but I think that could be the problem now.

Re: Need help with lua? - LunaLua General Help

Posted: Mon Mar 21, 2016 8:21 am
by PixelPest
Ness-Wednesday wrote:
PixelPest wrote:
Ness-Wednesday wrote:I got a massive error saying that the overload matching candidates couldn't be found.

Is there something wrong here?
Spoiler: show

Code: Select all

function onLoopSection1()
	if(dialogueTime >= 0) then
    dialogueTime = dialogueTime - 1
	end
	local dialogueInSeconds = math.ceil(dialogueTime / 32)
	Graphics.drawImage(image, 0, 0)
		if(dialogueInSeconds <= 30 and dialogueInSeconds >= 27) then
		Graphics.drawImageWP(zlakerboy , 0, 472, 1)
		Text.printWP("Did you see him straining?", 126, 520, 2)
		Audio.playSFX("Zlakerboy quote.ogg")
		elseif(dialogueInSeconds <= 27 and dialogueInSeconds >= 24) then
		Graphics.drawImageWP(nude , 0, 472, 1)
		Text.printWP("Positivley awful design.", 126, 520, 2)
		Audio.playSFX("Bossedit8 quote.ogg")
		elseif(dialogueInSeconds <= 24 and dialogueInSeconds >= 19) then
		Graphics.drawImageWP(princess , 0, 472, 1)
		Text.printWP("Just some garbage.", 126, 520, 2)
		Text.printWP("He should give up and be", 126, 540, 2)
		Text.printWP("disqualified before it's too late.", 126, 560, 2)
		Audio.playSFX("Meme princess quote.ogg")
		elseif(dialogueInSeconds <= 19 and dialogueInSeconds >= 15) then
		Graphics.drawImageWP(sexy , 0, 472, 1)
		Text.printWP("Shut up! You're all jealous.", 126, 520, 2)
		Text.printWP("Wraith's better than any of you!", 126, 540, 2)
		Audio.playSFX("some sexy girl.ogg")
		elseif(dialogueInSeconds <= 15 and dialogueInSeconds >= 11) then
		Graphics.drawImageWP(meme , 0, 472, 1)
		Text.printWP("Yre right, Ski.", 126, 520, 2)
		Text.printWP("Wraith's awl but heil surprise aws all!", 126, 540, 2)
		Audio.playSFX("Sinda meme A.ogg")
		elseif(dialogueInSeconds <= 11 and dialogueInSeconds >= 9) then
		Graphics.drawImageWP(captain , 0, 472, 1)
		Text.printWP("If people are gonna....", 126, 520, 2)
		Audio.playSFX("Wraith 1.ogg")
		elseif(dialogueInSeconds <= 9 and dialogueInSeconds >= 4) then
		Graphics.drawImageWP(preach , 0, 472, 1)
		Text.printWP("Come on Wraith, don't let them think", 126, 520, 2)
		Text.printWP("you could never improve, you'll get back to", 126, 540, 2)
		Text.printWP("higher tiers someday.", 126, 560, 2)
		Audio.playSFX("NW Quote 1.ogg")
		elseif(dialogueInSeconds <= 4 and dialogueInSeconds >= 1) then
		Graphics.drawImageWP(captain , 0, 472, 1)
		Text.printWP("Then I'll prove so that I can", 126, 520, 2)
		Text.printWP("do well and take Lucas-Thursday with me.", 126, 540, 2)
		Audio.playSFX("Wraith 2.ogg")
		elseif(dialogueInSeconds <= 1) then
		Text.printWP("PRESS UP TO CONTINUE", 230, 150, 1)
		Graphics.drawImageWP(captain , 0, 472, 1)
		Text.printWP("Then I'll prove so that I can", 126, 520, 2)
		Text.printWP("do well and take Lucas-Thursday with me.", 126, 540, 2)
		end
end
Edit: SMBX crashes when I go to that same section it's set on.
Do you ever load all of those images anywhere?
They're in the graphics folder of the level, I have them set, so I should add the name of the level next to them?
I have them set, but I think that could be the problem now.
No. That's not necessary. Do you ever do, for example:

Code: Select all

local memes = Graphics.loadImage("memes")
???

Re: Need help with lua? - LunaLua General Help

Posted: Mon Mar 21, 2016 8:26 am
by Ness-Wednesday
PixelPest wrote:
Ness-Wednesday wrote:
PixelPest wrote: Do you ever load all of those images anywhere?
They're in the graphics folder of the level, I have them set, so I should add the name of the level next to them?
I have them set, but I think that could be the problem now.
No. That's not necessary. Do you ever do, for example:

Code: Select all

local memes = Graphics.loadImage("memes")
???
I did, I just didn't show them and they are typed correctly so I don't know why does it happen.
Spoiler: show

Code: Select all

local zlakerboy = Graphics.loadImage("zee_laker.png")
local meme = Graphics.loadImage("ultemmie_spinka.png")
local dev = Graphics.loadImage("deviantart_user.png")
local preach = Graphics.loadImage("prince_north.png")
local princess = Graphics.loadImage("cool_trainer.png")
local hammer = Graphics.loadImage("bossy_edit.png")
local captain = Graphics.loadImage("wraith_as303298.png")

Re: Need help with lua? - LunaLua General Help

Posted: Mon Mar 21, 2016 10:41 am
by Mario_and_Luigi_55
How can I do fog in the level?

Re: Need help with lua? - LunaLua General Help

Posted: Mon Mar 21, 2016 11:00 am
by Emral
Mario_and_Luigi_55 wrote:How can I do fog in the level?
http://wohlsoft.ru/pgewiki/Particles.lua
If you download the package there are some example ini files which you can use. You just need some kind of white mist sprite to represent fog (I don't think they're included in the download, but they'll be available with the next 2.0 beta. For the time being, you can try making one yourself).

Re: Need help with lua? - LunaLua General Help

Posted: Mon Mar 21, 2016 11:19 am
by Hoeloe
Enjl wrote:(I don't think they're included in the download, but they'll be available with the next 2.0 beta. For the time being, you can try making one yourself).
They should be included in the download. One of the example particle systems is a fog effect.

Re: Need help with lua? - LunaLua General Help

Posted: Mon Mar 21, 2016 2:31 pm
by Mario_and_Luigi_55
Hoeloe wrote:
Enjl wrote:(I don't think they're included in the download, but they'll be available with the next 2.0 beta. For the time being, you can try making one yourself).
They should be included in the download. One of the example particle systems is a fog effect.

Wait, the example doesn't work

Code: Select all

local particles = loadAPI("particles");
 
local effect = particles.Emitter(0, 0, Misc.resolveFile("particles/p_rain.ini"));
effect:AttachToCamera(Camera.get()[1]);
 
function onCameraUpdate()
    effect:Draw();
end
Why? The / is flipped it should be \, but lua says:

for particles/anythinghere.ini - cannot open
and for particles\anything.ini - invalid escape near 'particles'

I have all the required .lua files from particles.lua (they are in SMBX 2.0 by deafult)