LunaLua Offical Thread - SMBX Usermod Framework

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?

Shall I steam some LunaLua live development?

Yes
200
92%
No
17
8%
 
Total votes: 217
PixelPest
Link
Link
Posts: 7111
Joined: Sun Jul 12, 2015 5:38 pm
Flair: Tamer of Boom Booms
Contact:

Re: LunaLua Offical Thread - SMBX Usermod Framework

Postby PixelPest » Sat Feb 13, 2016 12:10 pm

PixelPest wrote:
Spinda wrote:

Code: Select all

for _,v in pairs(NPC.Get(NPCID,player.section) do
	if Blocks.getIntersecting(v.x - 1,v.y - 1,v.x + v.width + 1,v.y + v.height + 1) ~= {} then
		v:kill()
	end
end
Thanks Spinda.
Except now it doesn't work:

Code: Select all

function onLoop()
	for _,v in pairs(NPC.Get(229,player.section) do
		if Blocks.getIntersecting(v.x - 1,v.y - 1,v.x + v.width + 1,v.y + v.height + 1) ~= {} then
			v:kill()
		end
	end
end
It keeps on saying ')' expected after 'do' (on line 2).

EDIT:
Enjl wrote:There's also NPC.collidesBlock(Bottom/Left/Top/Right), which are boolean values for each direction.

If you wanna kill NPCs at the ceiling you can check for
if NPC.collidesBlockTop then
v:kill()
end
Thanks Enjl, but the NPCs actually spawn from the ceiling using Lua so I don't think this would work. Might be useful in the future though.

Emral
Cute Yoshi Egg
Cute Yoshi Egg
Posts: 9887
Joined: Mon Jan 20, 2014 12:58 pm
Flair: Phoenix

Re: LunaLua Offical Thread - SMBX Usermod Framework

Postby Emral » Sat Feb 13, 2016 12:15 pm

PixelPest wrote:
PixelPest wrote:
Spinda wrote:

Code: Select all

for _,v in pairs(NPC.Get(NPCID,player.section) do
	if Blocks.getIntersecting(v.x - 1,v.y - 1,v.x + v.width + 1,v.y + v.height + 1) ~= {} then
		v:kill()
	end
end
Thanks Spinda.
Except now it doesn't work:

Code: Select all

function onLoop()
	for _,v in pairs(NPC.Get(229,player.section) do
		if Blocks.getIntersecting(v.x - 1,v.y - 1,v.x + v.width + 1,v.y + v.height + 1) ~= {} then
			v:kill()
		end
	end
end
It keeps on saying ')' expected after 'do' (on line 2).
It says "near" do. Which means that it's missing a ")" BEFORE the "do".

PixelPest
Link
Link
Posts: 7111
Joined: Sun Jul 12, 2015 5:38 pm
Flair: Tamer of Boom Booms
Contact:

Re: LunaLua Offical Thread - SMBX Usermod Framework

Postby PixelPest » Sat Feb 13, 2016 12:19 pm

Thanks Enjl. Didn't notice that.

lotus006
Spike
Spike
Posts: 284
Joined: Thu Sep 24, 2015 12:59 am

Re: LunaLua Offical Thread - SMBX Usermod Framework

Postby lotus006 » Sat Feb 13, 2016 12:20 pm

yay I found the Left Click Offsets for the mouse :D

Code: Select all

-1 = to the click

Code: Select all

mem(0x00B2C560, FIELD_WORD)

PixelPest
Link
Link
Posts: 7111
Joined: Sun Jul 12, 2015 5:38 pm
Flair: Tamer of Boom Booms
Contact:

Re: LunaLua Offical Thread - SMBX Usermod Framework

Postby PixelPest » Sat Feb 13, 2016 12:28 pm

==> no static 'Get' in class 'NPC'
==============
stack traceback:
[string "mainV2.lua"]:164:in function <[string "mainV2.lua"]:162>
[C]: in function '__index'
...\Daniel\SMBX\<name of CC level>\<name of CC level\lunadll.lua:2: in function <...\Daniel\SMBX\<name of CC level>\<name of CC level>\lunadll.lua:1>
[C]: in function '__xpcall'
[string "mainV2.lua"]:582: in function <[string "mainV2.lua"]:535>

This is the error the script Spinda provided me above is giving me now even after adding the bracket.
Last edited by PixelPest on Sat Feb 13, 2016 12:34 pm, edited 1 time in total.

underFlo
Wart
Wart
Posts: 4456
Joined: Mon Jul 14, 2014 10:44 am
Flair: sup im lesbiab
Pronouns: They/She
Contact:

Re: LunaLua Offical Thread - SMBX Usermod Framework

Postby underFlo » Sat Feb 13, 2016 12:31 pm

yeah it's NPC.get sorry for that

PixelPest
Link
Link
Posts: 7111
Joined: Sun Jul 12, 2015 5:38 pm
Flair: Tamer of Boom Booms
Contact:

Re: LunaLua Offical Thread - SMBX Usermod Framework

Postby PixelPest » Sat Feb 13, 2016 12:58 pm

Spinda wrote:yeah it's NPC.get sorry for that
And now it's saying that it's trying to index 'Blocks', a nil value.

underFlo
Wart
Wart
Posts: 4456
Joined: Mon Jul 14, 2014 10:44 am
Flair: sup im lesbiab
Pronouns: They/She
Contact:

Re: LunaLua Offical Thread - SMBX Usermod Framework

Postby underFlo » Sat Feb 13, 2016 1:20 pm

it's Block.getInteresecting

man i'm really dumb today

PixelPest
Link
Link
Posts: 7111
Joined: Sun Jul 12, 2015 5:38 pm
Flair: Tamer of Boom Booms
Contact:

Re: LunaLua Offical Thread - SMBX Usermod Framework

Postby PixelPest » Sat Feb 13, 2016 1:26 pm

Spinda wrote:it's Block.getInteresecting

man i'm really dumb today
Okay. It's not giving me an error anymore, however it isn't working either. The NPCs spawn randomly at the top of the screen like they are supposed to however they are killed instantly.
Might as well just post the whole script:

Code: Select all

local spawnchance = {}
local xvalue = {}
local recent = {0}
local recent2 = {0}
local recent3 = {0}
local recent4 = {0}
local recent5 = {0}
local recent6 = {0}
local recent7 = {0}
local recent8 = {0}
local recent9 = {0}
local recent10 = {0}

function onLoop()
	for _,v in pairs(NPC.get(229,player.section)) do
		if Block.getIntersecting(v.x - 1,v.y - 1,v.x + v.width + 1,v.y + v.height + 1) ~= {} then
			v:kill()
		end
	end
	spawnchance = math.random(1, 35)
	if recent ~= 0 then
		if recent == xvalue then
			spawnchance = 1
			recent = xvalue
			if recent10 ~= 0 then
				recent10 = 0
			end
		end
	end
	if recent2 ~= 0 then
		if recent2 == xvalue then
			spawnchance = 1
			recent2 = xvalue
			if recent1 ~= 0 then
				recent1 = 0
			end
		end
	end
	if recent3 ~= 0 then
		if recent3 == xvalue then
			spawnchance = 1
			recent3 = xvalue
			if recent2 ~= 0 then
				recent2 = 0
			end
		end
	end
	if recent4 ~= 0 then
		if recent4 == xvalue then
			spawnchance = 1
			recent4 = xvalue
			if recent3 ~= 0 then
				recent3 = 0
			end
		end
	end
	if recent5 ~= 0 then
		if recent5 == xvalue then
			spawnchance = 1
			recent5 = xvalue
			if recent4 ~= 0 then
				recent4 = 0
			end
		end
	end
	if recent6 ~= 0 then
		if recent6 == xvalue then
			spawnchance = 1
			recent6 = xvalue
			if recent5 ~= 0 then
				recent5 = 0
			end
		end
	end
	if recent7 ~= 0 then
		if recent7 == xvalue then
			spawnchance = 1
			recent7 = xvalue
			if recent6 ~= 0 then
				recent6 = 0
			end
		end
	end
	if recent8 ~= 0 then
		if recent8 == xvalue then
			spawnchance = 1
			recent8 = xvalue
			if recent7 ~= 0 then
				recent7 = 0
			end
		end
	end
	if recent9 ~= 0 then
		if recent9 == xvalue then
			spawnchance = 1
			recent9 = xvalue
			if recent8 ~= 0 then
				recent8 = 0
			end
		end
	end
	if recent10 ~= 0 then
		if recent10 == xvalue then
			spawnchance = 1
			recent10 = xvalue
			if recent9 ~= 0 then
				recent9 = 0
			end
		end
	end
	if spawnchance == 35 then
		xvalue = math.random(-6250, -6170)*32
		NPC.spawn(229, xvalue, -200608, 0)
	end
end

Kevsoft
Ripper II
Ripper II
Posts: 375
Joined: Sun Jul 27, 2014 8:03 am

Re: LunaLua Offical Thread - SMBX Usermod Framework

Postby Kevsoft » Sat Feb 13, 2016 3:33 pm

try:

Code: Select all

if #Block.getIntersecting(v.x - 1,v.y - 1,v.x + v.width + 1,v.y + v.height + 1) > 0 then
    v:kill()
end

underFlo
Wart
Wart
Posts: 4456
Joined: Mon Jul 14, 2014 10:44 am
Flair: sup im lesbiab
Pronouns: They/She
Contact:

Re: LunaLua Offical Thread - SMBX Usermod Framework

Postby underFlo » Sat Feb 13, 2016 3:43 pm

oh right you can do that

man i'm really dumb today

PixelPest
Link
Link
Posts: 7111
Joined: Sun Jul 12, 2015 5:38 pm
Flair: Tamer of Boom Booms
Contact:

Re: LunaLua Offical Thread - SMBX Usermod Framework

Postby PixelPest » Sat Feb 13, 2016 3:50 pm

Kevsoft wrote:try:

Code: Select all

if #Block.getIntersecting(v.x - 1,v.y - 1,v.x + v.width + 1,v.y + v.height + 1) > 0 then
    v:kill()
end
Okay. That worked. Thank you.
One more thing: How can I remove the sound for the death of npc-229 without removing the death sound for all of the other NPCs in the level?

HenryRichard
Reznor
Reznor
Posts: 2843
Joined: Mon Dec 23, 2013 12:09 pm
Flair: Is this where I type my password?
Contact:

Re: LunaLua Offical Thread - SMBX Usermod Framework

Postby HenryRichard » Sat Feb 13, 2016 3:59 pm

Instead of kill() use kill(7) - if I recall correctly that kills it with no animation or sound (if you need the animation use Animation.spawn())

Nat The Porcupine
Monty Mole
Monty Mole
Posts: 123
Joined: Tue Nov 10, 2015 2:55 pm

Re: LunaLua Offical Thread - SMBX Usermod Framework

Postby Nat The Porcupine » Sat Feb 13, 2016 7:06 pm

I'm having issues with loading a custom standing sprite in for Super Mario. Apparently SMBX 2.0 is having issues finding the "Player:getCurrentSpriteIndex()" function & possibly also having the same issue with the "Player:setCurrentSpriteIndex()" as well (I haven't bothered to test that last one on it's own yet, but I'm willing to guess that my prediction is correct). I have tried setting the memory values instead with unexpected results; there are no errors but the image index isn't actually set.

This is my code:

Code: Select all

local CurrentSprite = {}
local BigMario = false

loadHitboxes(1, 2, "mario-2.ini")

function onLoop()
	
	CurrentSprite = Player:getCurrentSpriteIndex()
	
	if Player.Character == CHARACTER_MARIO and Player.Powerup == PLAYER_BIG then
		BigMario = true;
	else
		BigMario = false;
	end
	
	if BigMario == true then
	
		if Player.Xspeed == 0 and Player.Yspeed == 0 and CurrentSprite(5,0) then
			Player:setCurrentSpriteIndex(7,6,false);
		end
		
		if Player.Xspeed == 0 and Player.Yspeed == 0 and CurrentSprite(4,8) then
			Player:setCurrentSpriteIndex(2,2,false);
		end
		
	end
	
end
And this is the resulting error message:

Code: Select all

==> no static 'getCurrentSpriteIndex' in class 'Player'
=============
stack traceback:
		[string "mainV2.lua"]:164: in function <[string "mainV2.lua"]:162>
		[C]: in function '_index'
		C:\Users\Nathan\Desktop\SMBX 2.0\worlds\Test\lunadll.lua:8: in
function <C:\Users\Nathan\Desktop\SMBX 2.0\worlds\Test\lunadll.lua:6>
		[C]: in function '_xpcall'
		[string "mainV2.lua"]:582: in function <[string "mainV2.lua"]:535>
I am a programmer (sort of; I mainly do HTML5 & GameMaker's proprietary programming language), but I am totally stumped on this...

I'm actually not even sure if I'm checking for the current sprite correctly using that "CurrentSprite" variable I set up, so some insight on that may be helpful as well.

Hoeloe
Phanto
Phanto
Posts: 1465
Joined: Sat Oct 03, 2015 6:18 pm
Flair: The Codehaus Girl
Pronouns: she/her

Re: LunaLua Offical Thread - SMBX Usermod Framework

Postby Hoeloe » Sat Feb 13, 2016 7:43 pm

Nat The Porcupine wrote:I'm having issues with loading a custom standing sprite in for Super Mario.
Capitalisation makes a difference.

Code: Select all

Player.Character
is not the same thing as

Code: Select all

player.character
The first of these looks for a variable called "Character" in the Player class, while the second looks for a variable called "character" (note the capitalisation) in the player object.

Nat The Porcupine
Monty Mole
Monty Mole
Posts: 123
Joined: Tue Nov 10, 2015 2:55 pm

Re: LunaLua Offical Thread - SMBX Usermod Framework

Postby Nat The Porcupine » Sat Feb 13, 2016 8:10 pm

Hoeloe wrote:
Nat The Porcupine wrote:I'm having issues with loading a custom standing sprite in for Super Mario.
Capitalisation makes a difference.

Code: Select all

Player.Character
is not the same thing as

Code: Select all

player.character
The first of these looks for a variable called "Character" in the Player class, while the second looks for a variable called "character" (note the capitalisation) in the player object.
Thank you. That certainly helped a lot. Now I'm having issues trying to actually checking for the current player sprite being used. How exactly am I supposed to properly check for something that returns 2 values? I can't even print the indexY value to the screen; only indexX value shows up.

EDIT: I resorted to using memory values partially. What I have found is that the 'setCurrentSpriteIndex' function doesn't work at all. It only changes the image index for a single frame after the left or right keys are pressed, making this function totally pointless. Looks like I'll have to find a creative workaround...

PixelPest
Link
Link
Posts: 7111
Joined: Sun Jul 12, 2015 5:38 pm
Flair: Tamer of Boom Booms
Contact:

Re: LunaLua Offical Thread - SMBX Usermod Framework

Postby PixelPest » Sat Feb 13, 2016 8:52 pm

HenryRichard wrote:Instead of kill() use kill(7) - if I recall correctly that kills it with no animation or sound (if you need the animation use Animation.spawn())
Nope. That did absolutely nothing. Anyone else no how to get rid of the death effect sound for this NPC using this code?:

Code: Select all

function onLoop()
	for _,v in pairs(NPC.get(229,player.section)) do
		if #Block.getIntersecting(v.x,v.y,v.x + v.width,v.y + v.height) > 0 then
			v:kill(7)
		end
	end
end

HenryRichard
Reznor
Reznor
Posts: 2843
Joined: Mon Dec 23, 2013 12:09 pm
Flair: Is this where I type my password?
Contact:

Re: LunaLua Offical Thread - SMBX Usermod Framework

Postby HenryRichard » Sat Feb 13, 2016 8:54 pm

You could try using sound overrides or teleporting the NPC offscreen.

PixelPest
Link
Link
Posts: 7111
Joined: Sun Jul 12, 2015 5:38 pm
Flair: Tamer of Boom Booms
Contact:

Re: LunaLua Offical Thread - SMBX Usermod Framework

Postby PixelPest » Sat Feb 13, 2016 8:59 pm

HenryRichard wrote:You could try using sound overrides or teleporting the NPC offscreen.
What do you mean by sounds overrides? Could you give me an example?

HenryRichard
Reznor
Reznor
Posts: 2843
Joined: Mon Dec 23, 2013 12:09 pm
Flair: Is this where I type my password?
Contact:

Re: LunaLua Offical Thread - SMBX Usermod Framework

Postby HenryRichard » Sat Feb 13, 2016 9:02 pm

http://wohlsoft.ru/pgewiki/SoundOverride_(class)
It's probably better to teleport the NPC offscreen though.


Return to “LunaLua”

Who is online

Users browsing this forum: No registered users and 1 guest

SMWCentralTalkhausMario Fan Games GalaxyKafukaMarioWikiSMBXEquipoEstelari