Life is Feudal: Forest Village

Life is Feudal: Forest Village

Forest Village Workshop
Forest Village hub of user generated mods, maps and scenarios.
了解更多
Erke 2019 年 11 月 16 日 上午 10:31
Looking for WorkerWindow Class references
Hello,

I'm trying to alter the Floating window of peasants (workers) in order to divide their age by 3. So if a peasant's age is 15, I want it to display 5 in the Peasant detail window.

I am not sure what is the exact reference in windows for "Age" but I am totally brainstorming to explain my situation.

I'm trying to find the right way to express a function like this;

function init(worker, layoutName, layoutAge = ("Peasant.Age" / "3"))

Or by simply altering the layoutAge

layoutAge = "Peasant.Age" / "3"

I would appreciate it if somebody could guide me on this or help me figure out the correct reference name. The official modding wiki page is helpful only to a point.
< >
正在显示第 1 - 15 条,共 45 条留言
linuxmistress 2019 年 11 月 16 日 上午 10:37 
hi,
contact directly eien no shikaku but from the time I looked through game code this thing you want wasn't possible to make
Erke 2019 年 11 月 16 日 上午 10:39 
引用自 linuxmistress
hi,
contact directly eien no shikaku but from the time I looked through game code this thing you want wasn't possible to make

So you tried to do this too? =D
linuxmistress 2019 年 11 月 16 日 上午 10:41 
I decided to quit investing my time because modding is very limited in FV, God knows how much patience has eien no shikaku to mod it by constantly looking for a workarounds...
linuxmistress 2019 年 11 月 16 日 上午 10:41 
I tried many things and it didn't work
Erke 2019 年 11 月 16 日 上午 10:41 
引用自 linuxmistress
I decided to quit investing my time because modding is very limited in FV, God knows how much patience has eien no shikaku to mod it by constantly looking for a workarounds...

Half of the fun is working your brain for workarounds ;)
linuxmistress 2019 年 11 月 16 日 上午 10:42 
without full access to core game code you can't do much
Erke 2019 年 11 月 16 日 上午 10:43 
引用自 linuxmistress
without full access to core game code you can't do much

Well let's hope somebody who understands what I need, comes up with a solution =D
linuxmistress 2019 年 11 月 16 日 上午 10:44 
No, it's not fun when you can so easily break this game without knowledge, at least eien no shikaku still make mods to make our lives easier, for me not having full access is too annoying
linuxmistress 2019 年 11 月 16 日 上午 10:45 
You do know only eien no shikaku knows fully how this game is coded right? Just contact eien no shikaku and she/he will help you.
Erke 2019 年 11 月 16 日 上午 10:47 
引用自 linuxmistress
You do know only eien no shikaku knows fully how this game is coded right? Just contact eien no shikaku and she/he will help you.
I really don't want to bother Shikaku with my every question or request. She's/He's already been kind enough to answer most of my questions for the last week...

I posted this here so may be another fellow modder who's into coding could spare time..
最后由 Erke 编辑于; 2019 年 11 月 16 日 上午 10:50
linuxmistress 2019 年 11 月 16 日 上午 10:54 
for now there is only active one, eien no shikaku, at least one who replies and have time to help players
dominuskevin 3 2019 年 11 月 16 日 下午 1:23 
Have you tried to alter

\scripts\gui\Pages\ResidentsPage.lua

function ResidentsPage:update(dt)

look for this line ---

itemWindow:setProperty("Age", w and tostring(w.age) or "")

change to

itemWindow:setProperty("Age", w and tostring(w.age/3) or "")

I haven't tried this myself but it looks like it will take a person's age and divide by three before displaying it. Because of the window classes I don't believe you can separate between working and non-working or by age group - child, teen, adult. If it does work it will change everyone's.
Erke 2019 年 11 月 16 日 下午 2:22 
引用自 dominuskevin
Have you tried to alter

\scripts\gui\Pages\ResidentsPage.lua

function ResidentsPage:update(dt)

look for this line ---

itemWindow:setProperty("Age", w and tostring(w.age) or "")

