File: fireballclass.cpp

package info (click to toggle)
freespace2 24.2.0%2Brepack-1
  • links: PTS, VCS
  • area: non-free
  • in suites: forky, sid
  • size: 43,716 kB
  • sloc: cpp: 595,001; ansic: 21,741; python: 1,174; sh: 457; makefile: 248; xml: 181
file content (128 lines) | stat: -rw-r--r-- 3,843 bytes parent folder | download
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
//
//

#include "fireballclass.h"
#include "model.h"
#include "fireball/fireballs.h"

namespace scripting {
namespace api {


//**********HANDLE: Fireballclass
ADE_OBJ(l_Fireballclass, int, "fireballclass", "Fireball class handle");

ADE_FUNC(__tostring, l_Fireballclass, NULL, "Fireball class name", "string", "Fireball class unique id, or an empty string if handle is invalid")
{
	int idx;
	if(!ade_get_args(L, "o", l_Fireballclass.Get(&idx)))
		return ade_set_error(L, "s", "");

	if (!SCP_vector_inbounds(Fireball_info, idx))
		return ade_set_error(L, "s", "");

	return ade_set_args(L, "s", Fireball_info[idx].unique_id);
}

ADE_FUNC(__eq, l_Fireballclass, "fireballclass, fireballclass", "Checks if the two classes are equal", "boolean", "true if equal, false otherwise")
{
	int idx1,idx2;
	if(!ade_get_args(L, "oo", l_Fireballclass.Get(&idx1), l_Fireballclass.Get(&idx2)))
		return ade_set_error(L, "b", false);

	if (!SCP_vector_inbounds(Fireball_info, idx1))
		return ade_set_error(L, "b", false);

	if (!SCP_vector_inbounds(Fireball_info, idx2))
		return ade_set_error(L, "b", false);

	return ade_set_args(L, "b", idx1 == idx2);
}

ADE_VIRTVAR(UniqueID, l_Fireballclass, "string", "Fireball class name", "string", "Fireball class unique id, or empty string if handle is invalid")
{
	int idx;
	if(!ade_get_args(L, "o", l_Fireballclass.Get(&idx)))
		return ade_set_error(L, "s", "");

	if (!SCP_vector_inbounds(Fireball_info, idx))
		return ade_set_error(L, "s", "");

	if (ADE_SETTING_VAR)
		LuaError(L, "This property is read-only");

	return ade_set_args(L, "s", Fireball_info[idx].unique_id);
}

ADE_VIRTVAR(Filename, l_Fireballclass, NULL, "Fireball class animation filename (LOD 0)", "string", "Filename, or empty string if handle is invalid")
{
	int idx;
	if(!ade_get_args(L, "o", l_Fireballclass.Get(&idx)))
		return ade_set_error(L, "s", "");

	if (!SCP_vector_inbounds(Fireball_info, idx))
		return ade_set_error(L, "s", "");

	//Currently not settable as the bitmaps are only loaded once at level start
	if (ADE_SETTING_VAR)
		LuaError(L, "This property is read-only");

	return ade_set_args(L, "s", Fireball_info[idx].lod[0].filename);
}

ADE_VIRTVAR(NumberFrames, l_Fireballclass, NULL, "Amount of frames the animation has (LOD 0)", "number", "Amount of frames, or -1 if handle is invalid")
{
	int idx;
	if(!ade_get_args(L, "o", l_Fireballclass.Get(&idx)))
		return ade_set_error(L, "i", -1);

	if (!SCP_vector_inbounds(Fireball_info, idx))
		return ade_set_error(L, "i", -1);

	if (ADE_SETTING_VAR)
		LuaError(L, "This property is read-only");

	return ade_set_args(L, "i", Fireball_info[idx].lod[0].num_frames);
}

ADE_VIRTVAR(FPS, l_Fireballclass, NULL, "The FPS with which this fireball's animation is played (LOD 0)", "number", "FPS, or -1 if handle is invalid")
{
	int idx;
	if (!ade_get_args(L, "o", l_Fireballclass.Get(&idx)))
		return ade_set_error(L, "i", -1);

	if (!SCP_vector_inbounds(Fireball_info, idx))
		return ade_set_error(L, "i", -1);

	if (ADE_SETTING_VAR)
		LuaError(L, "This property is read-only");

	return ade_set_args(L, "i", Fireball_info[idx].lod[0].fps);
}

ADE_FUNC(isValid, l_Fireballclass, NULL, "Detects whether handle is valid", "boolean", "true if valid, false if handle is invalid, nil if a syntax/type error occurs")
{
	int idx;
	if(!ade_get_args(L, "o", l_Fireballclass.Get(&idx)))
		return ADE_RETURN_NIL;

	if (!SCP_vector_inbounds(Fireball_info, idx))
		return ADE_RETURN_FALSE;

	return ADE_RETURN_TRUE;
}

ADE_FUNC(getTableIndex, l_Fireballclass, NULL, "Gets the index value of the fireball class", "number", "index value of the fireball class")
{
	int idx;
	if(!ade_get_args(L, "o", l_Fireballclass.Get(&idx)))
		return ade_set_args(L, "i", -1);

	if (!SCP_vector_inbounds(Fireball_info, idx))
		return ade_set_args(L, "i", -1);

	return ade_set_args(L, "i", idx + 1);
}

}
}