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 (68 lines) | stat: -rw-r--r-- 1,439 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/**
	Ladder Control
	Containes the basic functionality for ladder segments.

	@author Randrian
*/

local master;
local next_segment;
local prev_segment;

// Ladders are being searched for by FindObject and friends using a property.
local IsLadder = true;

public func SetMaster(object new_master, int new_index)
{
	master = new_master;
	return;
}

public func GetMaster()
{
	return master;
}

// Returns whether this segment and the other one are from the same ladder.
public func IsSameLadder(object other_segment)
{
	return GetMaster() == other_segment->GetMaster();
}

// Returns the segment (start x, start y, end x, end y, angle) on which the clonk can climb.
// The coordinate value must be specified with a precision of a 1000.
public func GetLadderData()
{
	// Normally (if not overloaded) interpret the first vertex as start and the second as end.
	return [
		GetX(1000) + 1000 * GetVertex(0, 0),
		GetY(1000) + 1000 * GetVertex(0, 1),
		GetX(1000) + 1000 * GetVertex(1, 0),
		GetY(1000) + 1000 * GetVertex(1, 1),
		0
	];
}

// Get the connected previous segment.
public func GetPreviousLadder()
{
	return prev_segment;
}

// Get the connected next segment.
public func GetNextLadder()
{
	return next_segment;
}

// Set the connected previous segment.
public func SetPreviousLadder(object ladder)
{
	prev_segment = ladder;
}

// Set the connected next segment.
public func SetNextLadder(object ladder)
{
	next_segment = ladder;
}