change to

itemWindow:setProperty("Age", w and tostring(w.age/3) or "")

I haven't tried this myself but it looks like it will take a person's age and divide by three before displaying it. Because of the window classes I don't believe you can separate between working and non-working or by age group - child, teen, adult. If it does work it will change everyone's.

Hello thank you SO much for your reply.
I have made the change you suggested. But isn't that for the houses window?

I also found this line inside WorkerWindow.lua;

self.nameLabel:setText(worker.name.." ("..worker.age..")")

which I believe the exact place where I'm looking to edit... But how would I go about dividing that?

Would it be like this;
self.nameLabel:setText(worker.name.." ("..worker.age/3..")")

or like this?

self.nameLabel:setText(worker.name.." ("..worker.age..")/3")

EDIT:
Also;
When I create a custom .lua for the ResidentsPage.lua I get an "loading failed" error.
I copied this whole section into the file;

function ResidentsPage:update(dt)
ResidentsPage.base.update(self, dt)

if self.residentInfoTimeout then
self.residentInfoTimeout = self.residentInfoTimeout - dt
local childCount = self.container:getChildCount()
if self.residentInfoTimeout <= 0 or self.residentInfoCount ~= childCount then
self.residentInfoTimeout = UPDATE_RESIDENT_INFO_TIMEOUT
self.residentInfoCount = childCount

local workerCount = self.building:getWorkerCount()
for i = 0, childCount - 1 do
local itemWindow = self.container:getChildAtIdx(i)
local w = i < workerCount and self.building:getWorker(i) or nil
itemWindow:setProperty("Age", w and tostring(w.age/3) or "")

local profText = ""
if w then
profText = "@prof_laborer@"
local workRole = w:getWorkRole()
if not workRole:isEmpty() then
profText = professionLoc(workRole)
else
if w:isChild() then
profText = "@child@"
elseif w:isTeen() then
profText = "@teenager@"
end
end
end

itemWindow:setProperty("Prof", localize(profText))

local genderIcon = ""
if w then
genderIcon = w:isMale() and "GameLook1/iconGenderMale2" or "GameLook1/iconGenderFemale2"
end

itemWindow:setProperty("NormalImage", genderIcon)
local name = w and w:getName() or "@expecting_baby@"
itemWindow:setProperty("wName", localize(name))

local btnWin = itemWindow:getChildRecursive("__btn__")
if btnWin then
if w then
btnWin.userData = w.uid
end
self.btns[btnWin] = btnWin -- prevent gc
end
end
end
end
end
最后由 Erke 编辑于; 2019 年 11 月 16 日 下午 2:30
dominuskevin 3 2019 年 11 月 16 日 下午 3:13 
I went back and looked at a few things in-game. Age is displayed in the production building, houses, and the individual. I'm not sure about the hospital.

The best way to learn this is to learn how to read log.log.

DL my Armed and Dangerous mod. It's a good example for getting a basic 'Function' based mod to work.

Start out by getting a mod made with a copy of a function (unchanged) to load.

When you understand how that works then you can start altering lines in the function.

For instance, you'll find you have to do this.

function ResidentsPage:update(dt)

change to

function fv.core.ResidentsPage:update(dt)

You need to understand how tables work and how data is stored in them. Based on what I've read about lua thus far, I've only scratched the surface.

To get a handle on log.log, take a known good mod and save the file some where then alter it so it crashes. The way you know what you did and you should be able to find a reference to it in the log.

If you are using NP++ you'll find mods loading in the 500 -600 line range with some info about why it didn't load. Sometimes you find additional info near the bottom. Just go all of the way down then scroll up until you see failed or crash or something that looks bad.
linuxmistress 2019 年 11 月 16 日 下午 3:35 
read about modding at gamepedia, you should see you can't just copy paste game functions like that, there should be a reference to game itself in your code

https://forestvillage.gamepedia.com/Modding
https://forestvillage.gamepedia.com/Mod
< >
正在显示第 1 - 15 条,共 45 条留言
每页显示数: 1530 50