Jump to content

Modded Skins (API)


Fidooop
 Share

Recommended Posts

Hello, modders and skin fanatics alike!

After a very long time working on it, I'm happy to announce a brand new mod API that allows one to create their very own skins for their modded characters and items! You can find the mod on the Steam Workshop here: http://steamcommunity.com/sharedfiles/filedetails/?id=835602689

WARNING:
This mod is only to be used to create skins for modded characters/items. Klei strongly forbids the use of modders creating skins for any official character/item. If any mod is found using code from this mod in order to skin official characters/items it will be reported on sight. 

How To Use:

Spoiler

SKINNING CHARACTERS:

The first thing you'll want is the 'MakeModCharacterSkinnable' function. (Which is a GLOBAL function) It must be called in the modmain and has to be called after 'AddModCharacter' is run.
MakeModCharacterSkinnable only has one argument which is the mod character's prefab name.

Now that the mod character is skinnable you can now add skins. 'AddModCharacterSkin' will create a skin prefab for the character and return it. It must be called within a prefab file.
AddModCharacterSkin's arguments are as follows: prefab, skin, skins, assets, tags, options

  • prefab = Mod character's prefab name.
  • skin = The skin being added. ("formal", "survivor", "shadow", etc.)
  • skins = A table of skinstates and the corrisponding builds. Example: {normal_skin = "charactername", ghost_skin = "ghost_charactername_build"}
  • assets = A table provided with names of builds used for this skin. Example: {"charactername", "ghost_charactername_build"}
  • tags = Tags for this skin. Example: {"CHARACTERNAME", "FORMAL"}
  • options = A table filled with various options that are all optional extras for the skin.
     options.starting_inv_skins = If a mod character's starting inventory items have skins that match this skin then this table can be used to swap out the inventory on spawn. (ONLY WORKS ON MODDED ITEMS.)
       The skin name string can be replaced by a function if there needs to be any special code run when replacing the original item. (Original item will be deleted by the time this function runs and the replacement needs to be spawned using this function)
        Arguments supplied to this function when it runs are: player, playerskin
             player = The player whose inventory is being replaced by skinned items
             playerskin = Said player's skin name ("formal", "survivor", etc.)
     options.avatarset = The name of a custom avatar set for this skin. (Changes out "avatar_charactername", "self_inspect_charactername", etc. with "avatar_avatarset", etc.)
     options.uiname = The name of a custom uiname image. (The dark gray one found in character select and when a character is examined.) When this skin is equipped it will switch the uiname image out for this one.
     options.gender = A gender change for this skin specifically. If one were to make a robotic skin or genderswap skin then this option will help out in doing so.

    Example of how to use the options argument:
        {
            starting_inv_skins = {customitem = "robotic"},
            avatarset = "roboticcharactername",
            uiname = "names_roboticcharactername",
            gender = "ROBOT"
        }

    
SKINNING ITEMS:

To add a skin for an item the function needed is 'AddModItemSkin'. It must be called in a prefab since it creates a prefab for the item.
AddModItemSkin's arguments are as follows: item, skin, fn, assets, atlas, image, placer, baseitem_atlas

  • item = The item's prefab name.
  • skin = The skin being added.
  • fn = The item/skin's prefab function. ('AddModItemSkin' creates an entirely new prefab and will need a function. Best way to do this is use the same function from the original item and have various values change based on what skin is being made)
  • assets = The skin's assets.
  • atlas = The skin's inventory image atlas. (Used in the crafting menu)
  • image = The skin's inventory image. (Used in the crafting menu)
  • placer = If this item comes with a placer then the placer argument can either be set to true or be a table and will build a placer prefab.
        If set to true the function will build a placer with the build and bank both being item.."_"..skin and the anim being "placer".
        If set to a table (the table keys/values must be {bank = "", build = "", anim = ""}) the function will create a placer with the bank, build, and anim being what is set in the table.
        If 'AddModItemSkin' is called without the placer argument it will return just the skin prefab.
        If 'AddModItemSkin' is called with the placer argument it will return both the skin prefab and the skin's placer.
  • baseitem_atlas = The default item's inventory image atlas. (Only needed if the default item's prefab name varies from its atlas name)


EXTRA FUNCTIONALITY:

