Adding entities (Powerups to be exact).

Mods, guides how to use and install mods go right in here.
Post Reply
User avatar
alesan99
Posts: 2335
Joined: 30 May 2013, 21:42
Contact:

Post » 03 Aug 2013, 19:48

I'm making some powerups that replace the fire flower.
Check them out!
But I want to make them into separate powerups mostly because fire bars use the same sprite as fireballs. Then I think to my self, "Well that's simple, all I have to do is make a copy of flower.lua and fireball.lua and it's all ready!". I was way wrong. Turns out you have to add code in editor.lua, variables.lua, main.lua, entities.lua,add more mario colors, and etc. I've tried this before (with a custom enemy 100% functional) , all I did is add the .lua file, add some code to editor , and added the sprite to the entities.png (obviously added the enemy's sprite). Doesn't Work.

So here is were I need help, can somebody please tell me what code to put and where to put it so the entity is usable and spawnable .

If not fell free to tell me it's too hard for a person like me.

User avatar
Sky
Posts: 1283
Joined: 08 Mar 2012, 04:35
Contact:

Post » 03 Aug 2013, 20:08

Turtle95 managed it in his Extra Entities mod; if you study his code you might be able to figure it out (assuming someone doesn't give you a better answer than mine).

This looks really cool, by the way. Just in case you didn't already know that.

User avatar
Superjustinbros
Posts: 2119
Joined: 29 Mar 2012, 20:39
Contact:

Post » 03 Aug 2013, 20:26

If the bombs had similar functions to the ones from the Kirby series (such as Super Star's) including bigger blasts, I'd consider it quite effective, but now it's just a fireball with a black shell that arcs downward and only works at close range. The Hammer suit looks good, though. If you want a bit of advice, you could make the Hammer Mario palette have a light grey hat with dark grey hair, while Bomb Mario would be a dark grey hat with black hair.

User avatar
alesan99
Posts: 2335
Joined: 30 May 2013, 21:42
Contact:

Post » 03 Aug 2013, 21:09

Superjustinbros wrote:If the bombs had similar functions to the ones from the Kirby series (such as Super Star's) including bigger blasts, I'd consider it quite effective, but now it's just a fireball with a black shell that arcs downward and only works at close range. The Hammer suit looks good, though. If you want a bit of advice, you could make the Hammer Mario palette have a light grey hat with dark grey hair, while Bomb Mario would be a dark grey hat with black hair.
Well with the bombs I plan on making bigger blast and have a exploding delay, for now the bombs are a failed hammer because I changed the fireball's bounce force to -5 thinking it would go downwards but instead it didn't bounce at all.
Oh and the Hammer mario colors are inspired by Newer Super Mario bros. wii's, a NewSMBWii hack, hammer powerup colors.

But I need help right now adding entities, i'm going to make a separate thread for the mod.

User avatar
Turtle95
Posts: 1246
Joined: 21 Mar 2012, 21:48
Contact:

Post » 03 Aug 2013, 21:37

alesan99 wrote:I'm making some powerups that replace the fire flower.
Check them out!
But I want to make them into separate powerups mostly because fire bars use the same sprite as fireballs. Then I think to my self, "Well that's simple, all I have to do is make a copy of flower.lua and fireball.lua and it's all ready!". I was way wrong. Turns out you have to add code in editor.lua, variables.lua, main.lua, entities.lua,add more mario colors, and etc. I've tried this before (with a custom enemy 100% functional) , all I did is add the .lua file, add some code to editor , and added the sprite to the entities.png (obviously added the enemy's sprite). Doesn't Work.

So here is were I need help, can somebody please tell me what code to put and where to put it so the entity is usable and spawnable .

If not fell free to tell me it's too hard for a person like me.
Well to do custom entities all you do is modify entity.lua, game.lua, and add the new *.lua file that you code. However, powerups are a bit more complex. You can also add custom mario colors, and you'd need to set Mario's size when he collides with the item. For example,

Code: Select all

function hammerpowerup:leftcollide(a, b)
if a == "mario" then
b:grow()
b.size = 4
end
end
Although it would be useful to make one big *.lua file called custompowerups.lua and pass a parameter to it, telling you which variant it is. Something like:

Code: Select all

function powerups:init(x, y, t)
 self.x = x
 self.y = y
 self.type = t or "hammersuit"
end
Just be sure you check the types in :update for the file, otherwise it won't work properly (trust me, I did that a long ways back in my mod, and it wasn't good). To pass parameters you'd have to find the item function in game.lua:

Code: Select all

function item(i, x, y, size)
 ... check for normal powerups ...
 if size > 1 and size and i ~= "flower" and i ~= "mushroom" then
  table.insert(powerupstable, powerup:new(x, y, map[x][y][2]) --returns the type of the entity placed on the map as long as it's not a flower or 'shroom
 end
end
I haven't tested that, but it should work, rather than doing fancy rightclicks.

If you have any questions, just PM me.

User avatar
alesan99
Posts: 2335
Joined: 30 May 2013, 21:42
Contact:

Post » 03 Aug 2013, 23:07

Turtle95 wrote:
Well to do custom entities all you do is modify entity.lua, game.lua, and add the new *.lua file that you code. However, powerups are a bit more complex. You can also add custom mario colors, and you'd need to set Mario's size when he collides with the item. For example,

Code: Select all

function hammerpowerup:leftcollide(a, b)
if a == "mario" then
b:grow()
b.size = 4
end
end
Although it would be useful to make one big *.lua file called custompowerups.lua and pass a parameter to it, telling you which variant it is. Something like:

Code: Select all

function powerups:init(x, y, t)
 self.x = x
 self.y = y
 self.type = t or "hammersuit"
end
Just be sure you check the types in :update for the file, otherwise it won't work properly (trust me, I did that a long ways back in my mod, and it wasn't good). To pass parameters you'd have to find the item function in game.lua:

Code: Select all

function item(i, x, y, size)
 ... check for normal powerups ...
 if size > 1 and size and i ~= "flower" and i ~= "mushroom" then
  table.insert(powerupstable, powerup:new(x, y, map[x][y][2]) --returns the type of the entity placed on the map as long as it's not a flower or 'shroom
 end
end
I haven't tested that, but it should work, rather than doing fancy rightclicks.

If you have any questions, just PM me.

Code: Select all

function My brain is about to collapse,
 b:can't stand seeing that blue screen then
 else if I'm too dumb for this stuff
end
But seriously, I've tried and tried and come to the conclusion that I'm not a good coder. I can only change existing stuff. I'm going to leave the mod as it is and go to sleep.

Post Reply