forked from cuberite/Core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
portal-worlds.lua
43 lines (31 loc) · 1.1 KB
/
portal-worlds.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
function HandlePortalCommand(Split, Player)
local NumParams = #Split
if (NumParams == 1) then
SendMessage(Player, "You are in world " .. Player:GetWorld():GetName())
return true
elseif (NumParams ~= 2) then
SendMessage(Player, "Usage: " .. Split[1] .. " [world]")
return true
end
if (Player:GetWorld():GetName() == Split[2]) then
SendMessageFailure( Player, "You are in " .. Split[2] .. "!" )
return true
elseif( Player:MoveToWorld(Split[2]) == false ) then
SendMessageFailure( Player, "Could not move to world " .. Split[2] .. "!" )
return true
end
SendMessageSuccess( Player, "Moved successfully to '" .. Split[2] .. "'! :D" )
return true
end
function HandleWorldsCommand(Split, Player)
local NumWorlds = 0
local Worlds = {}
cRoot:Get():ForEachWorld(function(World)
NumWorlds = NumWorlds + 1
Worlds[NumWorlds] = World:GetName()
end)
SendMessage(Player, "There are " .. NumWorlds .. " worlds:")
SendMessage(Player, table.concat(Worlds, ", "))
SendMessage(Player, "You are in world " .. Player:GetWorld():GetName())
return true
end