Project Zomboid

Project Zomboid

Moodle Framework B41
 This topic has been pinned, so it's probably important
Tchernobill  [developer] 11 Sep, 2022 @ 8:10am
Moodle Framework For Modders
Informations
Replace * by the name of your Moodle. (e.g. "Proteins" for ProteinsMoodle mod)
goodBadNeutral is an enum 1 means Good, 2 means Bad, 0 means Neutral.
moodleLevel is an unsigned int between 1 and 4.
playerNum is the local id of the player used for split screen. If you do not fill it, the mod will not be split screen compatible.

1/ Moodle Texture
Add Moodle *.png under media\ui.
Should be 30 by 30 pixels png with alpha enabled.

2/ Texture
Add the following text under media\lua\shared\Translate\EN
Moodles_EN { Moodles_*_Good_lvl1 = "text_1", Moodles_*_Good_desc_lvl1 = "text_desc_1", Moodles_*_Good_lvl2 = "text_2", Moodles_*_Good_desc_lvl2 = "text_desc_2", Moodles_*_Good_lvl3 = "text_3", Moodles_*_Good_desc_lvl3 = "text_desc_3", Moodles_*_Good_lvl4 = "text_4", Moodles_*_Good_desc_lvl4 = "text_desc_4", Moodles_*_Bad_lvl1 = "text_1", Moodles_*_Bad_desc_lvl1 = "text_desc_1", Moodles_*_Bad_lvl2 = "text_2", Moodles_*_Bad_desc_lvl2 = "text_desc_2", Moodles_*_Bad_lvl3 = "text_3", Moodles_*_Bad_desc_lvl3 = "text_desc_3", Moodles_*_Bad_lvl4 = "text_4", Moodles_*_Bad_desc_lvl4 = "text_desc_4", }

3/ Moodle object creation
Add these lines in your mod:
require "MF_ISMoodle" MF.createMoodle(*);

4/ Moodle value updates
Access your moodle from your code with
require "MF_ISMoodle" MF.getMoodle(*,playerNum):setValue(myNewMoodleValue)--float
0.0 <= myNewMoodleValue <=1.0
MF.getMoodle(*,playerNum) is not always valid (It requires the player to be already created and some framework internal function to be called). The safe way is to check it is different from nil before using it.

5/ [option] Change value thresholds with
MF.getMoodle(*,playerNum):setThresholds(bad4, bad3, bad2, bad1, good1, good2, good3, good4)--floats
By default values are respectively 0.1,0.2,0.3,0.4, 0.6,0.7,0.8,0.9
bad4 must always be the smallest threshold value, followed by bad3, and so on.. good4 being the biggest threshold value.
Bad thresholds are upper thresholds while good thresholds are lower thresholds.
The moodle is hidden strictly between bad1 and good1.
You can deactivate a level by setting its threshold to nil.

6/ [option] Add chevrons with
MF.getMoodle(*,playerNum):setChevronCount(chevronCount)--unsigned int MF.getMoodle(*):setChevronIsUp(isUp)--bool
By default chevronCount is 0 and setChevronIsUp is true.

7/ [option] Change a specific text tooltip
MF.getMoodle(*,playerNum):setTitle(goodBadNeutral,moodleLevel,text)
MF.getMoodle(*,playerNum):setDescription(goodBadNeutral,moodleLevel,text)
Invalid for goodBadNeutral = 0 (Neutral)

8/ [option] Change a specific texture
MF.getMoodle(*,playerNum):setBackground(goodBadNeutral,moodleLevel,texture)
MF.getMoodle(*,playerNum):setPicture(goodBadNeutral,moodleLevel,texture)
Invalid for goodBadNeutral = 0 (Neutral)

9/ [option] get access to the current value, goodBadNeutral and level
MF.getMoodle(*,playerNum):getValue()
MF.getMoodle(*,playerNum):getGoodBadNeutral()
MF.getMoodle(*,playerNum):getLevel()

10/ [option] Force wiggling
MF.getMoodle(*,playerNum):doWiggle()

11/ [information] On Death
The Moodle remains available but is diconnected from the non existing character and the moodle is hidden.
At this point, if you kept a local parameter for MF.getMoodle(*,playerNum), using setValue will do nothing.
The easy sure way is to always use MF.getMoodle(*,playerNum).
The ROAE way is to refresh your local variable with MF.getMoodle(*,playerNum) in the event callback of OnCreatePlayer AFTER MoodleFramework. Ensure you register your event after calling MF.createMoodle(*).
Last edited by Tchernobill; 7 Feb, 2024 @ 12:08pm
< >
Showing 1-5 of 5 comments
Ryan 14 Jul, 2024 @ 4:08am 
Can i get permission to expand upon it? and modify a version of my own?
Tchernobill  [developer] 14 Jul, 2024 @ 4:37am 
@Ryan Suggestions are welcome, but branches of the mod are not.
Josko 7 Sep, 2024 @ 11:59am 
Hi, how would I attach my custom moodle with this framework on an item?

So the moment the player consumes/eats the item like Alcohol the moodle should appear depending on how much of that item the character eats
Always lookin' up 16 Dec, 2024 @ 5:14am 
Hi, i just found this moodle framework and tried it out, but getMoodle() returns nil, no matter if playernum is 0, 1, or nil.

im not sure if thats the cause, but i assumed i have to put the png and the Moodles_EN.txt in my mod directory. Should i put it directly in the original pz directory?
Always lookin' up 16 Dec, 2024 @ 5:22am 
Originally posted by Josko:
Hi, how would I attach my custom moodle with this framework on an item?

So the moment the player consumes/eats the item like Alcohol the moodle should appear depending on how much of that item the character eats

if you havent found a solution yet, you would have to add your own logic to the items that should affect the moodle. Eg. hooking ISInventoryPaneContextMenu.eatItem
< >
Showing 1-5 of 5 comments
Per page: 1530 50