I developed a liquid tanks for CR.
But i found it very ugly because i had to override the Liquid functions of CR because they only allow putting liquid into barrels.
And does not allow blocking inputs or limiting them very well.
So i invented a new functionality.
It should exist only one type of liquidpipe (not both source and drainpipe). And an engine/default function for liquid transportation.
The pump pumps liquid into the pipe and the structure connected gets an LiquidInput(int dMat, ind dAmount, object pSource, object pPipe) call
Here is my fast implemented code for the pump, pipe and 2 sample buildinds (Tank and Barrelcontainer). (maybe the last one should be made availiable for #include like the Door
#SourcePipe->GetLiquid(int dnMat, int dnMaxAmount, object pPump)
##SourceObject->LiquidOutput(int dnMat, int dnMaxAmount, object pPump, object pPipe)
#TargetPipe->PutLiquid(int dnMat, int dnMaxAmount, object pPump)
##TargetObject->LiquidInput(int dnMat, int dnMaxAmount, object pPump, object pPipe)
I finished coding and appended the .patch file bellow. Testing this was really hard, because there were no structures to test with.
On another note: We need oil!
But DefCore/Picture/Mesh and all this have to be done by other people.
Maybe i write down some required DefCore-Options, but the rest is up to you (others)
You can use the graphics you need from CR to test your stuff and we will see to replace them in the future.
Also don't use names like
LiquidOutput(string sznMaterial, int inMaxAmount, object pnPump, object pnPipe, bool bnWildcard)
LiquidOutput(string mat, int max, object pump, object pipe, bool wild_card).
>generally, use meaningful identifiers which are self explanatory: e.g. weapon_strength rather than iStr
>don't use hungarian notation, preferably use lowercase_separated_by_underscores for variables
lowercase ok ill change that
hungarian notation vs meaningful identifiers, what identifiers are more meaningfull than sznMaterial? this var tells me its a string (sz), its declared as input (n) and its a material
-mat could be anything, but you can guess its material
-and max? ...
-why is wild_card sperated via _?
Somewhere in that code I've read sz.... and i never used sz before (s only)
>use CamelCase() for functions
>use PREFIX_Identifier for static constants
I didn't use any
>But you provide us with the unused libraries, without telling what they can be used for.
Import this to allow the structures to
-fill liquids which has been pumped into the building into barrels
-extract liquids from barrels and pump it somewhere else"
what else should i write there?
should i write that if you import this via #include into your structures and also objects in common,
that all inserted materials (via pipe or other ways) are put into barrels and that all extracted materials are extracted from barrels?
(you also can declare this as global func to add this functionality to every object connected to a pipline)
the tank lib does nearly the same but it doesn't fill liquids into and extract liquids from barrels, it provides an internal tank.
if you limit the liquids to oil this lib could be used to put fuel into steamengine and this very very easyly.
Maybe i missed something when reading libary but in java I include libaries to add additional functions to an object.
And this two libaries does nothing else than adding additional features to (selected) objects which aren't developed so far.
Maybe call it samplecode, but somewhere this functions have to be writen otherwise people won't know how to use.
Maybe i have chosen the wrong expressions/words, because i didn't use english for ages. and i have trusted my translation tool.
if i have to change this all, please tell me:
Shall i use int mat or string mat as parametre?
int does not support wildcard, but would be less complex for code readers
> hungarian notation vs meaningful identifiers, what identifiers are more meaningfull than sznMaterial?
Unfortunately, this is the convention. "material" is as helpful as "szMaterial" since to determine the proper type, you look into the function call anyway (where it is either string material or int material).
Please consider not using abbreviations like "mat" if "material" would do as well.
> i did
Please don't see this as a general critique on your work, I just wanted to give a reason why Maikel made such an appeal.
> what else should i write there?
You might want to have a look at the PowerConsumer and PowerGenerator libraries. They are good examples of well documented libraries. You don't have to do this since there are still many libs badly documented but I would be helpful for all other developers.
> Shall i use int mat or string mat as parametre?
That's up to you. I myself would prefer string because it's more likely human readable and people will end up using LiquidInput(Material("Water"), ...) anyway.
> Please consider not using abbreviations like "mat" if "material" would do as well.
To be fair, that was Maikel's suggestion. And we aren't really making a few name prefixes a reason for rejecting patches, are we? Just as with the engine I'd vote that anything that isn't part of an interface to other parts of the game is probably not worth having a big discussion over. Local variable names are firmly in that category.
but the liquidtank libary could be used within the steamengine or powerplant.
and the LiquidBarrelFiller lib could be used in base/basis/castle
You avoid doublicate code, and with one eye on the beginning of the file you can see, this building does .... + ... and handles liquid like X
>You might want to have a look at the PowerConsumer and PowerGenerator libraries. They are good examples of well documented libraries. You don't have to do this since there are still many libs badly documented but I would be helpful for all other developers.
Maybe i'm a bad documentor, but i really don't know how to put more into documentation. (Maybe because its english)
Everything else would be.
for (barrels with liquid new_mat)
maybe i could add a sentence like "object pump: if you don't like the pump you can restrict liquid flow"
I will see to include the patch into the repository. Unfortunatey I wasn't able to proper import the patch so your name as creator of the changeset is lost along the way. I hope you don't mind.
Thanks for contributing!
What just sprang to my mind: How about we remove "output" pipes? So you can only ever connect input pipes to the pump? We could simply have the pump as the place where you fill barrels - it doesn't really make much sense in arbitrary containers... It would make it a lot harder to just pump stuff into nothingness as well. And lastly, this would force you to put the pumps where you want to put the liquid - which means pumping water to the surface forces you to put the pump into a less guarded place.
Another idea would be that you just lay down the water pipes, which should be a bit larger than the CR ones, and they always transport liquid from the higher end to the lower end. A pump can be placed anywhere on the line path to set the pump direction of the attached pipe.
Even better would be if you didn't need pipes at all. You just dig tunnels and build loam bridges for water and place a pump anywhere to build up the pressure. IT would certainly make water transportation interesting and allow for complicated settlement goals. But we don't have that amount of physics in the landscape, unfortunately.
> Another idea would be that you just lay down the water pipes, which should be a bit larger than the CR ones, and they always transport liquid from the higher end to the lower end. A pump can be placed anywhere on the line path to set the pump direction of the attached pipe.
I'm not sure I understand the idea. Can you explain more?
> But we don't have that amount of physics in the landscape, unfortunately.
Yeah. I really need to get back to that someday. "Given a pixel in the landscape, give me the lowest connected air pixel in the landscape"... how hard could it be.
> Can you explain more?
It would work like a line kit, but you can freely place start and end anywhere in the landscape. Liquid then automatically flows from one end to the other if there is liquid at the top end and no liquid at the bottom end. Think of it like a water hose. It's the equivalent of just digging a path to let the water flow, but it would also work over hills and doesn't disrupt your mining so much.
You then walk up to any position on the pipe with a hammer and build a pump. The pump then allows the pipe to also work from the bottom end to the top end. So if there's water at the bottom end and sky at the top end, it would get transported.
Powered by mwForum 2.29.7 © 1999-2015 Markus Wichitill