Page 26 of 47

Re: LunaLua Offical Thread - SMBX Usermod Framework

Posted: Wed Dec 09, 2015 6:23 pm
by Emral
SMBX thinks your hammer brother has 3 frames for each direction, and doesn't load any beyond that, because they "don't exist".

My way to circumvent this redigit-like programming like this is to completely disable the frame counter and add in my own. In your case, I'd write frames=18 into the .txt and just add if calls asking for direction, ai5, your own frame counter, and the times when he should use his 3rd frame.

Re: LunaLua Offical Thread - SMBX Usermod Framework

Posted: Wed Dec 09, 2015 6:42 pm
by HenryRichard
Enjl wrote:SMBX thinks your hammer brother has 3 frames for each direction, and doesn't load any beyond that, because they "don't exist".

My way to circumvent this redigit-like programming like this is to completely disable the frame counter and add in my own. In your case, I'd write frames=18 into the .txt and just add if calls asking for direction, ai5, your own frame counter, and the times when he should use his 3rd frame.
Well, I got it working. It feels a bit clunky, but they render correctly - I still have to work on the death effect, but the NPC works great.

Code: Select all

local npcconfig = loadAPI("npcconfig");
npcconfig[29].frames = 6 * 3;
npcconfig[29].framestyle = 0;

local hammerBroFrameTimer = 0;
local broIds = {89, 210};

function onLoop()
	for k, v in pairs(NPC.get(29, -1)) do
		if(v.friendly) then v.friendly = false; end
		if(v.msg.str ~= "") then
			if(v.msg.str == "goomba") then
				v.ai4 = 1;
			elseif(v.msg.str == "rinka") then
				v.ai4 = 2;
			end
			v.msg = "";
		end
		v.animationTimer = 0;
		if(v.ai5 > 0) then v.ai5 = v.ai5 - 1; end
		
		local frameAdd = 0;
		if(v.ai5 > 0) then frameAdd = 2; else frameAdd = math.floor(hammerBroFrameTimer / 16); end
		if(v.direction == DIR_RIGHT) then frameAdd = frameAdd + 3; end
		
		v.animationFrame = (v.ai4 * 6) + frameAdd;
		
		for k1,v1 in pairs(NPC.getIntersecting(v.x, v.y, v.x + v.width, v.y + v.height)) do
			if(v1.id == 30 and v1.ai1 == 0) then
				v.ai5 = 16;
				if(v.ai4 == 0) then
					v1.ai1 = 1;
				else
					v1.id = broIds[v.ai4];
				end
			end
		end
	end
	hammerBroFrameTimer = (hammerBroFrameTimer + 1) % 32;
end
Maybe when drawImageToScene gets priorities within SMBX-drawn things I'll make a better version, but this'll do for now.

Re: LunaLua Offical Thread - SMBX Usermod Framework

Posted: Thu Dec 10, 2015 12:41 am
by lotus006
Cool about the birdo egg it's working to kill Npcs now :D Nice :P
Also I need to found how to make ill use now the Larry Ring but how I can
make it's ring moving in any direction I want like he do any idea ? (the id is 269)
(not just right and left, in diagonal also)

Re: LunaLua Offical Thread - SMBX Usermod Framework

Posted: Thu Dec 10, 2015 11:38 am
by TheSaturnyoshi
lotus006 wrote:Cool about the birdo egg it's working to kill Npcs now :D Nice :P
Also I need to found how to make ill use now the Larry Ring but how I can
make it's ring moving in any direction I want like he do any idea ? (the id is 269)
(not just right and left, in diagonal also)
Easy, set its x and y speeds.
However, if you want to be able to place it in the level, I would suggest using a system like Henry Richard's, using the NPC's message to determine the direction.

Re: LunaLua Offical Thread - SMBX Usermod Framework

