player-specific graphics

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?
Gaming-Dojo
Monty Mole
Monty Mole
Posts: 124
Joined: Mon Jan 25, 2016 9:20 am
Pronouns: he/him
Contact:

player-specific graphics

Postby Gaming-Dojo » Sat Jan 07, 2017 1:48 pm

Is it possible make npcs look different depending on the chatracter you use (like the SM3DW Propeller and Cannon Blocks) by using luna lua?Excuse me and move, please if it's in the wrong forum as I wasn't sure whether to put it here or in help and support.
Over that it would be good to know if you can change the hud elements for certain characters (esp. life counter).

krakin
Reznor
Reznor
Posts: 2920
Joined: Sun Dec 11, 2016 8:02 pm
Flair: cats are cool
Pronouns: he/him/his
Contact:

Re: player-specific graphics

Postby krakin » Sat Jan 07, 2017 1:57 pm

yoshiegg wrote:Is it possible make npcs look different depending on the chatracter you use (like the SM3DW Propeller and Cannon Blocks) by using luna lua?
Do you mean something like a Cat Goomba? Giving a goomba a custom graphic to make it a cat? If yes, I think it is.

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

Re: player-specific graphics

Postby Emral » Sat Jan 07, 2017 2:01 pm


Gaming-Dojo
Monty Mole
Monty Mole
Posts: 124
Joined: Mon Jan 25, 2016 9:20 am
Pronouns: he/him
Contact:

Re: player-specific graphics

Postby Gaming-Dojo » Sat Jan 07, 2017 2:04 pm

practicalshorty014 wrote: Do you mean something like a Cat Goomba? Giving a goomba a custom graphic to make it a cat?.
I actually mean the propeller and cannon blocks which are orange/ black whan unused by the player, red when Mario uses them, green for Luigi, pink for Peach, blue for Toad and cyan/turquoise when you play Rosalina

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

Re: player-specific graphics

Postby Emral » Sat Jan 07, 2017 2:07 pm

Uhh then you're better off including all the colours in your npc graphics file and changing the offset based on the character of the player holding the object.

Gaming-Dojo
Monty Mole
Monty Mole
Posts: 124
Joined: Mon Jan 25, 2016 9:20 am
Pronouns: he/him
Contact:

Re: player-specific graphics

Postby Gaming-Dojo » Sat Jan 07, 2017 3:44 pm

Sorry but I don't get it.Could you give an example?However, your last tip sounded quie logic to me so I wrote this code which created the following error message : ... /lunaworld.lua 3: "=" expected near "Mario": if player.character==Character_Mario then

Code: Select all

Graphics.sprites.npc[278].img = Propeller block Mario
end
if player.character==Character_Luigi then
Graphics.sprites.npc[278].img = Propeller block Luigi
end
if player.character==Character_Peach then
Graphics.sprites.npc[278].img = Propeller block Peach
end
if player.character==Character_Toad then
Graphics.sprites.npc[278].img = Propeller block Toad
end
Am I on the correct track with that and have just made a minor mistake in my code or would this code do ssomething completely different if it actually worked?

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

Re: player-specific graphics

Postby Emral » Sat Jan 07, 2017 3:50 pm

yoshiegg wrote:Sorry but I don't get it.Could you give an example?However, your last tip sounded quie logic to me so I wrote this code which created the following error message : ... /lunaworld.lua 3: "=" expected near "Mario": if player.character==Character_Mario then

Code: Select all

