Convert absurd buildtime values into seconds - Page 4

Convert absurd buildtime values into seconds

Requests for features in the spring code.

Moderator: Moderators

User avatar
Jazcash
Posts: 5309
Joined: 08 Dec 2007, 17:39

Re: Convert absurd buildtime values into seconds

Post by Jazcash »

zwzsg wrote:Jazcash: In C, 0 is false, so if(y) means if y is not 0, so the division is not done when y is zero.
Ok, that makes more sense ^_^
User avatar
zwzsg
Kernel Panic Co-Developer
Posts: 7052
Joined: 16 Nov 2004, 13:08

Re: Convert absurd buildtime values into seconds

Post by zwzsg »

Just keep in mind C and Lua diverge on that point.
- In C the condition is taken if (maybe after conversion) it's not 0
- In Lua the condition is taken if it's neither nil nor false

So:
- 0 is "false" in C
- 0 is "true" in Lua
User avatar
TradeMark
Posts: 4867
Joined: 17 Feb 2006, 15:58

Re: Convert absurd buildtime values into seconds

Post by TradeMark »

zwzsg wrote:Okay you want the tooltip to always display 0 instead of buildtime. Sure, that's doable. Totally useless, but doable.
Look closer... it displays zero if workertime is zero. Which is correct way of doing it.
zwzsg wrote:Also you want to read a file, always the same file, and god only know which, about a dozen time per rendering frame. I can only hope our OS handle caching well.
dozen? are you kidding me?

Code: Select all

void read_file(){
    load_library("unitsync.dll");
    load_modfile("BA642.sd7");
    for(u = 0; u < total_units; u++){ // loop through all units in mod
        if(!read_fbi(Unitdefs[u].UnitName + ".fbi")){ // read unit file and handle errors:
            load_library("unitsync.dll");
            load_modfile("BA642.sd7");
            u--; // try again
        }
    }
}
User avatar
zwzsg
Kernel Panic Co-Developer
Posts: 7052
Joined: 16 Nov 2004, 13:08

Re: Convert absurd buildtime values into seconds

Post by zwzsg »

Look closer... it displays zero if workertime is zero. Which is correct way of doing it.
Nah, you never changed y, so it's still 0. I mean, no sane person would want something as ugly as having y be a global variable, and having read_file() modify y, so I assumed read_file() was here just to make it run more sluggishly.
dozen? are you kidding me?
Assuming you always have a cons selected, and that your ctrlpanel.txt is set to display only a dozen buildpic per page.

load_modfile("BA642.sd7");
Not at all a BA specific request!
+".fbi"
I know you hate LUA, but FBI are a things of the past. There's whole mods with lotsa units without a single FBI file now.
for(u = 0; u < total_units; u++){
load_library("unitsync.dll");
load_modfile("BA642.sd7");
}
Loading the same .dll and .sd7 as many times as there are units?
u--; // try again
Get stuck in an infinite loop if fails?


Wait.. you're just typing non-sensical code to trick me into replying seriously to garbage and I fell in your trap. There's no way you could believe that this code bit has any relevance to getting workertime of selected units.
User avatar
CarRepairer
Cursed Zero-K Developer
Posts: 3359
Joined: 07 Nov 2007, 21:48

Re: Convert absurd buildtime values into seconds

Post by CarRepairer »

I just got a brand new idea! Make a widget!
User avatar
TradeMark
Posts: 4867
Joined: 17 Feb 2006, 15:58

Re: Convert absurd buildtime values into seconds

Post by TradeMark »

zwzsg wrote:Wait.. you're just typing non-sensical code to trick me into replying seriously to garbage and I fell in your trap. There's no way you could believe that this code bit has any relevance to getting workertime of selected units.
Sorry, i forgot to include the read_fbi() function, it had the global variable y set in there.
CarRepairer wrote:I just got a brand new idea! Make a widget!
Fool. My code was a widget, i made c++ interpreter with lua. note that it compiles the script into exe every frame and executes it by using WinExec(), ofc its using SW_HIDE so you wont see the window popping up all the time.
User avatar
knorke
Posts: 7971
Joined: 22 Feb 2006, 01:02

Re: Convert absurd buildtime values into seconds

Post by knorke »

