Page 27 of 47

Re: LunaLua Offical Thread - SMBX Usermod Framework

Posted: Sun Dec 20, 2015 4:31 pm
by ShadowStarX
Thank you guys for the help, hopefully (and probably) it'll succeed. ;)

Re: LunaLua Offical Thread - SMBX Usermod Framework

Posted: Mon Dec 21, 2015 7:36 am
by TDK
God Mode doesn't seem to work when I use LunaLua on the editor.

Re: LunaLua Offical Thread - SMBX Usermod Framework

Posted: Mon Dec 21, 2015 7:44 am
by Kevsoft
TheDinoKing432 wrote:God Mode doesn't seem to work when I use LunaLua on the editor.
This is an issue, which is already solved in the dev version. You can still activate godmode with the cheat "donthurtme".

Re: LunaLua Offical Thread - SMBX Usermod Framework

Posted: Mon Dec 21, 2015 10:58 am
by PixelPest
Can someone please help me with this? I have no idea where to start. I'm trying to create a system where you talk to NPCs, and then they disappear. After you talk to x number of NPCs (increasing amount in each level), an event is triggered.
So pretty much, I know I need some code called when an NPC is talked to and then a counter of some type that has a value of +1 added to it each time you talk to an NPC, then when the value is equal to a set number, the event is triggered.
Please help. I have no idea how to code this. (You will be given credit on the episode for your help.)

Re: LunaLua Offical Thread - SMBX Usermod Framework

Posted: Mon Dec 21, 2015 11:11 am
by underFlo
PixelPest wrote:Can someone please help me with this? I have no idea where to start. I'm trying to create a system where you talk to NPCs, and then they disappear. After you talk to x number of NPCs (increasing amount in each level), an event is triggered.
So pretty much, I know I need some code called when an NPC is talked to and then a counter of some type that has a value of +1 added to it each time you talk to an NPC, then when the value is equal to a set number, the event is triggered.
Please help. I have no idea how to code this. (You will be given credit on the episode for your help.)
http://hastebin.com/ezenekehej.lua

Also, I did a thing:
Spoiler: show
Image

Re: LunaLua Offical Thread - SMBX Usermod Framework

Posted: Mon Dec 21, 2015 11:19 am
by ShadowStarX
Spinda wrote: Also, I did a thing:
Spoiler: show
Image
That looks amazing!
Is it going to be a quiz show?

Re: LunaLua Offical Thread - SMBX Usermod Framework

Posted: Mon Dec 21, 2015 11:48 am
by Destiny
ShadowStarX wrote:
Spinda wrote: Also, I did a thing:
Spoiler: show
Image
That looks amazing!
Is it going to be a quiz show?
I guess it's the battle system from Undertale.

Re: LunaLua Offical Thread - SMBX Usermod Framework

Posted: Mon Dec 21, 2015 12:07 pm
by PersonNamedUser
After messing with lua for a little bit i managed to make a currency system:

Code: Select all

local Coins = 0;
local Counter = Graphics.loadImage("coincounter.png")

function onLoop()
      Text.print(Coins, 280, 80)
end

function onHUDDraw()
     Graphics.drawImage(Counter, 230, 80)

	end

function onNPCKill(eventObj,npcID,killReason)
    if npcID.id == 10 then
	    Coins = Coins + 1;
	end
	UserData.save()
end 
But the only thing wrong with it is that i don't know how to make your coin count carry over to other levels, could someone
help me?

Re: LunaLua Offical Thread - SMBX Usermod Framework

Posted: Mon Dec 21, 2015 12:13 pm
by Emral
I think your primary concern with that code is that coins will add to your counter when they despawn. For the other thing:
http://engine.wohlnet.ru/pgewiki/Data_%28class%29

Re: LunaLua Offical Thread - SMBX Usermod Framework

Posted: Mon Dec 21, 2015 1:23 pm
by PersonNamedUser
I messed with the data class a little bit, but i got stuck on this code:

Code: Select all

local Coins = 0;
local Counter = Graphics.loadImage("coincounter.png")

function onLoop()
      Text.print(Coins, 280, 80)
	  Coins = Data(Data.DATA_WORLD)
	  Data:set("Coins", 0;)
end

function onHUDDraw()
     Graphics.drawImage(Counter, 230, 80)

	end

function onNPCKill(eventObj,npcID,killReason)
    if npcID.id == 10 then
	     Data:get(Coins + 1;)
	 end
	 Data.save()
  end

Could someone please help me insert the correct code?

Re: LunaLua Offical Thread - SMBX Usermod Framework

