Coding Help

Mods, guides how to use and install mods go right in here.
Post Reply
HarrisonCrow
Posts: 3
Joined: 04 Dec 2012, 10:26

Post » 04 Dec 2012, 10:31

As far as coding goes, I'm fairly novice. With that in my mind, I was doing a bit of tinkering with some source and just needed a little nudge in the right direction for my project. Currently I'm trying to make the PC not change to the big animations when the player grabs one of the many power-ups in game. If you could lend me a bit of help on where to take out or edit code sections, I'd certainly appreciate it.

Update:
Alright well now I've run into another problem. I was attempting to bundle together a couple of my favorite mods and was attempting to move the Samus sprite sheet over into another mod and it seems to want to be stubborn and continue to show me Mario. Any help on this matter would be appreciated as well.

User avatar
BobTheLawyer
Posts: 2232
Joined: 01 May 2012, 21:00

Post » 04 Dec 2012, 22:26

Why would you not want to grow?
Anyways, Mario.lua: Delete Lines 782 to 793 (idk about the return, try once without deleting then if that messes up, try deleting) Delete 742 to 778 (same thing with the return)

For the graphics, replace the graphics folder with the one in the mod you want the mario sprites in. If you do not want all sprites, but just mario, graphics folder, smb, replace player folder.
You can also replace minecraft folder.

HarrisonCrow
Posts: 3
Joined: 04 Dec 2012, 10:26

Post » 05 Dec 2012, 04:21

Well to be specific I don't want Mario to use the grown sprites because I prefer his smaller sprite and just replacing the bigmario animations with the marioanimations causes some graphic distortions. I'm just seeking a way to have the sprite not change while retaining the ability to take a hit. Also I'm thinking of expanding on this and creating my own sprite swap, just wondering if you'd like to give me some pointers when I whip up a small example of the sprite sheet. Thanks for the help.

Update: Tried both ways, Mario hits the mushroom blocks and the same graphic distortion happens only now he's frozen. Any other ideas?

Update2: I'm not sure quite exactly what I changed this time to get it working, but the sprite swap worked. Now if I can get the proper rights from the owners, players can enjoy being Samus and having a jetpack.

User avatar
BobTheLawyer
Posts: 2232
Joined: 01 May 2012, 21:00

Post » 05 Dec 2012, 13:58

Here's what you'll be looking for (in mario.lua):

Code: Select all

elseif self.animation == "grow1" then
		self.animationtimer = self.animationtimer + dt
		--set frame lol
		local frame = math.ceil(math.mod(self.animationtimer, growframedelay*3)/growframedelay)
		self:updateangle()

		if frame == 3 then
			self.animationstate = "idle"
			self.graphic = self.biggraphic
			self:setquad("idle")
			self.quadcenterY = 20
			self.quadcenterX = 9
			self.offsetY = -3
		else
			self.graphic = self.smallgraphic
			self.quadcenterX = 11
			self.offsetY = 3
			if frame == 2 then
				self.animationstate = "grow"
				self:setquad("grow", 1)
				self.quadcenterY = 4
			else
				self.animationstate = "idle"
				self:setquad(nil, 1)
				self.quadcenterY = -2
			end
		end

		if self.animationtimer - dt < growtime and self.animationtimer > growtime then
			self.animationstate = self.animationmisc
			self.animation = false
			noupdate = false
			self.quadcenterY = 20
			self.graphic = self.biggraphic
			self.animationtimer = 0
			self.quadcenterX = 9
			self.offsetY = -3
		end
		return
ctrl+f and search grow1 and you'll find it.

Then git rid of everything I cross off here and add what I bold:


elseif self.animation == "grow1" then
self.animationtimer = self.animationtimer + dt
--set frame lol
local frame = math.ceil(math.mod(self.animationtimer, growframedelay*3)/growframedelay)
self:updateangle()

if frame == 3 then
self.animationstate = "idle"
self.graphic = self.biggraphic self.smallgraphic
self:setquad("idle")
self.quadcenterY = 20
self.quadcenterX = 9
self.offsetY = -3
else
self.graphic = self.smallgraphic
self.quadcenterX = 11
self.offsetY = 3
if frame == 2 then
self.animationstate = "grow"
self:setquad("grow", 1)
self.quadcenterY = 4
else
self.animationstate = "idle"
self:setquad(nil, 1)
self.quadcenterY = -2
end
end

if self.animationtimer - dt < growtime and self.animationtimer > growtime then
self.animationstate = self.animationmisc
self.animation = false
noupdate = false
self.quadcenterY = 20[/del}
self.graphic = self.biggraphic self.smallgraphic
self.animationtimer = 0
self.quadcenterX = 9
self.offsetY = -3

end
return


Do that, then you will need to find this:

Code: Select all

function mario:grow()
	self.animationmisc = self.animationstate
	if self.animation and self.animation ~= "invincible" then
		return
	end
	addpoints(1000, self.x+self.width/2, self.y)
	playsound(mushroomeatsound)

	if bigmario then
		return
	end

	if self.size > 2 then

	else
		self.size = self.size + 1
		if self.size == 2 then		
			self.y = self.y - 12/16
			self.height = 24/16
		elseif self.size == 3 then
			self.colors = flowercolor
		end

		if self.size == 2 then
			self.animation = "grow1"
		else
			self.animation = "grow2"
		end

		self.drawable = true
		self.invincible = false
		self.animationtimer = 0
		noupdate = true
	end
end
Make it:

function mario:grow()
self.animationmisc = self.animationstate
if self.animation and self.animation ~= "invincible" then
return
end
addpoints(1000, self.x+self.width/2, self.y)
playsound(mushroomeatsound)

if bigmario then
return
end

if self.size > 2 then

else
self.size = self.size + 1
if self.size == 2 then
self.y = self.y - 12/16
self.height = 24/16

elseif self.size == 3 then
self.colors = flowercolor
end

if self.size == 2 then
self.animation = "grow1"
else
self.animation = "grow2"
end

self.drawable = true
self.invincible = false
self.animationtimer = 0
noupdate = true
end
end


Try that.
Tell me how it works!
What I did was getting rid of all the functions that change Mario's size and offsets for graphics.
EDIT: Mind some exceptions...

HarrisonCrow
Posts: 3
Joined: 04 Dec 2012, 10:26

Post » 07 Dec 2012, 04:22

Still nothing, I can move though so it's more progress since the last edit. I'll keep tinkering and let you know. Also whipped up the sprite sheet, it's not finished I have to adjust the portal gun.

User avatar
BobTheLawyer
Posts: 2232
Joined: 01 May 2012, 21:00

Post » 07 Dec 2012, 13:35

HarrisonCrow wrote:Still nothing, I can move though so it's more progress since the last edit. I'll keep tinkering and let you know. Also whipped up the sprite sheet, it's not finished I have to adjust the portal gun.
Upload what you have so far

Post Reply