Posted: Thu Dec 10, 2015 6:52 pm
by HenryRichard
TheSaturnyoshi wrote:
lotus006 wrote:Cool about the birdo egg it's working to kill Npcs now :D Nice :P
Also I need to found how to make ill use now the Larry Ring but how I can
make it's ring moving in any direction I want like he do any idea ? (the id is 269)
(not just right and left, in diagonal also)
Easy, set its x and y speeds.
However, if you want to be able to place it in the level, I would suggest using a system like Henry Richard's, using the NPC's message to determine the direction.
One thing to note is that if you want to make it move diagonally at the same speed it moves horizontally/vertically, you'll probably want to use some basic trigonometry. This works okay:

Code: Select all

		local angle = 45;
		local length = 4;

		v.speedX = math.sin(angle * (math.pi / 180)) * length;
		v.speedY = math.cos(angle * (math.pi / 180)) * length;
...where angle is the angle (big surprise), length is the speed it moves, and v is the NPC.

EDIT: What's the best way to add animation frames to the player? I could use Graphics.drawImageToScene, but that makes the player render in front of everything, which is bad.

Re: LunaLua Offical Thread - SMBX Usermod Framework

Posted: Thu Dec 10, 2015 11:02 pm
by lotus006
HenryRichard wrote:
TheSaturnyoshi wrote:
lotus006 wrote:Cool about the birdo egg it's working to kill Npcs now :D Nice :P
Also I need to found how to make ill use now the Larry Ring but how I can
make it's ring moving in any direction I want like he do any idea ? (the id is 269)
(not just right and left, in diagonal also)
Easy, set its x and y speeds.
However, if you want to be able to place it in the level, I would suggest using a system like Henry Richard's, using the NPC's message to determine the direction.
One thing to note is that if you want to make it move diagonally at the same speed it moves horizontally/vertically, you'll probably want to use some basic trigonometry. This works okay:

Code: Select all

		local angle = 45;
		local length = 4;

		v.speedX = math.sin(angle * (math.pi / 180)) * length;
		v.speedY = math.cos(angle * (math.pi / 180)) * length;
...where angle is the angle (big surprise), length is the speed it moves, and v is the NPC.

EDIT: What's the best way to add animation frames to the player? I could use Graphics.drawImageToScene, but that makes the player render in front of everything, which is bad.
Thanks for both, I will check soon :) sorry for the late reply

Re: LunaLua Offical Thread - SMBX Usermod Framework

Posted: Fri Dec 11, 2015 2:49 pm
by lotus006
LOL thnx again guys @HenryRichard & @ TheSaturnyoshi for the help ! ;) :P

Now I have my Spread S powerups in SMBX !!! haha , I love to much LunaLua !!
But when to much bullets the game slow too much, I think is because about colliders api on my bullets
need to find a way without this !


Re: LunaLua Offical Thread - SMBX Usermod Framework

Posted: Fri Dec 11, 2015 7:31 pm
by HenryRichard
I found a bug: If you replace an effect with a .png, it doesn't automatically resize.

Re: LunaLua Offical Thread - SMBX Usermod Framework

Posted: Fri Dec 11, 2015 7:57 pm
by Willhart
HenryRichard wrote:I found a bug: If you replace an effect with a .png, it doesn't automatically resize.
That happens with some backgrounds too, especially when they are larger than original. I remember that placing a mask gif file of correct size should work as a temporary fix. It will tell the size of the sprite to the editor, but also be overridden by the png's graphics.

Re: LunaLua Offical Thread - SMBX Usermod Framework

Posted: Fri Dec 11, 2015 9:55 pm
by HenryRichard
Willhart wrote:That happens with some backgrounds too, especially when they are larger than original. I remember that placing a mask gif file of correct size should work as a temporary fix. It will tell the size of the sprite to the editor, but also be overridden by the png's graphics.
I guess I could do that if I had to.

I'm still wondering about adding more frames to a character - It'd be weird if my Kirby playable didn't open his mouth when he inhaled.

Re: LunaLua Offical Thread - SMBX Usermod Framework

