1
0

APIDump: Fixed the WritingPlugin article.

The code is no longer weirdly indented in the browser, and links are relative to the API docs root.
This commit is contained in:
madmaxoft 2013-12-27 14:46:07 +01:00
parent f0ca18d72a
commit 270d79d47b

View File

@ -2,7 +2,6 @@
<html>
<head>
<!--MCServer, a divison of McDonalds Enterprises-->
<title>MCS Plugin Tutorial</title>
<link rel="stylesheet" type="text/css" href="main.css" />
<link rel="stylesheet" type="text/css" href="prettify.css" />
@ -72,7 +71,7 @@
<h2>Registering hooks</h2>
<p>
Hooks are things that MCServer calls when an internal event occurs. For example, a hook is fired when a player places a block, moves,
logs on, eats, and many other things. For a full list, see <a href="http://mc-server.xoft.cz/LuaAPI/">the API documentation</a>.
logs on, eats, and many other things. For a full list, see <a href="index.html">the API documentation</a>.
</p>
<p>
A hook can be either informative or overridable. In any case, returning false will not trigger a response, but returning true will cancel
@ -207,23 +206,35 @@
end
function Explode(Split, Player)
if #Split ~= 2
SendMessage(Player, "Usage: /explode [playername]") -- There was more or less than one argument (excluding the /explode bit)
else
local ExplodePlayer = function(Explodee) -- Create a callback ExplodePlayer with parameter Explodee, which MCS calls for every player on the server
if (Explodee:GetName() == Split[2] then -- If the player we are currently at is the one we specified as the parameter...
Player:GetWorld():DoExplosionAt(Explodee:GetPosX(), Explodee:GetPosY(), Explodee:GetPosZ(), false, esPlugin) -- Explode 'em; see API docs for further details of this function
SendMessageSuccess(Player, Split[2] .. " was successfully exploded") -- Success!
return true -- Break out
if (#Split ~= 2) then
-- There was more or less than one argument (excluding the "/explode" bit)
-- Send the proper usage to the player and exit
SendMessage(Player, "Usage: /explode [playername]")
return true
end
-- Create a callback ExplodePlayer with parameter Explodee, which MCS calls for every player on the server
local HasExploded = false
local ExplodePlayer = function(Explodee)
-- If the player we are currently at is the one we specified as the parameter
if (Explodee:GetName() == Split[2]) then
-- Create an explosion at the same position as they are; see <a href="cWorld.html">API docs</a> for further details of this function
Player:GetWorld():DoExplosionAt(Explodee:GetPosX(), Explodee:GetPosY(), Explodee:GetPosZ(), false, esPlugin)
SendMessageSuccess(Player, Split[2] .. " was successfully exploded")
HasExploded = true;
return true -- Signalize to MCS that we do not need to call this callback for any more players
end
end
cRoot:Get():FindAndDoWithPlayer(Split[2], ExplodePlayer) -- Tells MCS to loop through all players and call the callback above with the Player object it has found
-- Tell MCS to loop through all players and call the callback above with the Player object it has found
cRoot:Get():FindAndDoWithPlayer(Split[2], ExplodePlayer)
SendMessageFailure(Player, Split[2] .. " was not found") -- We have not broken out so far, therefore, the player must not exist, send failure
if not(HasExploded) then
-- We have not broken out so far, therefore, the player must not exist, send failure
SendMessageFailure(Player, Split[2] .. " was not found")
end
return true -- Concluding return
return true
end
function OnCollectingPickup(Player, Pickup) -- Again, see the API docs for parameters of all hooks. In this case, it is a Player and Pickup object
@ -237,7 +248,7 @@
<p>
Make sure to read the comments for a description of what everything does. Also be sure to return true for all <b>command</b> handlers, unless you want MCS to print out an "Unknown command" message
when the command gets executed :P. Make sure to follow standards - use CoreMessaging.lua functions for messaging, dashes for no parameter commands and tildes for vice versa,
and finally, <a href="http://mc-server.xoft.cz/LuaAPI/">the API documentation</a> is your friend!
and finally, <a href="index.html">the API documentation</a> is your friend!
</p>
<p>
Happy coding ;)
@ -247,7 +258,5 @@
prettyPrint();
</script>
</div>
<hr />
<footer>This tutorial was brought you by Aperture Science, in conjunction with McDonalds Enterprises.<br /></footer>
</body>
</html>