Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add missing production time help texts #3791

Open
lukstruck opened this issue Mar 22, 2020 · 5 comments
Open

Add missing production time help texts #3791

lukstruck opened this issue Mar 22, 2020 · 5 comments

Comments

@lukstruck
Copy link

@lukstruck lukstruck commented Mar 22, 2020

Problem

I wanted to create a Graphviz tree to get an overview of how long resources take to produce, when I noticed that only the production times of the food chain (and not even all) are given in the help texts. For many production buildings, the production time is missing in the help texts - or wrong (e.g. Empire Inn, helptexts says (48s on average for a meal OR a ration) or (85s for both), program is 33s and 40s).

Solution

Minimum: Fill out the remaining missing production times as defined in the building programs and fix incorrect times.

Optional: create a tool that automatically fills out the remaining production times by parsing the building programs and calculating the absolute time for all produced wares. (No differentiation between cases like rations are skipped, only meals are prepared. Absolute time assume that all wares are needed.)

Optional to the optional: create a tool that creates said Graphviz tree for me. Here's an example, although it probably won't look like this since I left out some connections for better readability.

Implementation steps

Minimum

  • add up all the times in the sleep and animate program commands
  • update the building helptexts with the template pgettext("{building_name}", "Needs %1% to produce {produced_wares}"):bformat(format_seconds({seconds}))

Optional
Need some help here, never worked with Lua. How do I parse the programs? If parsed and ready in a tree like structure, the tree can be traversed and all the relevant info (animate and sleep ms, produced wares) can be extracted.

  • Take info and fill the above template

Optional to the optional
Also extract the consumes info from the parsed tree and create the following DOT line per building:

{consumed_wares} -> {produced_wares} [label="{seconds} {building_name}"]

The result is probably not pretty - it's probably a bit clustered - but it's a start.

This is my first created issue on a project that is not mine, please help me out with any formal and non formal errors I made. I would also be very glad to start working on the issue, I have already cloned the repo and looked at the files a bit. I did not start working on it yet, since there seem to be too many inconsistencies between comments and the actual programs that I can be sure what I write is correct.

@lukstruck

This comment has been minimized.

Copy link
Author

@lukstruck lukstruck commented Mar 22, 2020

Inconsistencies I noticed:

      produce_ax_broad = {
         -- TRANSLATORS: Completed/Skipped/Did not start forging a broad ax because ...
         descname = _"forging a broad ax",
         actions = {
            -- time total: 57 + 3.6
            "return=skipped unless economy needs ax_broad",
            "consume=coal:2 iron:2",
            "sleep=26000",
            "playsound=sound/smiths/smith 192",
            "animate=working 22000",
            "playsound=sound/smiths/sharpening 120",
            "sleep=9000",
            "produce=ax_broad"
         }
      },

where does the 3.6 come from? This happens at a lot of other places as well, but not at all.

@Noordfrees

This comment has been minimized.

Copy link
Member

@Noordfrees Noordfrees commented Mar 22, 2020

Whenever you see the magic number 3.6 anywhere you can be sure that it refers to the time a worker needs to walk one field far and back. I.e. it is the time the worker needs to drop one produced ware to the building's flag and go back in. This is another "hidden delay" which is not apparent in the program but needs to be added to the actual duration.

@lukstruck

This comment has been minimized.

Copy link
Author

@lukstruck lukstruck commented Mar 22, 2020

Are there any other hidden delays?

... and why isn't that included in the animation time?

@Noordfrees

This comment has been minimized.

Copy link
Member

@Noordfrees Noordfrees commented Mar 22, 2020

The animate statement sets the building's displayed animation to the given animation. This anim continues running until it is changed again by some other statement. Additionally, animate pauses program execution for the given number of milliseconds. Then the next program step is started – such as produce, which causes the building's main worker to drop out one ware.

As far as I know the only other hidden delay are in call (which pauses the program until the building's called program finishes), callworker (which pauses the program until the worker's called program finishes) and the respective workers walk statements.

@gunchleoc

This comment has been minimized.

Copy link
Contributor

@gunchleoc gunchleoc commented Mar 24, 2020

See also #3437

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.