If some changes need to be applied to a character skin there are two functions that get run whenever skins get changed.
inst.OnChangeModdedSkin gets run on the server. Arguments are as follows: inst, skin, newspawn
inst = the character, skin = skin name ("formal", "survivor", etc.) newspawn = true if it is a brand new spawn on the server.
inst.OnChangeModdedSkinClient gets run on the client side. It gets the same arguments as 'OnChangeModdedSkin' but without 'newspawn'
The event "onchangemoddedskin" also gets pushed on both the client and the server with data providing the name of the skin that has just been equipped.

To spawn a skinned item you can only do it like this:
SpawnPrefab("item", "skin")


Very special thanks to:
@Kzisor who's Additional Dressware mod inspired the creation of this mod!
@Dudedude who helped out with the assets.
@PeterA who walked me through a lot of the Dos and Don'ts so that I wasn't stepping over any lines! :)
@Blueberrys who made the Persistant Data module that helped make this possible. Can be found here: 

 

For anyone wanting to skin their modded characters here are the skin portrait backgrounds!

Spoiler

Guest of Honor
frame_formal.png

Survivor
frame_survivor.png

Triumphant
frame_shadow.png

Roseate
frame_rose.png

Halloween 2016
frame_halloween.png

 

Some frequently asked questions: (If you have any more questions post them down below! I'll reply as soon as I can!)

Can I skin Wilson or any other official character?
No, Peter has told me to make sure that everybody is very aware that this is off limits... We've been given a gift so let's not squander it! ;)

How do I use it?
The tutorial is up above! It has all the usable functions inside and how to use them! Please don't rip the code and put it in your mod through... Make sure that when you upload your mod you add this mod as a required item. (It is set up this way so that the same code doesn't run multiple times if someone has multiple mods that have skins!)

What is an API?
An API (Application Programming Interface) is a set of functions which allows you to use advanced techniques without having to write your own code or copy/paste the code in your mod... In order to use this API you must add this mod as a requirement on your mods workshop page.

Can I make clothing?
No, that is off limits. (and it'd also require a lot of extra code that is not supplied within the mod...)

I found a mod that skins official items/characters! What should I do?
If it is not the playable pets mod (They technically have the go-ahead to skin the playable mobs) then please immediately report it! We don't want to force Klei's hand and have Modded Skins shut down.

What if I made a rip-off character of one of the official characters and skinned that?
Still off limits because it is still Klei's character. (even after you change one letter in the name) So this is also prohibited and must be reported if anyone is found doing this!

Can this be used to give myself official skins?
At the moment I'm more than certain that this is impossible... However, if a way is found to do this using my mod then it's more a fault of Klei's (for leaving a hole in skin restrictions) and not mine because all I did was some UI hacking.

What mods are currently using this to make skins?
Check out @Chris1488's Modded Skins thread! He's going to try his best to stay on top of what mods get skins and he'll be updating his thread whenever he possibly can!

Is mayonnaise an instrument?
I'm... not entirely sure? I guess you could make a song using only sounds made by a tub of mayonnaise... But then again you could technically do that with almost everything! So I propose a counter-question. Does that mean that everything is an instrument?

Edited by Fidooop
  • Like 25
  • Thanks 2
Link to comment
Share on other sites

3 minutes ago, Chris1488 said:

I can probably guess the answer, but this rule also applies to mods of the SW characters, right?

I'm fairly certain it does because as halfrose said, they are official characters... :p

  • Like 1
Link to comment
Share on other sites

47 minutes ago, Fidooop said:

Are you going to add a Mod Made rarity section to your skins thread? xD

Hm...y'know, I just might be able to handle that! A separate thread in the Mods section showing off any and all skins for mods and their respective creators. I just need a little help with the mod makers themselves, of course. :p 

EDIT: I may have gotten myself too excited...

Erik:

Goh Erik Portrait.pngMod_Erik_Racquet_GoH.pngMod_Erik_Ball_GoH.png [GoH Set]

Edited by Chris1488
  • Like 6
Link to comment
Share on other sites

This seems really nice, i'll probably try it a day.

 

On 06/01/2017 at 0:17 AM, Fidooop said:

Can I make clothing?
No, that is off limits. (and it'd also require a lot of extra code that is not supplied within the mod...)

What is clothing exactly, i don't understand ? Skin for armor/hat ? Something else ?

 

Also, it is possible to give special condition for a skin to appears ?

Link to comment
Share on other sites

41 minutes ago, Lumina said:

Ok, thanks for the answer :) It's because even if the character isn't a klei character, since there are clothing from klei you don't want the mod to be in "conflict" with official skin is it this ?

To clear the air a bit more... Equippables are completely fine to reskin! (Not official equippables however) What I mean by clothing are the items here below the head:

5B63D72A2145F0F95D0460EDB17DC2B7D3C9C8E4

And it isn't a compatibility issue! It's just that Peter had told me that making clothes was off limits to us modders. :p

 

17 minutes ago, neal_b4_me said:

Which file in which folder am I inserting ' MakeModCharacterSkinnable' into? Also what folder in general am I modifying? The one that came in this particular mod folder?

MakeModCharacterSkinnable goes into your mod's modmain.lua after the AddModCharacter function has been run! Please don't modify anything in the Modded Skins folder, only your own mod. (and please do not copy anything from the modded skins mod into your own mod) Every needed function to create skins for your mod are available in the global space once Modded Skins is enabled! All you've got to do is create the skin prefabs in your mod's prefabs folder! :p

  • Like 1
Link to comment
Share on other sites

1 minute ago, Fidooop said:

And it isn't a compatibility issue! It's just that Peter had told me that making clothes was off limits to us modders. :p

Yeah, sorry, didn't use the right word, by conflict i was meaning more like "competition"/"concurrence", rather than compatibility.

Thanks for your answer :)

