forked from Mirrors/openclonk
Steam Engine: Use fuel as liquid, finished
The pump was blocked, because the steam engine did not insert enough materialliquid_container
parent
7a1b7d6258
commit
0a77b58b6a
|
@ -151,7 +151,9 @@ protected func WorkAbort()
|
|||
func RefillFuel()
|
||||
{
|
||||
// Check if there is still enough fuel available.
|
||||
if (GetFuelAmount() <= 0) // || IsWorking() && GetFuelAmount() < GetLiquidContainerMaxFillLevel() / 2)
|
||||
var no_fuel = GetFuelAmount() <= 0;
|
||||
var should_keep_reserve = IsWorking() && GetNeutralPipe() && GetFuelAmount() < GetLiquidContainerMaxFillLevel() / 2;
|
||||
if (no_fuel || should_keep_reserve)
|
||||
{
|
||||
var max_extracted = GetLiquidFillLevelRemaining();
|
||||
var fuel_extracted;
|
||||
|
@ -199,6 +201,20 @@ func Smoking()
|
|||
Smoke(-20 * GetCalcDir() + RandomX(-2, 2), -24, 10);
|
||||
}
|
||||
|
||||
func PutLiquid(string liquid_name, int amount, object source)
|
||||
{
|
||||
// Convert to fuel on insertion
|
||||
var fuel_value = GetFuelValue(liquid_name, amount);
|
||||
if (_inherited("Fuel", fuel_value, source) != 0)
|
||||
{
|
||||
return amount; // return the requested amount, so that the correct value is deducted from the source
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
func GetFuelValue(string liquid, int amount)
|
||||
{
|
||||
if (liquid == "Oil") return amount;
|
||||
|
|
|
@ -1141,7 +1141,6 @@ global func Test21_OnStart(int plr)
|
|||
var engine = CreateObjectAbove(SteamEngine, 70, 160, plr);
|
||||
var barrel = engine->CreateContents(Barrel, 1);
|
||||
barrel->SetLiquidContainer("Oil", 10);
|
||||
//engine->CreateContents(Coal); // give some fuel so that the pump can start working
|
||||
|
||||
// Power consumer: one pump.
|
||||
var pump = CreateObjectAbove(Pump, 124, 160, plr);
|
||||
|
@ -1153,9 +1152,9 @@ global func Test21_OnStart(int plr)
|
|||
|
||||
// Power consumer: armory.
|
||||
var armory = CreateObjectAbove(Armory, 255, 160, plr);
|
||||
armory->CreateContents(Firestone, 10);
|
||||
armory->CreateContents(Metal, 10);
|
||||
armory->AddToQueue(IronBomb, 10);
|
||||
armory->CreateContents(Firestone, 20);
|
||||
armory->CreateContents(Metal, 20);
|
||||
armory->AddToQueue(IronBomb, 20);
|
||||
|
||||
// Log what the test is about.
|
||||
Log("A steam engine fueled by an oil field via pump.");
|
||||
|
@ -1165,7 +1164,7 @@ global func Test21_OnStart(int plr)
|
|||
global func Test21_Completed()
|
||||
{
|
||||
// One wood is being burned as fuel by the steam engine.
|
||||
if (ObjectCount(Find_ID(IronBomb)) >= 10)
|
||||
if (ObjectCount(Find_ID(IronBomb)) >= 20)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue