Example #1
0
/*
	This function is called when a some script is loaded.
*/
EXPORT void ScriptLoad(HSQUIRRELVM pVM)
{
	// Register constants for this script:
	RegisterConstant(pVM, "TEST_FLOAT_CONST", 29.0f);
	RegisterConstant(pVM, "ANOTHER_CONST", "String constant");

	// Register functions for this script:
	RegisterFunction(pVM, "helloWorld", sq_helloworld, 1, "f");			// only 1 float parameter for function 'helloWorld'
	RegisterFunction(pVM, "createVehicleEx", sq_createVehicleEx);		// any template/count of paramaters for function 'createVehicleEx'
	//..., "fantasticFunction", sq_fantasticFunction, 6, "siifsb");		// template: ( string, integer, integer, float, string, bool ) - for function 'fantasticFunction'

	LogPrintf("[%s] A script got loaded!", m_szModuleName);
}
Example #2
0
bool CSquirrel::Execute()
{
	// Add the script name constant
	RegisterConstant("SCRIPT_NAME", m_strName);

	// Add the script path constant
	RegisterConstant("SCRIPT_PATH", m_strPath);

	// Load and compile the script
	if(SQ_FAILED(sqstd_dofile(m_pVM, m_strPath.Get(), SQFalse, SQTrue)))
		return false;

	return true;
}
Example #3
0
bool CScript::Execute()
{
	// Add the script name constant
	RegisterConstant("SCRIPT_NAME", m_MetaFile.m_File);

	// Add the script path constant
	RegisterConstant("SCRIPT_PATH", m_MetaFile.ToFullPath());

	if(lua_pcall(m_pVM, 0, LUA_MULTRET, 0) == 0)
	{
		return true;
	}
	else
	{
		PrintLuaError("Script execute, %s", m_MetaFile.ToFullPath().Get());
		return false;
	}
}
void CScriptingManager::RegisterDefaultConstants()
{
	RegisterConstant("MAX_PLAYERS", MAX_PLAYERS);
	RegisterConstant("MAX_VEHICLES", MAX_VEHICLES);
	RegisterConstant("MAX_OBJECTS", MAX_OBJECTS);
	RegisterConstant("MAX_CHECKPOINTS", MAX_CHECKPOINTS);
	RegisterConstant("MAX_BLIPS", MAX_BLIPS);
	RegisterConstant("MAX_ACTORS", MAX_ACTORS);
	RegisterConstant("MAX_NAME_LENGTH", MAX_NAME_LENGTH);
	// TODO: Merge all into INVALID_ENTITY_ID or leave as is?
	RegisterConstant("INVALID_PLAYER_ID", INVALID_ENTITY_ID);
	RegisterConstant("INVALID_VEHICLE_ID", INVALID_ENTITY_ID);
	RegisterConstant("INVALID_OBJECT_ID", INVALID_ENTITY_ID);
	RegisterConstant("INVALID_ACTOR_ID", INVALID_ENTITY_ID);
	RegisterConstant("INVALID_CHECKPOINT_ID", INVALID_ENTITY_ID);
	RegisterConstant("INVALID_BLIP_ID", INVALID_ENTITY_ID);
	RegisterConstant("INVALID_PICKUP_ID", INVALID_ENTITY_ID);
	RegisterConstant("IVMP_VERSION", MOD_VERSION_STRING);
}