And check for walls that would prevent a patrolling cons to reach a factories... okay there it starts getting too stupid. But where do you draw the line?
I think it should be as basic as possible.
Taking into account walktime of cons etc. is too much. This is just about the tooltip not real time estimates like the ETA widget does.

For factories buildings it should just be unitbuildtime / factoryworkspeed
Surely the engine has these informations and can transform them into to seconds?
And for multiple constructors making a building it should be unitbuildtime / workspeed_of_all_selected_cons_added_up
The engine can sum up the health of all selected units so it can surely also add up their workerspeed?

If multiple factories are selecting and the player wants each one to make the same unit, it should just show the average. Must of the time the factories will finish at the same/have same workspeed anyway.
Like 5 baracks each making one spacemarine, 5 vehlabs each making one flashtank etc.

I think as a player I just want to know "I have 10 conbots and want to make a fusion. How long will that take if i do not stall?"
The correct answer would be "90 seconds"
The answer you currently get is "622145"
Even if the time is not 100% correct due to cons walking, unfolding blabla the first answer was still more helpful.

Or the noob who does not know if "buildtime: 520145" for a Krog will take long or not. But if he sees "unassisted buildtime: 20 minutes", thats some usefull information.

Even after reading Forboding Angel's math I've already forgetten how many seconds something in BA takes to build if the tooltips reads "buildtime 42133"
One minute? 10 minutes? I think i must divide by 90.8 or something. No idea! And by which number must I divide in game X? Uhm...
30 seconds will always be 30 seconds.
Yes the proposed system would be nifty, but the fact is that you can have something close without needing a new version of spring or any luaz.
Yea, I see what you mean. Its the "this just has to work" approach. But it is somewhat hackish, like when I tried to generate minimaps by taking screenshots of the map. It might have side effects for example isn't mass based on unitcost too by default? And targetting uses cost too I think?
User avatar
zwzsg
Kernel Panic Co-Developer
Posts: 7052
Joined: 16 Nov 2004, 13:08

Re: Convert absurd buildtime values into seconds

Post by zwzsg »

knorke wrote:And for multiple constructors making a building it should be unitbuildtime / workspeed_of_all_selected_cons_added_up

If multiple factories are selecting and the player wants each one to make the same unit, it should just show the average.
I disagree on the second point. If multiple factories are selected, then it should also shows unitbuildtime / workspeed_of_all_selected_facs_added_up. That way both factories and cons are treated the same way. That way the engine doesn't have to know if it's factory or a cons, a helper or an initiator.

It still makes some sense if you reason in term of: Every 2 seconds I'll get one new Peewee from this batch of factories.
User avatar
Niobium
Posts: 456
Joined: 07 Dec 2008, 02:35

Re: Convert absurd buildtime values into seconds

Post by Niobium »

How has this thread continued on for 4 pages?

The solution is just a simple lua widget, less than a dozen lines of functional code, buildtime/sum(buildspeed), want nanos factored in? Then just add them to the selection.

This is not an engine issue! It is a UI issue, which is what lua is for. Though afaik there is no easy way to override the tooltip text before it reaches tooltip rendering widgets, so you might have to get creative on how to display it, which is down to user/mod style.
User avatar
Das Bruce
Posts: 3544
Joined: 23 Nov 2005, 06:16

Re: Convert absurd buildtime values into seconds

Post by Das Bruce »

From what I've gathered, Niobium, that isn't a solution since we can't know what is building the structure.
User avatar
zwzsg
Kernel Panic Co-Developer
Posts: 7052
Joined: 16 Nov 2004, 13:08

Re: Convert absurd buildtime values into seconds

Post by zwzsg »

Niobium wrote:Though afaik there is no easy way to override the tooltip text before it reaches tooltip rendering widgets
There is actually.:

function widget:GetTooltip(x,y)
return your_custom_tooltip_text
end

