From e301ff48fa88d366c3e1f22c4047385f8ae74052 Mon Sep 17 00:00:00 2001 From: Mattes D Date: Thu, 19 Mar 2015 12:57:00 +0100 Subject: APIDump: Removed the tolua.cast() example. The example was all wrong and the function is normally not needed at all (#1789). Fixes #1787 --- MCServer/Plugins/APIDump/APIDesc.lua | 29 +++-------------------------- 1 file changed, 3 insertions(+), 26 deletions(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index 63fccb2f6..92cdb7415 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -2871,41 +2871,18 @@ end This class represents the tolua bridge between the Lua API and MCServer. It supports some low level operations and queries on the objects. See also the tolua++'s documentation at {{http://www.codenix.com/~tolua/tolua++.html#utilities}}. Normally you shouldn't use any of these - functions except for cast() and type() + functions except for type() ]], Functions = { - cast = { Params = "Object, TypeStr", Return = "Object", Notes = "Casts the object to the specified type through the inheritance hierarchy." }, + cast = { Params = "Object, TypeStr", Return = "Object", Notes = "Casts the object to the specified type.
Note: This is a potentially unsafe operation and it could crash the server. There is normally no need to use this function at all, so don't use it unless you know exactly what you're doing." }, getpeer = { Params = "", Return = "", Notes = "" }, inherit = { Params = "", Return = "", Notes = "" }, releaseownership = { Params = "", Return = "", Notes = "" }, setpeer = { Params = "", Return = "", Notes = "" }, takeownership = { Params = "", Return = "", Notes = "" }, - type = { Params = "Object", Return = "TypeStr", Notes = "Returns a string representing the type of the object. This works similar to Lua's built-in type() function, but recognizes the underlying C++ types, too." }, + type = { Params = "Object", Return = "TypeStr", Notes = "Returns a string representing the type of the object. This works similar to Lua's built-in type() function, but recognizes the underlying C++ classes, too." }, }, - AdditionalInfo = - { - { - Header = "Usage example", - Contents = - [[ - The tolua.cast() function is normally used to cast between related types. For example in the - hook callbacks you often receive a generic {{cEntity}} object, when in fact you know that the - object is a {{cMonster}}. You can cast the object to access its cMonster functions: -
-function OnTakeDamage(a_ReceiverEntity, TDI)
-	if (a_ReceiverEntity.IsMob()) then
-		local Mob = tolua.cast(a_ReceiverEntity, "cMonster");  -- Cast a_ReceiverEntity into a {{cMonster}} instance
-		if (Mob:GetMonsterType() == cMonster.mtSheep) then
-			local Sheep = tolua.cast(Mob, "cSheep");  -- Cast Mob into a {{cSheep}} instance
-			-- Do something sheep-specific
-		end
-	end
-end
-
- ]], - } - } -- AdditionalInfo }, -- tolua Globals = -- cgit v1.2.3