Posted: Mon Dec 21, 2015 2:08 pm
by PixelPest
Spinda wrote:
PixelPest wrote:Can someone please help me with this? I have no idea where to start. I'm trying to create a system where you talk to NPCs, and then they disappear. After you talk to x number of NPCs (increasing amount in each level), an event is triggered.
So pretty much, I know I need some code called when an NPC is talked to and then a counter of some type that has a value of +1 added to it each time you talk to an NPC, then when the value is equal to a set number, the event is triggered.
Please help. I have no idea how to code this. (You will be given credit on the episode for your help.)
http://hastebin.com/ezenekehej.lua

Also, I did a thing:
Spoiler: show
Image
Thanks Spinda. That actually makes sense!

Re: LunaLua Offical Thread - SMBX Usermod Framework

Posted: Mon Dec 21, 2015 3:05 pm
by PixelPest

Code: Select all

events = {"count"}
counter = 0
gotRun = false

function onEvent(eventname)
	for _,v in pairs(events) do
		if eventname = v then
			counter = counter + 1
		end
	end
end

function onLoop()
	if counter == 1 and not gotRun then
		gotRun = true
	end
end
if gotRun = true
	then ...
end
So now that I have this (the first level only has one NPC that needs to be talked to), how do I trigger an event to happen? I have an event named "end" that shows the SMB3 star to end the level. Or, would it be easier to spawn an SMB3 star; if so how would I do so?

Re: LunaLua Offical Thread - SMBX Usermod Framework

Posted: Mon Dec 21, 2015 3:08 pm
by underFlo
PixelPest wrote:

Code: Select all

events = {"count"}
counter = 0
gotRun = false

function onEvent(eventname)
	for _,v in pairs(events) do
		if eventname = v then
			counter = counter + 1
		end
	end
end

function onLoop()
	if counter == 1 and not gotRun then
		gotRun = true
	end
end
if gotRun = true
	...
end
So now that I have this (the first level only has one NPC that needs to be talked to), how do I trigger an event to happen? I have an event named "end" that shows the SMB3 star to end the level. Or, would it be easier to spawn an SMB3 star; if so how would I do so?
http://hastebin.com/ruzuzitoya.lua

pretty much this.
Spoiler: show
Image
also menues, oh my.

Re: LunaLua Offical Thread - SMBX Usermod Framework

Posted: Mon Dec 21, 2015 3:11 pm
by PixelPest
Spinda wrote:
PixelPest wrote:

Code: Select all

events = {"count"}
counter = 0
gotRun = false

function onEvent(eventname)
	for _,v in pairs(events) do
		if eventname = v then
			counter = counter + 1
		end
	end
end

function onLoop()
	if counter == 1 and not gotRun then
		gotRun = true
	end
end
if gotRun = true
	...
end
So now that I have this (the first level only has one NPC that needs to be talked to), how do I trigger an event to happen? I have an event named "end" that shows the SMB3 star to end the level. Or, would it be easier to spawn an SMB3 star; if so how would I do so?
http://hastebin.com/ruzuzitoya.lua

pretty much this.
Spoiler: show
Image
also menues, oh my.
It's all starting to come together. Thanks for all of your help!

Re: LunaLua Offical Thread - SMBX Usermod Framework

Posted: Mon Dec 21, 2015 3:24 pm
by PixelPest
Now I'm getting "7: 'then' expected near '='. What could be a mistake with the code?

http://hastebin.com/ruzuzitoya.lua

Re: LunaLua Offical Thread - SMBX Usermod Framework

Posted: Mon Dec 21, 2015 3:26 pm
by underFlo
oh rip it should be == (as a matter of fact, = is used for declaring stuff and == is used for comparing stuff)

Re: LunaLua Offical Thread - SMBX Usermod Framework

Posted: Mon Dec 21, 2015 3:40 pm
by PixelPest
Spinda wrote:oh rip it should be == (as a matter of fact, = is used for declaring stuff and == is used for comparing stuff)
Yes! It works!
Spoiler: show
Image

Re: LunaLua Offical Thread - SMBX Usermod Framework

Posted: Tue Dec 22, 2015 8:07 am
by Lukas Old Account
I need a code for a health bar of a boss i made, it has to work on mother brain tough. Each time you hit him, 1hp will be taken away. When the boss is defeated. te bar goes up and disappears.

Re: LunaLua Offical Thread - SMBX Usermod Framework

Posted: Tue Dec 22, 2015 1:35 pm
by litchh
Is there a way to switch in 1-player mode without lunaforcing cheating?

Re: LunaLua Offical Thread - SMBX Usermod Framework

Posted: Wed Dec 23, 2015 2:14 pm
by Creasion
There's this thing I want to do that involves the ghost npc's.

I want the ghost's ''hunting phase'' to have 2 frames, as well as I want the ghost to be ''heat seeking'' aka I want it to be vicious in it's pursuit of you, following your every move. I also want the npc to instead of seeking you when your back is turned, I want it to always seek you.

Can lunalua do all these things?