Graphics.sprites.npc[278].img = Propeller block Mario
end
if player.character==Character_Luigi then
Graphics.sprites.npc[278].img = Propeller block Luigi
end
if player.character==Character_Peach then
Graphics.sprites.npc[278].img = Propeller block Peach
end
if player.character==Character_Toad then
Graphics.sprites.npc[278].img = Propeller block Toad
end
Am I on the correct track with that and have just made a minor mistake in my code or would this code do ssomething completely different if it actually worked?
1) constants are in all caps: "CHARACTER_MARIO"
2) Propeller block Luigi makes no sense. You have to pass it a luaimageresource. A file returned by Graphics.loadImage(string filename)
3) your 2nd post made me realise GraphicsOverride is not the way to do this. Instead, you could have a sprite much like a standard smbx spritesheet, where frames are in the same column but in different rows.
The idea here is to have 1 column for each playable inserted to the right of that or repeat everything in a different colour below.
NPC Offset 0x12C returns which player is holding the NPC. If it's being held you can adjust the NPC's Animation Frame to suit the colour you need.
A different way to draw them which circumvents complex animationFrame setting and stuff is just setting that and the animationTimerinto oblivion and using Graphics.drawImageToSceneWP to draw a custom image at the position of the now invisible NPC.

Gaming-Dojo
Monty Mole
Monty Mole
Posts: 124
Joined: Mon Jan 25, 2016 9:20 am
Pronouns: he/him
Contact:

Re: player-specific graphics

Postby Gaming-Dojo » Sat Jan 07, 2017 4:15 pm

Thank you.I think I mostly got it now but how do I specify which npc should be affected by the lua code? Furthermore, I also wonder if this would also work for the new 2.0 chars and other graphics like e.g. blocks or tiles on the world map?
Update: My spritesheet for npc-278 looks like that now: Image So now I think I can proceed with writing the code. However, I don't know how to do the frame setup in the code.Over that, I want to know if the npc offset uses numbers (eg. 1 for Mario) or letters (CHARACTER_MARIO) to define the player holding the object.

Sambo
Snifit
Snifit
Posts: 211
Joined: Fri Jan 24, 2014 6:43 pm

Re: player-specific graphics

Postby Sambo » Wed Jan 11, 2017 12:22 am

Code: Select all

Graphics.sprites.npc[278].img = Propeller block Mario
end
if player.character==Character_Luigi then
Graphics.sprites.npc[278].img = Propeller block Luigi
end
if player.character==Character_Peach then
Graphics.sprites.npc[278].img = Propeller block Peach
end
if player.character==Character_Toad then
Graphics.sprites.npc[278].img = Propeller block Toad
end
There's a glaring problem with this code that somehow went unnoticed. You're trying to use variable names with spaces in them. You can't do that. Lua will recognize "Propeller block Mario" as 3 separate variables and get confused as to what you want it to do with them. This is what's causing your error. You should replace the spaces with underscores or just remove them and use camelCase in the names (i.e. "propeller block Mario" becomes "propellerBlockMario")
Also, just an FYI, capitalizing the first letter of your variable names is usually considered bad naming convention. They should generally start with lowercase letters.
yoshiegg wrote:Thank you.I think I mostly got it now but how do I specify which npc should be affected by the lua code? Furthermore, I also wonder if this would also work for the new 2.0 chars and other graphics like e.g. blocks or tiles on the world map?
You would use this in onDraw (since this needs custom images to be drawn):

Code: Select all

for k,v in pairs (NPC.get(278, -1)) do
	-- You would put the code you want to apply to the propeller block here
end
World map stuff is a bit less developed in LunaLua, so I'm not sure if this would work on world map graphics so well. I don't really know how the new characters work, but I don't think they use the same ID system as vanilla SMBX characters.
yoshiegg wrote:So now I think I can proceed with writing the code. However, I don't know how to do the frame setup in the code.Over that, I want to know if the npc offset uses numbers (eg. 1 for Mario) or letters (CHARACTER_MARIO) to define the player holding the object.
You should override the Propeller block's image with a blank one, then add a column to your image for each player who uses it. (You may want to add another row onto the front of your image for when no one is holding it)
Then, you need to use DrawImageToSceneWP to draw your image. Use the version with the sourceX, sourceY, width, and height arguments to draw only the part of the image that should be shown.
CHARACTER_MARIO is a constant that equals 1, so either way would be the same.

You seem to be fairly new to Lua, so you might want to look at some tutorials for anything you don't understand.


Return to “LunaLua”

Who is online

Users browsing this forum: No registered users and 1 guest

SMWCentralTalkhausMario Fan Games GalaxyKafukaMarioWikiSMBXEquipoEstelari