File: Script.c

package info (click to toggle)
openclonk 8.1-4
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 169,520 kB
  • sloc: cpp: 180,479; ansic: 108,988; xml: 31,371; python: 1,223; php: 767; makefile: 145; sh: 101; javascript: 34
file content (51 lines) | stat: -rw-r--r-- 1,238 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/*
	Seeds
	Author: Clonkonaut

	For planting wheat or to get flour
*/

public func RejectUse(object clonk)
{
	// General inability?
	if(clonk->GetProcedure() != "WALK") return true;
	if (GBackSemiSolid(0, 0)) return true;
	/*
	This check might make sense, so that you can just hold the button and walk over the ground until the soil is fitting.
	However, you would never get the $NoSuitableGround$ message in that case.
	// Check soil below the Clonk's feet
	var ground_y = clonk->GetDefBottom() - clonk->GetY() + 1;
	if (GetMaterialVal("Soil", "Material", GetMaterial(0, ground_y)) == 0) return true;
	*/
	return false;
}

public func ControlUse(object clonk, int x, int y, bool box)
{
	var ground_y = clonk->GetDefBottom() - clonk->GetY() + 1;
	
	if (GetMaterialVal("Soil", "Material", GetMaterial(0, ground_y)) == 1)
	{
		// Plant!
		clonk->DoKneel();
		var wheat = CreateObjectAbove(Wheat, 0, ground_y, clonk->GetOwner());
		wheat->SetCon(1);
		wheat->Unripe();
		RemoveObject();
	}
	else
		clonk->Message("$NoSuitableGround$");

	return true;
}

protected func Hit()
{
	Sound("Hits::GeneralHit?");
}

public func IsMillIngredient() { return true; }

local Collectible = 1;
local Name = "$Name$";
local Description = "$Description$";