MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / RegisterAPI

Method RegisterAPI

src/ai/ai_info.cpp:32–55  ·  view source on GitHub ↗

static */

Source from the content-addressed store, hash-verified

30template <> SQInteger PushClassName<AIInfo, ScriptType::AI>(HSQUIRRELVM vm) { sq_pushstring(vm, "AIInfo"); return 1; }
31
32/* static */ void AIInfo::RegisterAPI(Squirrel &engine)
33{
34 /* Create the AIInfo class, and add the RegisterAI function */
35 DefSQClass<AIInfo, ScriptType::AI> SQAIInfo("AIInfo");
36 SQAIInfo.PreRegister(engine);
37 SQAIInfo.AddConstructor<void (AIInfo::*)()>(engine, "x");
38 SQAIInfo.DefSQAdvancedMethod(engine, &AIInfo::AddSetting, "AddSetting");
39 SQAIInfo.DefSQAdvancedMethod(engine, &AIInfo::AddLabels, "AddLabels");
40 SQAIInfo.DefSQConst(engine, ScriptConfigFlags{}.base(), "CONFIG_NONE");
41 SQAIInfo.DefSQConst(engine, ScriptConfigFlags{}.base(), "CONFIG_RANDOM"); // Deprecated, mapped to NONE.
42 SQAIInfo.DefSQConst(engine, ScriptConfigFlags{ScriptConfigFlag::Boolean}.base(), "CONFIG_BOOLEAN");
43 SQAIInfo.DefSQConst(engine, ScriptConfigFlags{ScriptConfigFlag::InGame}.base(), "CONFIG_INGAME");
44 SQAIInfo.DefSQConst(engine, ScriptConfigFlags{ScriptConfigFlag::Developer}.base(), "CONFIG_DEVELOPER");
45
46 /* Pre 1.2 had an AI prefix */
47 SQAIInfo.DefSQConst(engine, ScriptConfigFlags{}.base(), "AICONFIG_NONE");
48 SQAIInfo.DefSQConst(engine, ScriptConfigFlags{}.base(), "AICONFIG_RANDOM"); // Deprecated, mapped to NONE.
49 SQAIInfo.DefSQConst(engine, ScriptConfigFlags{ScriptConfigFlag::Boolean}.base(), "AICONFIG_BOOLEAN");
50 SQAIInfo.DefSQConst(engine, ScriptConfigFlags{ScriptConfigFlag::InGame}.base(), "AICONFIG_INGAME");
51
52 SQAIInfo.PostRegister(engine);
53 engine.AddMethod("RegisterAI", &AIInfo::Constructor, "tx");
54 engine.AddMethod("RegisterDummyAI", &AIInfo::DummyConstructor, "tx");
55}
56
57/* static */ SQInteger AIInfo::Constructor(HSQUIRRELVM vm)
58{

Callers

nothing calls this directly

Calls 8

PreRegisterMethod · 0.80
DefSQAdvancedMethodMethod · 0.80
DefSQConstMethod · 0.80
PostRegisterMethod · 0.80
AddMethodMethod · 0.80
AddClassBeginMethod · 0.80
AddClassEndMethod · 0.80
baseMethod · 0.45

Tested by

no test coverage detected