Cuchulainn Posted November 16, 2013 Share Posted November 16, 2013 So I was just wondering if anyone would be so kind as to give me some advice as to how to create a class. I have seen some mods that inolve custom classes and would love to make one or two of my own! Very new at this but got the drive for it so any help would be greatly appreciated!!Slainte! Link to comment Share on other sites More sharing options...
RoboMat Posted November 16, 2013 Share Posted November 16, 2013 You mean java-classes? Never used them. PZ has excellent modding support for lua though. Link to comment Share on other sites More sharing options...
Cuchulainn Posted November 16, 2013 Author Share Posted November 16, 2013 well...I read your article on creating mods, but couldnt follow. Probably from my lack of experience. I just want to create a new class other than police officer, fire fighter, etc. I didnt know if there was a text I could alter or work with that would allow me to do that Link to comment Share on other sites More sharing options...
RoboMat Posted November 16, 2013 Share Posted November 16, 2013 Ahhhh you mean a new profession What part couldn't you follow exactly? Link to comment Share on other sites More sharing options...
Cuchulainn Posted November 16, 2013 Author Share Posted November 16, 2013 Oh shoot. All of it really. I guess I just got lost in the whole Lua scripiting concept. I am more of a "let me find the folder and file, and rummage around the script and see what I can add". Obviously I am not a modder haha But I found the folder and file in C:\Program Files (x86)\Steam\SteamApps\common\ProjectZomboid\media\lua\Professions ; that lists the professions...or at least what I think are the professions. For example, I want to create the class Military Officer, and seeing the text file there is one but I want to add that to game and if possible with my own traits along with it. Link to comment Share on other sites More sharing options...
RoboMat Posted November 16, 2013 Share Posted November 16, 2013 You can find the code for custom professions in NPCs->UI->MainCreationMethods.lua and the code for clothing in NPCs->UI->ProfessionClothing.lua Link to comment Share on other sites More sharing options...
Cuchulainn Posted November 16, 2013 Author Share Posted November 16, 2013 Is MainCreationMethods.lua in UI or in the same folder as UI...? Link to comment Share on other sites More sharing options...
RoboMat Posted November 16, 2013 Share Posted November 16, 2013 It should be in the lua folder so media/lua ... NPCs->UI->MainCreationMethods.lua IIRC. Or just search for MainCreationMethods.lua in your OS Link to comment Share on other sites More sharing options...
Cuchulainn Posted November 16, 2013 Author Share Posted November 16, 2013 Stupid question...sorry, figured that one out... Now do I simply mimic a lets say "police officer" coding and name it as whatever I want and this will work? How would I possibly add the logo for that profession as well as the trait? Link to comment Share on other sites More sharing options...
RoboMat Posted November 16, 2013 Share Posted November 16, 2013 Now do I simply mimic a lets say "police officer" coding and name it as whatever I want and this will work? How would I possibly add the logo for that profession as well as the trait? No. Everything you need to create a profession can be found here: http://theindiestone.com/forums/index.php/topic/61-robomats-modding-tutorials-updated-12112013/#IV But that just creates a new profession - it wouldn't add any functionality to it whatsoever. That's a totally different task alltogether ^^ Link to comment Share on other sites More sharing options...
Ontogenesis Posted November 16, 2013 Share Posted November 16, 2013 You can make Lua classes like so:function NewPerson(name, health)object = {}object.name = nameobject.health = healthfunction object:ApplyDamage(damage)local d = object.health - damageif d <= 0 then object:Die()else object.health = d print("Ugh!")endendfunction object:Die()object.health = 0print("I'm dying, nooo")endreturn objectendBarry = NewPerson("Barry", 100)Barry:ApplyDamage(50)Barry:ApplyDamage(50) Link to comment Share on other sites More sharing options...
RoboMat Posted November 16, 2013 Share Posted November 16, 2013 Onto he doesn't mean a class in the programming sense. He wants to create a profession like a firefighter Besides that I like your code <3 Link to comment Share on other sites More sharing options...
Cuchulainn Posted November 16, 2013 Author Share Posted November 16, 2013 Hm, suppose it would be pointless if it didnt have any functionality...but what if I linked my profession to already known traits like Eagle Eyed, light eater, heavy drinker, etc as "free traits" in the MainCreationMethods.lua? Would this at least give my profession funcitonality through those traits. I am not interested really in creating my own traits, just using the ones the game already has Link to comment Share on other sites More sharing options...
RoboMat Posted November 16, 2013 Share Posted November 16, 2013 You can add vanilla traits to your custom professions just like I did in the tutorial with:cheater:addFreeTrait("NightOwl");Of course you'd have to replace cheater with your profession variable. Link to comment Share on other sites More sharing options...
Cuchulainn Posted November 16, 2013 Author Share Posted November 16, 2013 Alrighty! Thanks mucho friend. Think I am starting to get it. Will play with it for a while and see if I can get it to work. If not, I shall be back! Thanks Again!! Slainte! Link to comment Share on other sites More sharing options...
Cuchulainn Posted November 16, 2013 Author Share Posted November 16, 2013 So I followed the tutorial and applied it in mods, but when I get to the profession screen it doesnt show This is what it looks like: -- ArmyOfficerProfession.luarequire'NPCs/MainCreationMethods';require'NPCs/ProfessionClothing';local function initProfessions() -- Java: Create a new profession. local armyofficer = ProfessionFactory.addProfession("army officer", "Army Officer", "Prof_rm_Army Officer"); -- Java: Add the vanilla trait Nightowl. armyofficer:addFreeTrait("NightOwl"); -- Java: Add the vanilla trait ThickSkinned. armyofficer:addFreeTrait("ThickSkinned"); -- Java: Add the vanilla trait Patient. armyofficer:addFreeTrait("Patient"); -- Java: Add the vanilla trait ShortTemper. armyofficer:addFreeTrait("ShortTemper"); -- Java: Add the vanilla trait Brave. armyofficer:addFreeTrait("Brave"); -- Java: Add the vanilla trait EagleEyed. armyofficer:addFreeTrait("EagleEyed"); -- Java: Add the vanilla trait Athletic. armyofficer:addFreeTrait("Athletic"); -- Java: Add the vanilla trait Stout. armyofficer:addFreeTrait("Stout"); -- Java: Add the vanilla trait Marksman. armyofficer:addFreeTrait("Marksman"); -- Java: Add the vanilla trait Outdoorsman. armyofficer:addFreeTrait("Outdoorsman");end----- Set custom spawn points for this profession.-- Modelled after spawn code by RegularX. Thanks to-- The_Real_Ai for his explanation on how to calculate-- them.--local function initSpawnPoints() local spawn; -- Create a Spawnpoint in the large Warehouse. spawn = { { worldX = 33, worldY = 33, posX = 874, posY = 80, }, } -- Add our profession to the list of spawnpoints for Muldraugh. BaseGameCharacterDetails.spawnPoint.MuldraughKY.armyofficer = spawn; spawn = { { worldX = 39, worldY = 23, posX = 138, posY = 100, }, } -- Add our profession to the list of spawnpoints for West Point. BaseGameCharacterDetails.spawnPoint.WestPointKY.armyofficer = spawn; spawn = { { worldX = 37, worldY = 23, posX = 741, posY = 79, }, }end----- Set custom clothing and clothing colors for this-- profession.--local function initClothing() local clothes = { male = { topPal = "Shirt_White", top = "Shirt", bottomPal = "Trousers_White", bottom = "Trousers", topCol = { r = 0.1, g = 0.1, b = 0.1, }, bottomCol = { r = 0.1, g = 0.1, b = 0.1, }, }, female = { topPal = "Shirt_White", top = "Shirt", bottomPal = "Trousers_White", bottom = "Trousers", topCol = { r = 0.1, g = 0.1, b = 0.1, }, bottomCol = { r = 0.1, g = 0.1, b = 0.1, }, }, } ProfessionClothing.armyofficer = clothes;end-- -------------------------------------------------- Game Hooks-- ------------------------------------------------Events.OnGameBoot.Add(initTraits);Events.OnGameBoot.Add(initProfessions);Events.OnGameBoot.Add(initSpawnPoints);Events.OnGameBoot.Add(initClothing); Link to comment Share on other sites More sharing options...
RoboMat Posted November 16, 2013 Share Posted November 16, 2013 Did you create a mod.info file? Did you activate the mod? Link to comment Share on other sites More sharing options...
Cuchulainn Posted November 16, 2013 Author Share Posted November 16, 2013 That I did. Other mods that I have used work fine using the ame cutom mod.info file...so dont think that is it.Is there anything in the script that may be wrong? Like locations or anything? Link to comment Share on other sites More sharing options...
RoboMat Posted November 16, 2013 Share Posted November 16, 2013 No way to check from where I am at the moment. Go to the local content of PZ and look for error.log and output.log - they usually tell you what's wrong. Link to comment Share on other sites More sharing options...
Cuchulainn Posted November 16, 2013 Author Share Posted November 16, 2013 I see them but dont know what to make of the text. Nothing that I know of that involves my mod but then again I dont know what I am looking for. Link to comment Share on other sites More sharing options...
Cuchulainn Posted November 16, 2013 Author Share Posted November 16, 2013 I take that back, found this in the error file: Nov 16, 2013 3:39:45 PM zombie.ZomboidFileSystem loadModsSEVERE: nulljava.io.FileNotFoundException: C:\Users\---\Zomboid\mods\C:\Users\---\Zomboid\mods\armyofficerprofession\mod.info (The filename, directory name, or volume label syntax is incorrect) at java.io.FileInputStream.open(Native Method) at java.io.FileInputStream.<init>(FileInputStream.java:138) at java.io.FileInputStream.<init>(FileInputStream.java:97) at zombie.core.IndieFileLoader.getStreamReader(IndieFileLoader.java:46) at zombie.core.IndieFileLoader.getStreamReader(IndieFileLoader.java:26) at zombie.gameStates.ChooseGameInfo.getModDetails(ChooseGameInfo.java:41) at zombie.ZomboidFileSystem.loadMods(ZomboidFileSystem.java:109) at zombie.GameWindow.maina(GameWindow.java:904) at zombie.gameStates.MainScreenState.main(MainScreenState.java:112) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at com.exe4j.runtime.LauncherEngine.launch(Unknown Source) at com.exe4j.runtime.WinLauncher.main(Unknown Source)Nov 16, 2013 3:39:45 PM zombie.ZomboidFileSystem loadModsSEVERE: nulljava.io.FileNotFoundException: C:\Users\---\Zomboid\mods\C:\Users\---\Zomboid\mods\armyofficerprofession\mod.info (The filename, directory name, or volume label syntax is incorrect) at java.io.FileInputStream.open(Native Method) at java.io.FileInputStream.<init>(FileInputStream.java:138) at java.io.FileInputStream.<init>(FileInputStream.java:97) at zombie.core.IndieFileLoader.getStreamReader(IndieFileLoader.java:46) at zombie.core.IndieFileLoader.getStreamReader(IndieFileLoader.java:26) at zombie.gameStates.ChooseGameInfo.getModDetails(ChooseGameInfo.java:41) at zombie.ZomboidFileSystem.loadMods(ZomboidFileSystem.java:136) at zombie.GameWindow.maina(GameWindow.java:904) at zombie.gameStates.MainScreenState.main(MainScreenState.java:112) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at com.exe4j.runtime.LauncherEngine.launch(Unknown Source) at com.exe4j.runtime.WinLauncher.main(Unknown Source)java.nio.BufferOverflowException at java.nio.DirectByteBuffer.put(DirectByteBuffer.java:357) at com.evildevil.engines.bubble.texture.DDSLoader.readFileData(DDSLoader.java:203) at com.evildevil.engines.bubble.texture.DDSLoader.loadDDSFile(DDSLoader.java:104) at zombie.core.textures.ImageData.<init>(ImageData.java:321) at zombie.core.textures.TextureID.<init>(TextureID.java:175) at zombie.core.textures.Texture.<init>(Texture.java:149) at zombie.core.textures.TexturePackPage.loadFromPackFileDDS(TexturePackPage.java:465) at zombie.GameWindow.LoadTexturePackDDS(GameWindow.java:1466) at zombie.GameWindow.run(GameWindow.java:1073) at zombie.GameWindow.maina(GameWindow.java:959) at zombie.gameStates.MainScreenState.main(MainScreenState.java:112) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at com.exe4j.runtime.LauncherEngine.launch(Unknown Source) at com.exe4j.runtime.WinLauncher.main(Unknown Source) Fixed! I simply had to add it to the mods in SteamApp media foulder! We are good to go! Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now