Posted: Sat Dec 12, 2015 8:53 am
by Destiny
So, I'm having an issue.
Always when I install LunaLua, I can run it normally, but only one single time. After that, if I try to run it, I always get this error:

"Instruction at 0x7295efa8 referenced memory at 0x514100dd. The memory could not be read."

I know it may be due to my PC being old, but I just wanna know why.

Re: LunaLua Offical Thread - SMBX Usermod Framework

Posted: Sat Dec 12, 2015 12:18 pm
by Kevsoft
Looks like an issue with the vb6 virtual machine. Which OS do you use?

Re: LunaLua Offical Thread - SMBX Usermod Framework

Posted: Sat Dec 12, 2015 12:40 pm
by Destiny
Kevsoft wrote:Looks like an issue with the vb6 virtual machine. Which OS do you use?
Win XP. I can't upgrade it due to not having the specs to install the others.

Re: LunaLua Offical Thread - SMBX Usermod Framework

Posted: Sat Dec 12, 2015 12:58 pm
by Kevsoft
Which Service Pack? Newer ones may include newer version of the vb6 virtual machine.

Also "only one single time": Do you mean only one single time after reboot, or one single time after installation?

Re: LunaLua Offical Thread - SMBX Usermod Framework

Posted: Sat Dec 12, 2015 1:04 pm
by Destiny
Kevsoft wrote:Which Service Pack? Newer ones may include newer version of the vb6 virtual machine.
Service Pack 3.
Kevsoft wrote:Also "only one single time": Do you mean only one single time after reboot, or one single time after installation?
I mean, I was able to open it multiple times, but after a short period of time, the error started appearing.

Re: LunaLua Offical Thread - SMBX Usermod Framework

Posted: Sun Dec 20, 2015 12:18 pm
by ShadowStarX
Guys, can I get the script for vertical wrap? (basically if you fall down on the bottom you'll continue falling on the top)
Thanks.

Re: LunaLua Offical Thread - SMBX Usermod Framework

Posted: Sun Dec 20, 2015 2:00 pm
by Lukas Old Account
Welp, kind of stuck writing a lua code. I tried to but ofcourse i failed. So i wanted to ask here;
"Is there by any chance a way to let rinka or volcano lotus spawn their fireballs in circles? Just wondering..."

Re: LunaLua Offical Thread - SMBX Usermod Framework

Posted: Sun Dec 20, 2015 3:23 pm
by Emral
ShadowStarX wrote:Guys, can I get the script for vertical wrap? (basically if you fall down on the bottom you'll continue falling on the top)
Thanks.
From Level 1 in Halloween Hypnosis:
http://hastebin.com/anemeketas.lua

Re: LunaLua Offical Thread - SMBX Usermod Framework

Posted: Sun Dec 20, 2015 3:36 pm
by HenryRichard
I'd advise using this modification, as it will work with both players.

Code: Select all

function onLoop()
        -- set up for section 4
	NPCs = NPC.get({--[[table of npcs you want to wrap]]}, 3)
	for i=1,table.getn(bobombx) do
		if (bobombx[i].y >= -140000) then
			bobombx[i].y = -140632
		end
	end
	if (player.section == 3 and player.y > -139950) then
		player.y = -140666
	end
	if(player2) then
		if (player2.section == 3 and player2.y > -139950) then
			player2.y = -140666
		end
	end
end

Re: LunaLua Offical Thread - SMBX Usermod Framework

Posted: Sun Dec 20, 2015 3:56 pm
by lotus006
I found this also on talkhaus I recently used it and worked perfectly, but maybe need modification for all players also , enjoy :D

Code: Select all

function onLoop()
   local sectBottom = player.sectionObj.boundary.bottom
   local sectTop = player.sectionObj.boundary.top

   if (player.speedY > 0) then
      if (player.y > sectBottom) then
         --bottom to top
         player.y = sectTop - 48
      end
   elseif (player.speedY < 0) then
      if (player.y < sectTop - 48) then
         --top to bottom
         player.y = sectBottom
      end
   end
end