Project Zomboid

Project Zomboid

Yes' Improved Stealth v2 [B42/B41]
PepperCat 2023 年 10 月 29 日 上午 9:30
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
< >
正在显示第 1 - 2 条,共 2 条留言
yes  [开发者] 2023 年 10 月 29 日 上午 11:10 
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 2023 年 10 月 29 日 上午 11:53 
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 :)
< >
正在显示第 1 - 2 条,共 2 条留言
每页显示数: 1530 50