From 2a4fa72d107fd5bcb8d77c1f880c9004f0bba4b1 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sun, 19 Jan 2014 13:43:42 +0000 Subject: Updated core --- MCServer/Plugins/Core | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'MCServer') diff --git a/MCServer/Plugins/Core b/MCServer/Plugins/Core index 1d524e4e7..e96955202 160000 --- a/MCServer/Plugins/Core +++ b/MCServer/Plugins/Core @@ -1 +1 @@ -Subproject commit 1d524e4e7d2b1178f2b772c95766c63c338ad711 +Subproject commit e9695520248ef32f229162ba2b0ee6792749777d -- cgit v1.2.3 From 1c05831974c827366b2c028b1906320ed1e88f92 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sun, 19 Jan 2014 16:20:38 +0100 Subject: Updated Core. --- MCServer/Plugins/Core | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'MCServer') diff --git a/MCServer/Plugins/Core b/MCServer/Plugins/Core index e96955202..759cf48ba 160000 --- a/MCServer/Plugins/Core +++ b/MCServer/Plugins/Core @@ -1 +1 @@ -Subproject commit e9695520248ef32f229162ba2b0ee6792749777d +Subproject commit 759cf48ba3f1409e6d7b60cb821ee17e589bdef8 -- cgit v1.2.3 From 41618bf242e66744431a1d28e0409f543fb240e4 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sun, 19 Jan 2014 23:49:19 +0100 Subject: Changed the cWorld::ScheduleTask() signature. Now it takes the delay in ticks as an argument, and a cTask descendant as the task to run. Lua API has been updated similarly. --- MCServer/Plugins/Debuggers/Debuggers.lua | 40 ++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) (limited to 'MCServer') diff --git a/MCServer/Plugins/Debuggers/Debuggers.lua b/MCServer/Plugins/Debuggers/Debuggers.lua index 8512fbd5f..2d2d2736d 100644 --- a/MCServer/Plugins/Debuggers/Debuggers.lua +++ b/MCServer/Plugins/Debuggers/Debuggers.lua @@ -52,6 +52,7 @@ function Initialize(Plugin) PM:BindCommand("/fill", "debuggers", HandleFill, "- Fills all block entities in current chunk with junk"); PM:BindCommand("/fr", "debuggers", HandleFurnaceRecipe, "- Shows the furnace recipe for the currently held item"); PM:BindCommand("/ff", "debuggers", HandleFurnaceFuel, "- Shows how long the currently held item would burn in a furnace"); + PM:BindCommand("/sched", "debuggers", HandleSched, "- Schedules a simple countdown using cWorld:ScheduleTask()"); Plugin:AddWebTab("Debuggers", HandleRequest_Debuggers); @@ -955,6 +956,45 @@ end +function HandleSched(a_Split, a_Player) + local World = a_Player:GetWorld() + + -- Schedule a broadcast of a countdown message: + for i = 1, 10 do + World:ScheduleTask(i * 20, + function(a_World) + a_World:BroadcastChat("Countdown: " .. 11 - i) + end + ) + end + + -- Schedule a broadcast of the final message and a note to the originating player + -- Note that we CANNOT us the a_Player in the callback - what if the player disconnected? + -- Therefore we store the player's EntityID + local PlayerID = a_Player:GetUniqueID() + World:ScheduleTask(220, + function(a_World) + a_World:BroadcastChat("Countdown: BOOM") + a_World:DoWithEntityByID(PlayerID, + function(a_Entity) + if (a_Entity:IsPlayer()) then + -- Although unlikely, it is possible that this player is not the originating player + -- However, I leave this as an excercise to you to fix this "bug" + local Player = tolua.cast(a_Entity, "cPlayer") + Player:SendMessage("Countdown finished") + end + end + ) + end + ) + + return true +end + + + + + function HandleRequest_Debuggers(a_Request) local FolderContents = cFile:GetFolderContents("./"); return "

The following objects have been returned by cFile:GetFolderContents():

  • " .. table.concat(FolderContents, "
  • ") .. "

