Jump to content

Creating Class


Cuchulainn

Recommended Posts

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

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

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

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

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

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

So I followed the tutorial and applied it in mods, but when I get to the profession screen it doesnt show :cry:

 

This is what it looks like:

 

-- ArmyOfficerProfession.lua
require'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

I take that back, found this in the error file:

 

Nov 16, 2013 3:39:45 PM zombie.ZomboidFileSystem loadMods
SEVERE: null
java.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 loadMods
SEVERE: null
java.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

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
×
×
  • Create New...