(I think it's widget:IsAbove(x,y) that takes care of knowing when to not.)

For instance, in KP, I have the ColorWar gadget and the BuildBar widget that swap the tooltip text with their own text, and the ToolTip widget that reformat and display the tooltip. So the tooltip content and the tooltip drawing are neatly separated.

Well, sorta, because my tooltip widget parse the tooltip text to determine which type is it, and if it is a unit tooltip, a builbutton tooltip, or a command tooltip, it extracts the relevant info then rewrite it in its own way, removing some info, adding others. So I had to modify the BuildBar widget to make it output in exactly the same format as the engine so my tooltip widget could correctly parse it. For extra cleanness I could have broken my tooltip widget in two, into a reformating widget, and a drawing widget.

I just realise now, changes in the engine tooltip could break my tooltip widget, as well as other tooltip reformatting widgets from other mods, which suddently make engine change even less desirable.
User avatar
TradeMark
Posts: 4867
Joined: 17 Feb 2006, 15:58

Re: Convert absurd buildtime values into seconds

Post by TradeMark »

Niobium wrote:This is not an engine issue! It is a UI issue, which is what lua is for. Though afaik there is no easy way to override the tooltip text before it reaches tooltip rendering widgets, so you might have to get creative on how to display it, which is down to user/mod style.
this is engine default UI issue, which doesnt use lua, does it
Tobi
Spring Developer
Posts: 4598
Joined: 01 Jun 2005, 11:36

Re: Convert absurd buildtime values into seconds

Post by Tobi »

Which is exactly why the complete engine UI should go, at some point, in my opinion.
Google_Frog
Moderator
Posts: 2464
Joined: 12 Oct 2007, 09:24

Re: Convert absurd buildtime values into seconds

Post by Google_Frog »

Why are you using engine default UI? One of the engine UI's main task is not to get in the way of lua UI. It should certainly not change as a change would break many lua UIs.

There are 2 very simple solutions:
* Write a very simple gadget to read unit selection, read tooltip and output a tooltip with your desired information.
* Use easily calculatable BT values in whichever game you think has the problem.
User avatar
TradeMark
Posts: 4867
Joined: 17 Feb 2006, 15:58

Re: Convert absurd buildtime values into seconds

Post by TradeMark »

Google_Frog wrote: * Write a very simple gadget to read unit selection, read tooltip and output a tooltip with your desired information.
no. it must work on every mod.
Google_Frog wrote: * Use easily calculatable BT values in whichever game you think has the problem.
i wont change every mod. waste of time, you could just make small patch like i said, but noo... need to whine here instead than do some work to improve the freaking default UI.
User avatar
CarRepairer
Cursed Zero-K Developer
Posts: 3359
Joined: 07 Nov 2007, 21:48

Re: Convert absurd buildtime values into seconds

Post by CarRepairer »

TradeMark wrote:
Google_Frog wrote: * Write a very simple gadget to read unit selection, read tooltip and output a tooltip with your desired information.
no. it must work on every mod.
Google_Frog wrote: * Use easily calculatable BT values in whichever game you think has the problem.
i wont change every mod. waste of time, you could just make small patch like i said, but noo... need to whine here instead than do some work to improve the freaking default UI.
Yeah google, why are you whining instead of making a patch. TradeMark is right, you are doing nothing to help!
User avatar
zwzsg
Kernel Panic Co-Developer
Posts: 7052
Joined: 16 Nov 2004, 13:08

Re: Convert absurd buildtime values into seconds

Post by zwzsg »

TradeMark wrote:no. it must work on every mod.
Oh. Then an engine patch is out of question, as that would break some mods.
User avatar
TradeMark
Posts: 4867
Joined: 17 Feb 2006, 15:58

Re: Convert absurd buildtime values into seconds

Post by TradeMark »

zwzsg wrote:
TradeMark wrote:no. it must work on every mod.
Oh. Then an engine patch is out of question, as that would break some mods.
And how it would break some mods...? I gave you the patch already, use it.
User avatar
zwzsg
Kernel Panic Co-Developer
Posts: 7052
Joined: 16 Nov 2004, 13:08

Re: Convert absurd buildtime values into seconds

Post by zwzsg »

I don't understand. You made maps, maybe not of top originality but nice and playable nonetheless. You made that modinfo site, which must have taken lots of work, and shows you can do coding.

So why have you now sunk to the argumentative level of a Creationist?
User avatar
TradeMark
Posts: 4867
Joined: 17 Feb 2006, 15:58

Re: Convert absurd buildtime values into seconds

Post by TradeMark »

Because you dont know what youre talking about
Post Reply

Return to “Feature Requests”