"; -- cgit v1.2.3 From e9e9593e6d2d7bfc89e9e56f834fb006481f18e0 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sun, 19 Jan 2014 23:50:49 +0100 Subject: APIDump: Updated cWorld:ScheduleTask()'s description. --- MCServer/Plugins/APIDump/APIDesc.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'MCServer') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index bf32ea8c2..c548b620c 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -2087,7 +2087,7 @@ end QueueSetBlock = { Params = "BlockX, BlockY, BlockZ, BlockType, BlockMeta, TickDelay", Return = "", Notes = "Queues the block to be set to the specified blocktype and meta after the specified amount of game ticks. Uses SetBlock() for the actual setting, so simulators are woken up and block entities are handled correctly." }, QueueTask = { Params = "TaskFunction", Return = "", Notes = "Queues the specified function to be executed in the tick thread. This is the primary means of interaction with a cWorld from the WebAdmin page handlers (see {{WebWorldThreads}}). The function signature is
function()
All return values from the function are ignored. Note that this function is actually called *after* the QueueTask() function returns." }, RegenerateChunk = { Params = "ChunkX, ChunkZ", Return = "", Notes = "Queues the specified chunk to be re-generated, overwriting the current data. To queue a chunk for generating only if it doesn't exist, use the GenerateChunk() instead." }, - ScheduleTask = { Params = "TaskFunction, Ticks", Return = "", Notes = "Queues the specified function to be executed in the world's tick thread after a number of ticks. This enables operations to be queued for execution in the future. The function signature is
function({{cWorld|World}})
All return values from the function are ignored." }, + ScheduleTask = { Params = "DelayTicks, TaskFunction", Return = "", Notes = "Queues the specified function to be executed in the world's tick thread after a the specified number of ticks. This enables operations to be queued for execution in the future. The function signature is
function({{cWorld|World}})
All return values from the function are ignored." }, SendBlockTo = { Params = "BlockX, BlockY, BlockZ, {{cPlayer|Player}}", Return = "", Notes = "Sends the block at the specified coords to the specified player's client, as an UpdateBlock packet." }, SetBlock = { Params = "BlockX, BlockY, BlockZ, BlockType, BlockMeta", Return = "", Notes = "Sets the block at the specified coords, replaces the block entities for the previous block type, creates a new block entity for the new block, if appropriate, and wakes up the simulators. This is the preferred way to set blocks, as opposed to FastSetBlock(), which is only to be used under special circumstances." }, SetBlockMeta = -- cgit v1.2.3 From 2407a67906c408013f05cd5878e1761608fe24f0 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sun, 19 Jan 2014 23:56:49 +0100 Subject: APIDump: Added notes about objects across cWorld's task execution. --- MCServer/Plugins/APIDump/APIDesc.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'MCServer') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index c548b620c..347299a50 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -2085,9 +2085,9 @@ end QueueBlockForTick = { Params = "BlockX, BlockY, BlockZ, TicksToWait", Return = "", Notes = "Queues the specified block to be ticked after the specified number of gameticks." }, QueueSaveAllChunks = { Params = "", Return = "", Notes = "Queues all chunks to be saved in the world storage thread" }, QueueSetBlock = { Params = "BlockX, BlockY, BlockZ, BlockType, BlockMeta, TickDelay", Return = "", Notes = "Queues the block to be set to the specified blocktype and meta after the specified amount of game ticks. Uses SetBlock() for the actual setting, so simulators are woken up and block entities are handled correctly." }, - QueueTask = { Params = "TaskFunction", Return = "", Notes = "Queues the specified function to be executed in the tick thread. This is the primary means of interaction with a cWorld from the WebAdmin page handlers (see {{WebWorldThreads}}). The function signature is
function()
All return values from the function are ignored. Note that this function is actually called *after* the QueueTask() function returns." }, + QueueTask = { Params = "TaskFunction", Return = "", Notes = "Queues the specified function to be executed in the tick thread. This is the primary means of interaction with a cWorld from the WebAdmin page handlers (see {{WebWorldThreads}}). The function signature is
function()
All return values from the function are ignored. Note that this function is actually called *after* the QueueTask() function returns. Note that it is unsafe to store references to MCServer objects, such as entities, across from the caller to the task handler function; store the EntityID instead." }, RegenerateChunk = { Params = "ChunkX, ChunkZ", Return = "", Notes = "Queues the specified chunk to be re-generated, overwriting the current data. To queue a chunk for generating only if it doesn't exist, use the GenerateChunk() instead." }, - ScheduleTask = { Params = "DelayTicks, TaskFunction", Return = "", Notes = "Queues the specified function to be executed in the world's tick thread after a the specified number of ticks. This enables operations to be queued for execution in the future. The function signature is
function({{cWorld|World}})
All return values from the function are ignored." }, + ScheduleTask = { Params = "DelayTicks, TaskFunction", Return = "", Notes = "Queues the specified function to be executed in the world's tick thread after a the specified number of ticks. This enables operations to be queued for execution in the future. The function signature is
function({{cWorld|World}})
All return values from the function are ignored. Note that it is unsafe to store references to MCServer objects, such as entities, across from the caller to the task handler function; store the EntityID instead." }, SendBlockTo = { Params = "BlockX, BlockY, BlockZ, {{cPlayer|Player}}", Return = "", Notes = "Sends the block at the specified coords to the specified player's client, as an UpdateBlock packet." }, SetBlock = { Params = "BlockX, BlockY, BlockZ, BlockType, BlockMeta", Return = "", Notes = "Sets the block at the specified coords, replaces the block entities for the previous block type, creates a new block entity for the new block, if appropriate, and wakes up the simulators. This is the preferred way to set blocks, as opposed to FastSetBlock(), which is only to be used under special circumstances." }, SetBlockMeta = -- cgit v1.2.3