Project Zomboid

Project Zomboid

Yes' Improved Stealth v2 [B42/B41]
PepperCat 29 Oct, 2023 @ 9:30am
Moodle Framework sample
Hey there!

This is how I'm using it to make it work for one of my Moodles.

A new file with:

require "MF_ISMoodle"
MF.createMoodle("dtoverdose");

-- OVERDOSE MOODLE
function overdoseMoodleUpdate(player)
--print("Player overdose: " .. player:getModData().DTOverdose)
if MF.getMoodle("dtoverdose") ~= nil then
if player:getModData().DTOverdose > 50 and player:getModData().DTOverdose <= 70 then
MF.getMoodle("dtoverdose"):setValue(0.3)
--print("Moodle 2")
elseif player:getModData().DTOverdose > 70 and player:getModData().DTOverdose <= 85 then
MF.getMoodle("dtoverdose"):setValue(0.2)
--print("Moodle 3")
elseif player:getModData().DTOverdose > 85 and player:getModData().DTOverdose <= 100 then
MF.getMoodle("dtoverdose"):setValue(0.1)
--print("Moodle 4")
else
MF.getMoodle("dtoverdose"):setValue(0.5)
--print("No Moodle")
end
end
end

And then I'm calling that function using EveryOneMinute, but that's it, I didn't need to bring all the MoodleFramework files into my mod, with the "require" is enough as the MF object is global.

Based on what I saw on your mod, I think that by deleting the "Moodle" folder would be enough as you're already handling your own Moodle in the improvedsneak.lua file
< >
Showing 1-2 of 2 comments
yes  [developer] 29 Oct, 2023 @ 11:10am 
The problem I had with this is that, if someone does not have Moodle Framework activated (likely scenario since my mod didn't need it before), the file will throw an error at MF.createMoodle("dtoverdose") 100% of the time. So for now, as I am learning the in and outs of this framework, decided to just copy the file so anyone who could run the mod before could run it now without paying any attention while I keep digging into it. Later I can just check if the user has Moodle Framework or not and do something about it.
PepperCat 29 Oct, 2023 @ 11:53am 
Understood. If that's the case what you could do instead is to only create and use the Moodle if the MoodleFramework is activated using something like:


if getActivatedMods():contains("MoodleFramework") then
-- code here
end

But now I got your point :)
< >
Showing 1-2 of 2 comments
Per page: 1530 50