mirror of
https://github.com/OpenTTD/OpenTTD
synced 2026-01-23 12:14:11 +01:00
Add: [Script] Framework for loading/saving selected ScriptObject
This commit is contained in:
@@ -9,7 +9,17 @@
|
||||
|
||||
${SQUIRREL_INCLUDES}
|
||||
|
||||
static SQInteger ${APIUC}ObjectConstructor(HSQUIRRELVM vm)
|
||||
{
|
||||
return sq_throwerror(vm, "${APIUC}Object is not instantiable");
|
||||
}
|
||||
|
||||
void SQ${APIUC}_RegisterAll(Squirrel *engine)
|
||||
{
|
||||
DefSQClass<ScriptObject, ScriptType::${APIUC}> SQ${APIUC}Object("${APIUC}Object");
|
||||
SQ${APIUC}Object.PreRegister(engine);
|
||||
SQ${APIUC}Object.DefSQAdvancedStaticMethod(engine, &${APIUC}ObjectConstructor, "constructor");
|
||||
SQ${APIUC}Object.PostRegister(engine);
|
||||
|
||||
${SQUIRREL_REGISTER}
|
||||
}
|
||||
|
||||
@@ -84,6 +84,22 @@ protected:
|
||||
static ScriptInstance *active; ///< The global current active instance.
|
||||
};
|
||||
|
||||
/**
|
||||
* Save this object.
|
||||
* Must push 2 elements on the stack:
|
||||
* - the name (classname without "Script") of the object (OT_STRING)
|
||||
* - the data for the object (any supported types)
|
||||
* @return True iff saving this type is supported.
|
||||
*/
|
||||
virtual bool SaveObject(HSQUIRRELVM) { return false; }
|
||||
|
||||
/**
|
||||
* Load this object.
|
||||
* The data for the object must be pushed on the stack before the call.
|
||||
* @return True iff loading this type is supported.
|
||||
*/
|
||||
virtual bool LoadObject(HSQUIRRELVM) { return false; }
|
||||
|
||||
public:
|
||||
/**
|
||||
* Store the latest result of a DoCommand per company.
|
||||
|
||||
Reference in New Issue
Block a user