Link to comment
Share on other sites

On 1/5/2017 at 6:17 PM, Fidooop said:

This mod is only to be used to create skins for modded characters/items. Klei strongly forbids the use of modders creating skins for any official character/item. If any mod is found using code from this mod in order to skin official characters/items it will be reported on sight. 

 

Including Shipwrecked characters ported mods?

Link to comment
Share on other sites

24 minutes ago, Devinxh04 said:

Including Shipwrecked characters ported mods?

 

On 1/5/2017 at 5:47 PM, Fidooop said:
On 1/5/2017 at 5:40 PM, Chris1488 said:

I can probably guess the answer, but this rule also applies to mods of the SW characters, right?

I'm fairly certain it does because as halfrose said, they are official characters... :p

 

Link to comment
Share on other sites

1 minute ago, NeddoFreddo said:

So we can't make skins for Klei-made objects? Darn, that sucks, I was looking forward to seeing the fabled Microwave on a Stool skin for the Crock Pot!

....You could make a custom crockpot with the same exact code and have it use a microwave-on-stool art though! Just as long as it isn't considered a "skin" and isn't using the skin system then you're completely fine! :p

  • Like 1
Link to comment
Share on other sites

Ok i tried to make something but i got mistakes. I'm sure some of them are obvious but i'm not skilled enough to fix them. Here is the mod :

sunshade.rar

 

Here is the error log :

Spoiler


[00:00:47]: MOD ERROR: sunshade (Sunshade): Mod: sunshade (Sunshade)    
[00:00:47]: [string "../mods/sunshade/modmain.lua"]:13: attempt to index global 'RECIPETABS' (a nil value)
LUA ERROR stack traceback:
        ../mods/sunshade/modmain.lua(13,1) in main chunk
        =[C] in function 'xpcall'
        scripts/util.lua(609,1) in function 'RunInEnvironment'
        scripts/mods.lua(483,1) in function 'InitializeModMain'
        scripts/mods.lua(457,1) in function 'LoadMods'
        scripts/main.lua(251,1) in function 'ModSafeStartup'
        scripts/main.lua(306,1)
        =[C] in function 'SetPersistentString'
        scripts/mainfunctions.lua(22,1) in function 'SavePersistentString'
        scripts/modindex.lua(76,1)
        =[C] in function 'GetPersistentString'
        scripts/modindex.lua(63,1) in function 'BeginStartupSequence'
        scripts/main.lua(305,1) in function 'callback'
        scripts/modindex.lua(516,1)
        =[C] in function 'GetPersistentString'
        scripts/modindex.lua(490,1) in function 'Load'
        scripts/main.lua(304,1) in main chunk

I tried to use erik mod as an example but i don't understand some problems i got... Thanks for any help.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
  • Create New...