From 6cad07c4295dbc720992335a0f114f468cb2d670 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 24 Oct 2013 12:24:11 +0200 Subject: APIDump: Documented cItemGrid and cPlayer. --- MCServer/Plugins/APIDump/APIDesc.lua | 105 +++++++++++++++++++++++++---------- 1 file changed, 75 insertions(+), 30 deletions(-) (limited to 'MCServer') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index 0940931cd..3b459e686 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -1260,9 +1260,12 @@ local Item5 = cItem(E_ITEM_DIAMOND_CHESTPLATE, 1, 0, "thorns=1;unbreaking=3"); { Params = "X, Y", Return = "", Notes = "Destroys the item in the specified slot" }, }, GetFirstEmptySlot = { Params = "", Return = "number", Notes = "Returns the SlotNumber of the first empty slot, -1 if all slots are full" }, + GetFirstUsedSlot = { Params = "", Return = "number", Notes = "Returns the SlotNumber of the first non-empty slot, -1 if all slots are empty" }, GetHeight = { Params = "", Return = "number", Notes = "Returns the Y dimension of the grid" }, GetLastEmptySlot = { Params = "", Return = "number", Notes = "Returns the SlotNumber of the last empty slot, -1 if all slots are full" }, + GetLastUsedSlot = { Params = "", Return = "number", Notes = "Returns the SlotNumber of the last non-empty slot, -1 if all slots are empty" }, GetNextEmptySlot = { Params = "StartFrom", Return = "number", Notes = "Returns the SlotNumber of the first empty slot following StartFrom, -1 if all the following slots are full" }, + GetNextUsedSlot = { Params = "StartFrom", Return = "number", Notes = "Returns the SlotNumber of the first non-empty slot following StartFrom, -1 if all the following slots are full" }, GetNumSlots = { Params = "", Return = "number", Notes = "Returns the total number of slots in the grid (Width * Height)" }, GetSlot = { @@ -1581,42 +1584,84 @@ a_Player:OpenWindow(Window); cPlayer = { - Desc = [[cPlayer describes a human player in the server. cPlayer inherits all functions and members of {{cPawn|cPawn}} -]], + Desc = [[ + This class describes a player in the server. cPlayer inherits all functions and members of + {{cPawn|cPawn}}. It handles all the aspects of the gameplay, such as hunger, sprinting, inventory + etc. + ]], Functions = { - GetEyeHeight = { Return = "number" }, - GetEyePosition = { Return = "{{Vector3d|EyePositionVector}}" }, - GetFlying = { Return = "bool" }, - GetStance = { Return = "number" }, - GetInventory = { Return = "{{cInventory|Inventory}}" }, + AddFoodExhaustion = { Params = "Exhaustion", Return = "", Notes = "Adds the specified number to the food exhaustion. Only positive numbers expected." }, + AddToGroup = { Params = "GroupName", Return = "", Notes = "Temporarily adds the player to the specified group. The assignment is lost when the player disconnects." }, + CanUseCommand = { Params = "Command", Return = "bool", Notes = "Returns true if the player is allowed to use the specified command." }, + CloseWindow = { Params = "[CanRefuse]", Return = "", Notes = "Closes the currently open UI window. If CanRefuse is true (default), the window may refuse the closing." }, + CloseWindowIfID = { Params = "WindowID, [CanRefuse]", Return = "", Notes = "Closes the currently open UI window if its ID matches the given ID. If CanRefuse is true (default), the window may refuse the closing." }, + Feed = { Params = "AddFood, AddSaturation", Return = "bool", Notes = "Tries to add the specified amounts to food level and food saturation level (only positive amounts expected). Returns true if player was hungry and the food was consumed, false if too satiated." }, + FoodPoison = { Params = "NumTicks", Return = "", Notes = "Starts the food poisoning for the specified amount of ticks; if already foodpoisoned, sets FoodPoisonedTicksRemaining to the larger of the two" }, + GetAirLevel = { Params = "", Return = "number", Notes = "Returns the air level (number of ticks of air left)." }, + GetClientHandle = { Params = "", Return = "{{cClientHandle}}", Notes = "Returns the client handle representing the player's connection. May be nil (AI players)." }, + GetColor = { Return = "string", Notes = "Returns the full color code to be used for this player (based on the first group). Prefix player messages with this code." }, + GetEquippedItem = { Params = "", Return = "{{cItem}}", Notes = "Returns the item that the player is currently holding; empty item if holding nothing." }, + GetEyeHeight = { Return = "number", Notes = "Returns the height of the player's eyes, in absolute coords" }, + GetEyePosition = { Return = "{{Vector3d|EyePositionVector}}", Notes = "Returns the position of the player's eyes, as a {{Vector3d}}" }, + GetFoodExhaustionLevel = { Params = "", Return = "number", Notes = "Returns the food exhaustion level" }, + GetFoodLevel = { Params = "", Return = "number", Notes = "Returns the food level (number of half-drumsticks on-screen)" }, + GetFoodPoisonedTicksRemaining = { Params = "", Return = "", Notes = "Returns the number of ticks left for the food posoning effect" }, + GetFoodSaturationLevel = { Params = "", Return = "number", Notes = "Returns the food saturation (overcharge of the food level, is depleted before food level)" }, + GetFoodTickTimer = { Params = "", Return = "", Notes = "Returns the number of ticks past the last food-based heal or damage action; when this timer reaches 80, a new heal / damage is applied." }, GetGameMode = { Return = "{{eGameMode|GameMode}}", Notes = "Returns the player's gamemode. The player may have their gamemode unassigned, in which case they inherit the gamemode from the current {{cWorld|world}}.
NOTE: Instead of comparing the value returned by this function to the gmXXX constants, use the IsGameModeXXX() functions. These functions handle the gamemode inheritance automatically."}, - GetIP = { Return = "string" }, - SetGameMode = { Return = "" }, - MoveTo = { Return = "" }, - GetClientHandle = { Return = "{{cClientHandle|ClientHandle}}" }, - SendMessage = { Return = "" }, - GetName = { Return = "String" }, - SetName = { Return = "" }, - AddToGroup = { Return = "" }, - CanUseCommand = { Return = "bool" }, - HasPermission = { Return = "bool" }, - IsInGroup = { Return = "bool" }, - GetColor = { Return = "string" }, - TossItem = { Return = "" }, - Heal = { Return = "" }, - TakeDamage = { Return = "" }, - KilledBy = { Return = "" }, - Respawn = { Return = "" }, - SetVisible = { Return = "" }, - IsVisible = { Return = "bool" }, - MoveToWorld = { Return = "bool" }, - LoadPermissionsFromDisk = { Return = "" }, - GetGroups = { Return = "list<{{cGroup|cGroup}}>" }, - GetResolvedPermissions = { Return = "string" }, + GetGroups = { Return = "array-table of {{cGroup}}", Notes = "Returns all the groups that this player is member of, as a table. The groups are stored in the array part of the table, beginning with index 1."}, + GetIP = { Return = "string", Notes = "Returns the IP address of the player, if available. Returns an empty string if there's no IP to report."}, + GetInventory = { Return = "{{cInventory|Inventory}}", Notes = "Returns the player's inventory"}, + GetMaxSpeed = { Params = "", Return = "number", Notes = "Returns the player's current maximum speed (as reported by the 1.6.1+ protocols)" }, + GetName = { Return = "string", Notes = "Returns the player's name" }, + GetNormalMaxSpeed = { Params = "", Return = "number", Notes = "Returns the player's maximum walking speed (as reported by the 1.6.1+ protocols)" }, + GetResolvedPermissions = { Return = "array-table of string", Notes = "Returns all the player's permissions, as a table. The permissions are stored in the array part of the table, beginning with index 1." }, + GetSprintingMaxSpeed = { Params = "", Return = "number", Notes = "Returns the player's maximum sprinting speed (as reported by the 1.6.1+ protocols)" }, + GetStance = { Return = "number", Notes = "Returns the player's stance (Y-pos of player's eyes)" }, + GetThrowSpeed = { Params = "SpeedCoeff", Return = "{{Vector3d}}", Notes = "Returns the speed vector for an object thrown with the specified speed coeff. Basically returns the normalized look vector multiplied by the coeff, with a slight random variation." }, + GetThrowStartPos = { Params = "", Return = "{{Vector3d}}", Notes = "Returns the position where the projectiles should start when thrown by this player." }, + GetWindow = { Params = "", Return = "{{cWindow}}", Notes = "Returns the currently open UI window. If the player doesn't have any UI window open, returns the inventory window." }, + HasPermission = { Params = "PermissionString", Return = "bool", Notes = "Returns true if the player has the specified permission" }, + Heal = { Params = "HitPoints", Return = "", Notes = "Heals the player by the specified amount of HPs. Only positive amounts are expected. Sends a health update to the client." }, + IsEating = { Params = "", Return = "bool", Notes = "Returns true if the player is currently eating the item in their hand." }, + IsGameModeAdventure = { Params = "", Return = "bool", Notes = "Returns true if the player is in the gmAdventure gamemode, or has their gamemode unset and the world is a gmAdventure world." }, + IsGameModeCreative = { Params = "", Return = "bool", Notes = "Returns true if the player is in the gmCreative gamemode, or has their gamemode unset and the world is a gmCreative world." }, + IsGameModeSurvival = { Params = "", Return = "bool", Notes = "Returns true if the player is in the gmSurvival gamemode, or has their gamemode unset and the world is a gmSurvival world." }, + IsInGroup = { Params = "GroupNameString", Return = "bool", Notes = "Returns true if the player is a member of the specified group." }, + IsOnGround = { Params = "", Return = "bool", Notes = "Returns true if the player is on ground (not falling, not jumping, not flying)" }, + IsSatiated = { Params = "", Return = "bool", Notes = "Returns true if the player is satiated (cannot eat)." }, + IsSubmerged = { Params = "", Return = "bool", Notes = "Returns true if the player is submerged in water (the player's head is in a water block)" }, + IsSwimming = { Params = "", Return = "bool", Notes = "Returns true if the player is swimming in water (the player's feet are in a water block)" }, + IsVisible = { Params = "", Return = "bool", Notes = "Returns true if the player is visible to other players" }, + LoadPermissionsFromDisk = { Params = "", Return = "", Notes = "Reloads the player's permissions from the disk. This loses any temporary changes made to the player's groups." }, + MoveTo = { Params = "{{Vector3d|NewPosition}}", Return = "Tries to move the player into the specified position." }, + MoveToWorld = { Params = "WorldName", Return = "bool", Return = "Moves the player to the specified world. Returns true if successful." }, + OpenWindow = { Params = "{{cWindow|Window}}", Return = "", Notes = "Opens the specified UI window for the player." }, + RemoveFromGroup = { Params = "GroupName", Return = "", Notes = "Temporarily removes the player from the specified group. This change is lost when the player disconnects." }, + Respawn = { Params = "", Return = "", Notes = "Restores the health, extinguishes fire, makes visible and sends the Respawn packet." }, + SendMessage = { Params = "MessageString", Return = "", Notes = "Sends the specified message to the player." }, + SetCrouch = { Params = "IsCrouched", Return = "", Notes = "Sets the crouch state, broadcasts the change to other players." }, + SetFoodExhaustionLevel = { Params = "ExhaustionLevel", Return = "", Notes = "Sets the food exhaustion to the specified level." }, + SetFoodLevel = { Params = "FoodLevel", Return = "", Notes = "Sets the food level (number of half-drumsticks on-screen)" }, + SetFoodPoisonedTicksRemaining = { Params = "FoodPoisonedTicksRemaining", Return = "", Notes = "Sets the number of ticks remaining for food poisoning. Doesn't send foodpoisoning effect to the client, use FoodPoison() for that." }, + SetFoodSaturationLevel = { Params = "FoodSaturationLevel", Return = "", Notes = "Sets the food saturation (overcharge of the food level)." }, + SetFoodTickTimer = { Params = "FoodTickTimer", Return = "", Notes = "Sets the number of ticks past the last food-based heal or damage action; when this timer reaches 80, a new heal / damage is applied." }, + SetGameMode = { Params = "{{eGameMode|NewGameMode}}", Return = "", Notes = "Sets the gamemode for the player. The new gamemode overrides the world's default gamemode, unless it is set to gmInherit." }, + SetName = { Params = "Name", Return = "", Notes = "Sets the player name. This rename will NOT be visible to any players already in the server who are close enough to see this player." }, + SetNormalMaxSpeed = { Params = "NormalMaxSpeed", Return = "", Notes = "Sets the normal (walking) maximum speed (as reported by the 1.6.1+ protocols)" }, + SetSprint = { Params = "IsSprinting", Return = "", Notes = "Sets whether the player is sprinting or not." }, + SetSprintingMaxSpeed = { Params = "SprintingMaxSpeed", Return = "", Notes = "Sets the sprinting maximum speed (as reported by the 1.6.1+ protocols)" }, + SetVisible = { Params = "IsVisible", Return = "", Notes = "Sets the player visibility to other players" }, + TossItem = { Params = "DraggedItem, [Amount], [CreateType], [CreateDamage]", Return = "", Notes = "FIXME: This function will be rewritten, avoid it. It tosses an item, either from the inventory, dragged in hand (while in UI window) or a newly created one." }, }, Constants = { + DROWNING_TICKS = { Notes = "Number of ticks per heart of damage when drowning (zero AirLevel)" }, + EATING_TICKS = { Notes = "Number of ticks required for consuming an item." }, + MAX_AIR_LEVEL = { Notes = "The maximum air level value. AirLevel gets reset to this value when the player exits water." }, + MAX_FOOD_LEVEL = { Notes = "The maximum food level value. When the food level is at this value, the player cannot eat." }, + MAX_HEALTH = { Notes = "The maximum health value" }, }, Inherits = "cPawn", }, -- cgit v1.2.3 From 785301c9a07c22df204323cde261f93649e9481b Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 24 Oct 2013 16:27:48 +0200 Subject: APIDump: Documented cPickup. --- MCServer/Plugins/APIDump/APIDesc.lua | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'MCServer') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index 3b459e686..0d7770a49 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -1568,16 +1568,18 @@ a_Player:OpenWindow(Window); cPickup = { - Desc = [[cPickup is a pickup object representation. It is also commonly known as "drops". With this class you could create your own "drop" or modify automatically created. -]], + Desc = [[ + This class represents a pickup entity (an item that the player or mobs can pick up). It is also + commonly known as "drops". With this class you could create your own "drop" or modify those + created automatically. + ]], Functions = { - cPickup = { Notes = "[[cPickup}}" }, - GetItem = { Notes = "{{cItem|cItem}}" }, - CollectedBy = { Return = "bool" }, - }, - Constants = - { + constructor = { Params = "PosX, PosY, PosZ, {{cItem|Item}}, IsPlayerCreated, [SpeedX, SpeedY, SpeedZ]", Return = "cPickup", Notes = "Creates a new pickup at the specified coords. If IsPlayerCreated is true, the pickup has a longer initial collection interval." }, + CollectedBy = { Params = "{{cPlayer}}", Return = "bool", Notes = "Tries to make the player collect the pickup. Returns true if the pickup was collected, at least partially." }, + GetAge = { Params = "", Return = "number", Notes = "Returns the number of ticks that the pickup has existed." }, + GetItem = { Params = "", Return = "{{cItem|cItem}}", Notes = "Returns the item represented by this pickup" }, + IsCollected = { Params = "", Return = "bool", Notes = "Returns true if this pickup has already been collected (is waiting to be destroyed)" }, }, Inherits = "cEntity", }, -- cgit v1.2.3 From 7c2ba5544205a4b59ec34b8b487f7f3b7e32af74 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 24 Oct 2013 16:32:51 +0200 Subject: APIDump: Documented cEnchantments. The constants are self-documenting, no need to describe them further. --- MCServer/Plugins/APIDump/APIDesc.lua | 41 ++++++++++++++++++++++++++++++++---- 1 file changed, 37 insertions(+), 4 deletions(-) (limited to 'MCServer') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index 0d7770a49..e273924be 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -693,10 +693,20 @@ World:ForEachChestInChunk(Player:GetChunkX(), Player:GetChunkZ(), cEnchantments = { - Desc = [[This class is the storage for enchantments for a single {{cItem|cItem}} object, through its m_Enchantments member variable. Although it is possible to create a standalone object of this class, it is not yet used in any API directly. -

-

Enchantments can be initialized either programmatically by calling the individual functions (SetLevel()), or by using a string description of the enchantment combination. This string description is in the form "id=lvl;id=lvl;...;id=lvl;", where id is either a numerical ID of the enchantment, or its textual representation from the table below, and lvl is the desired enchantment level. The class can also create its string description from its current contents; however that string description will only have the numerical IDs. -]], + Desc = [[ + This class is the storage for enchantments for a single {{cItem|cItem}} object, through its + m_Enchantments member variable. Although it is possible to create a standalone object of this class, + it is not yet used in any API directly.

+

+ Enchantments can be initialized either programmatically by calling the individual functions + (SetLevel()), or by using a string description of the enchantment combination. This string + description is in the form "id=lvl;id=lvl;...;id=lvl;", where id is either a numerical ID of the + enchantment, or its textual representation from the table below, and lvl is the desired enchantment + level. The class can also create its string description from its current contents; however that + string description will only have the numerical IDs.

+

+ See the {{cItem}} class for usage examples. + ]], Functions = { constructor = @@ -715,6 +725,29 @@ World:ForEachChestInChunk(Player:GetChunkX(), Player:GetChunkZ(), }, Constants = { + -- Only list these enchantment IDs, as they don't really need any kind of documentation: + enchAquaAffinity = { Notes = "" }, + enchBaneOfArthropods = { Notes = "" }, + enchBlastProtection = { Notes = "" }, + enchEfficiency = { Notes = "" }, + enchFeatherFalling = { Notes = "" }, + enchFireAspect = { Notes = "" }, + enchFireProtection = { Notes = "" }, + enchFlame = { Notes = "" }, + enchFortune = { Notes = "" }, + enchInfinity = { Notes = "" }, + enchKnockback = { Notes = "" }, + enchLooting = { Notes = "" }, + enchPower = { Notes = "" }, + enchProjectileProtection = { Notes = "" }, + enchProtection = { Notes = "" }, + enchPunch = { Notes = "" }, + enchRespiration = { Notes = "" }, + enchSharpness = { Notes = "" }, + enchSilkTouch = { Notes = "" }, + enchSmite = { Notes = "" }, + enchThorns = { Notes = "" }, + enchUnbreaking = { Notes = "" }, }, }, -- cgit v1.2.3 From c875b887589144b19109f4d9f2cb2815c1a79411 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 24 Oct 2013 17:20:52 +0200 Subject: APIDump: Documented cMonster. --- MCServer/Plugins/APIDump/APIDesc.lua | 55 ++++++++++++++++++++++++++++++++++-- 1 file changed, 52 insertions(+), 3 deletions(-) (limited to 'MCServer') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index e273924be..0de6afbb8 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -1574,9 +1574,58 @@ a_Player:OpenWindow(Window); cMonster = { - Desc = "", - Functions = {}, - Constants = {}, + Desc = [[ + This class is the base class for all computer-controlled mobs in the game.

+

+ To spawn a mob in a world, use the {{cWorld}}:SpawnMob() function. + ]], + Functions = + { + FamilyFromType = { Params = "MobType", Return = "MobFamily", Notes = "(STATIC) Returns the mob family (mfXXX constants) based on the mob type (mtXXX constants)" }, + GetMobFamily = { Params = "", Return = "MobFamily", Notes = "Returns this mob's family (mfXXX constant)" }, + GetMobType = { Params = "", Return = "MobType", Notes = "Returns the type of this mob (mtXXX constant)" }, + GetSpawnDelay = { Params = "MobFamily", Return = "number", Notes = "(STATIC) Returns the spawn delay - the number of game ticks between spawn attempts - for the specified mob family." }, + MobTypeToString = { Params = "MobType", Return = "string", Notes = "(STATIC) Returns the string representing the given mob type (mtXXX constant), or empty string if unknown type." }, + StringToMobType = { Params = "string", Return = "MobType", Notes = "(STATIC) Returns the mob type (mtXXX constant) parsed from the string type (\"creeper\"), or mtInvalidType if unrecognized." }, + }, + Constants = + { + mfAmbient = { Notes = "Family: ambient (bat)" }, + mfHostile = { Notes = "Family: hostile (blaze, cavespider, creeper, enderdragon, enderman, ghast, giant, magmacube, silverfish, skeleton, slime, spider, witch, wither, zombie, zombiepigman)" }, + mfMaxplusone = { Notes = "The maximum family value, plus one. Returned when monster family not recognized." }, + mfPassive = { Notes = "Family: passive (chicken, cow, horse, irongolem, mooshroom, ocelot, pig, sheep, snowgolem, villager, wolf)" }, + mfWater = { Notes = "Family: water (squid)" }, + mtBat = { Notes = "" }, + mtBlaze = { Notes = "" }, + mtCaveSpider = { Notes = "" }, + mtChicken = { Notes = "" }, + mtCow = { Notes = "" }, + mtCreeper = { Notes = "" }, + mtEnderDragon = { Notes = "" }, + mtEnderman = { Notes = "" }, + mtGhast = { Notes = "" }, + mtGiant = { Notes = "" }, + mtHorse = { Notes = "" }, + mtInvalidType = { Notes = "Invalid monster type. Returned when monster type not recognized" }, + mtIronGolem = { Notes = "" }, + mtMagmaCube = { Notes = "" }, + mtMooshroom = { Notes = "" }, + mtOcelot = { Notes = "" }, + mtPig = { Notes = "" }, + mtSheep = { Notes = "" }, + mtSilverfish = { Notes = "" }, + mtSkeleton = { Notes = "" }, + mtSlime = { Notes = "" }, + mtSnowGolem = { Notes = "" }, + mtSpider = { Notes = "" }, + mtSquid = { Notes = "" }, + mtVillager = { Notes = "" }, + mtWitch = { Notes = "" }, + mtWither = { Notes = "" }, + mtWolf = { Notes = "" }, + mtZombie = { Notes = "" }, + mtZombiePigman = { Notes = "" }, + }, Inherits = "cPawn", }, -- cgit v1.2.3 From de6f628d2e7ce08f695e524eda0b682347c5e1e4 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Fri, 25 Oct 2013 12:36:39 +0200 Subject: ChunkWorx: Updated for the cIniFile changes. --- MCServer/Plugins/ChunkWorx/chunkworx_main.lua | 53 ++++++++++------------- MCServer/Plugins/ChunkWorx/chunkworx_web.lua | 61 +++++++++++++++++---------- 2 files changed, 62 insertions(+), 52 deletions(-) (limited to 'MCServer') diff --git a/MCServer/Plugins/ChunkWorx/chunkworx_main.lua b/MCServer/Plugins/ChunkWorx/chunkworx_main.lua index ab9962387..f74c4ea2d 100644 --- a/MCServer/Plugins/ChunkWorx/chunkworx_main.lua +++ b/MCServer/Plugins/ChunkWorx/chunkworx_main.lua @@ -6,20 +6,27 @@ CX = 0 CZ = 0 CURRENT = 0 TOTAL = 0 + -- AREA Variables AreaStartX = -10 AreaStartZ = -10 AreaEndX = 10 AreaEndZ = 10 + -- RADIAL Variables RadialX = 0 RadialZ = 0 -Radius = 1 +Radius = 10 + -- WORLD WORK_WORLD = cRoot:Get():GetDefaultWorld():GetName() WW_instance = cRoot:Get():GetDefaultWorld() WORLDS = {} + + + + function Initialize(Plugin) PLUGIN = Plugin @@ -36,39 +43,25 @@ function Initialize(Plugin) LOG("" .. PLUGIN:GetName() .. " v" .. PLUGIN:GetVersion() .. ": NO WORLD found :(") end - PLUGIN.IniFile = cIniFile("ChunkWorx.ini") - if (PLUGIN.IniFile:ReadFile() == false) then - PLUGIN.IniFile:HeaderComment("ChunkWorx Save") - PLUGIN.IniFile:AddKeyName("Area data") - PLUGIN.IniFile:SetValueI("Area data", "StartX", AreaStartX) - PLUGIN.IniFile:SetValueI("Area data", "StartZ", AreaStartZ) - PLUGIN.IniFile:SetValueI("Area data", "EndX", AreaEndX) - PLUGIN.IniFile:SetValueI("Area data", "EndZ", AreaEndZ) - PLUGIN.IniFile:AddKeyName("Radial data") - PLUGIN.IniFile:SetValueI("Radial data", "RadialX", RadialX) - PLUGIN.IniFile:SetValueI("Radial data", "RadialZ", RadialZ) - PLUGIN.IniFile:SetValueI("Radial data", "Radius", Radius) - PLUGIN.IniFile:WriteFile() - end - - AreaStartX = PLUGIN.IniFile:GetValueI("Area data", "StartX") - AreaStartZ = PLUGIN.IniFile:GetValueI("Area data", "StartZ") - AreaEndX = PLUGIN.IniFile:GetValueI("Area data", "EndX") - AreaEndZ = PLUGIN.IniFile:GetValueI("Area data", "EndZ") - - RadialX = PLUGIN.IniFile:GetValueI("Radial data", "RadialX") - RadialZ = PLUGIN.IniFile:GetValueI("Radial data", "RadialZ") - Radius = PLUGIN.IniFile:GetValueI("Radial data", "Radius") + -- Read the stored values: + local SettingsIni = cIniFile(); + SettingsIni:ReadFile("ChunkWorx.ini"); -- ignore any read errors + AreaStartX = SettingsIni:GetValueSetI("Area data", "StartX", AreaStartX) + AreaStartZ = SettingsIni:GetValueSetI("Area data", "StartZ", AreaStartZ) + AreaEndX = SettingsIni:GetValueSetI("Area data", "EndX", AreaEndX) + AreaEndZ = SettingsIni:GetValueSetI("Area data", "EndZ", AreaEndZ) + RadialX = SettingsIni:GetValueSetI("Radial data", "RadialX", RadialX) + RadialZ = SettingsIni:GetValueSetI("Radial data", "RadialZ", RadialZ) + Radius = SettingsIni:GetValueSetI("Radial data", "Radius", Radius) + SettingsIni:WriteFile("ChunkWorx.ini"); LOG("Initialized " .. PLUGIN:GetName() .. " v" .. PLUGIN:GetVersion()) - --LOG("Test1: " .. math.fmod(1.5, 1)) - return fractional part! return true end -function OnDisable() - PLUGIN.IniFile:WriteFile() - LOG(PLUGIN:GetName() .. " v" .. PLUGIN:GetVersion() .. " is shutting down...") -end + + + function OnTick( DeltaTime ) if (GENERATION_STATE == 1 or GENERATION_STATE == 3) then @@ -128,7 +121,7 @@ function OnTick( DeltaTime ) end end end - WW_instance:SaveAllChunks() + WW_instance:QueueSaveAllChunks() WW_instance:UnloadUnusedChunks() end end diff --git a/MCServer/Plugins/ChunkWorx/chunkworx_web.lua b/MCServer/Plugins/ChunkWorx/chunkworx_web.lua index e9a930c92..44993f81c 100644 --- a/MCServer/Plugins/ChunkWorx/chunkworx_web.lua +++ b/MCServer/Plugins/ChunkWorx/chunkworx_web.lua @@ -1,11 +1,44 @@ + +-- chunkworx_web.lua + +-- WebAdmin-related functions + + + + + local function Buttons_Player( Name ) return "

" end + + + + local function Button_World( Name ) return "
" end + + + + +local function SaveSettings() + local SettingsIni = cIniFile() + SettingsIni:SetValueI("Area data", "StartX", AreaStartX) + SettingsIni:SetValueI("Area data", "StartZ", AreaStartZ) + SettingsIni:SetValueI("Area data", "EndX", AreaEndX) + SettingsIni:SetValueI("Area data", "EndZ", AreaEndZ) + SettingsIni:SetValueI("Radial data", "RadialX", RadialX) + SettingsIni:SetValueI("Radial data", "RadialZ", RadialZ) + SettingsIni:SetValueI("Radial data", "Radius", Radius) + SettingsIni:WriteFile("ChunkWorx.ini") +end + + + + + function HandleRequest_Generation( Request ) local Content = "" if (Request.PostParams["AGHRRRR"] ~= nil) then @@ -69,21 +102,12 @@ function HandleRequest_Generation( Request ) AreaStartZ = tonumber(Request.PostParams["FormAreaStartZ"]) AreaEndX = tonumber(Request.PostParams["FormAreaEndX"]) AreaEndZ = tonumber(Request.PostParams["FormAreaEndZ"]) - - PLUGIN.IniFile:DeleteValue("Area data", "StartX") - PLUGIN.IniFile:DeleteValue("Area data", "StartZ") - PLUGIN.IniFile:DeleteValue("Area data", "EndX") - PLUGIN.IniFile:DeleteValue("Area data", "EndZ") - PLUGIN.IniFile:SetValueI("Area data", "StartX", AreaStartX) - PLUGIN.IniFile:SetValueI("Area data", "StartZ", AreaStartZ) - PLUGIN.IniFile:SetValueI("Area data", "EndX", AreaEndX) - PLUGIN.IniFile:SetValueI("Area data", "EndZ", AreaEndZ) + SaveSettings(); if (OPERATION_CODE == 0) then GENERATION_STATE = 1 elseif (OPERATION_CODE == 1) then GENERATION_STATE = 3 end - PLUGIN.IniFile:WriteFile() Content = ProcessingContent() return Content end @@ -93,26 +117,19 @@ function HandleRequest_Generation( Request ) and Request.PostParams["FormRadius"] ~= nil ) then --(Re)Generation valid! -- COMMON (Re)gen if( Request.PostParams["StartRadial"]) then - RadialX = tonumber(Request.PostParams["FormRadialX"]) - RadialZ = tonumber(Request.PostParams["FormRadialZ"]) - Radius = tonumber(Request.PostParams["FormRadius"]) + RadialX = tonumber(Request.PostParams["FormRadialX"]) or 0 + RadialZ = tonumber(Request.PostParams["FormRadialZ"]) or 0 + Radius = tonumber(Request.PostParams["FormRadius"]) or 10 AreaStartX = RadialX - Radius AreaStartZ = RadialZ - Radius AreaEndX = RadialX + Radius AreaEndZ = RadialZ + Radius - - PLUGIN.IniFile:DeleteValue("Radial data", "RadialX") - PLUGIN.IniFile:DeleteValue("Radial data", "RadialZ") - PLUGIN.IniFile:DeleteValue("Radial data", "Radius") - PLUGIN.IniFile:SetValueI("Radial data", "RadialX", RadialX) - PLUGIN.IniFile:SetValueI("Radial data", "RadialZ", RadialZ) - PLUGIN.IniFile:SetValueI("Radial data", "Radius", Radius) + SaveSettings() if (OPERATION_CODE == 0) then GENERATION_STATE = 1 elseif (OPERATION_CODE == 1) then GENERATION_STATE = 3 end - PLUGIN.IniFile:WriteFile() Content = ProcessingContent() return Content end @@ -214,7 +231,7 @@ function HandleRequest_Generation( Request ) Content = Content .. "" -- SELECTING RADIAL - Content = Content .. "

Radial:

Center X, Center Z, Raduis (0 to any)" + Content = Content .. "

Radial:

Center X, Center Z, Radius" Content = Content .. "
" Content = Content .. "" Content = Content .. "" -- cgit v1.2.3 From e7b3ced70b14a9cb24d61036be9b740a0a14897b Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sat, 26 Oct 2013 10:33:44 +0200 Subject: APIDump: Documented cIniFile. --- MCServer/Plugins/APIDump/APIDesc.lua | 216 ++++++++++++++++++++++------------- 1 file changed, 135 insertions(+), 81 deletions(-) (limited to 'MCServer') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index 0de6afbb8..b60a6f746 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -1015,101 +1015,155 @@ cFile:Delete("/usr/bin/virus.exe"); cIniFile = { - Desc = [[The cIniFile is a class that makes it simple to read from and write to INI files. MCServer uses mostly INI files for settings and options. -]], + Desc = [[ + This class implements a simple name-value storage represented on disk by an INI file. These files + are suitable for low-volume high-latency human-readable information storage, such as for + configuration. MCServer itself uses INI files for settings and options.

+

+ The INI files follow this basic structure: +

+; Header comment line
+[KeyName0]
+; Key comment line 0
+ValueName0=Value0
+ValueName1=Value1
+
+[KeyName1]
+; Key comment line 0
+; Key comment line 1
+ValueName0=SomeOtherValue
+
+ The cIniFile object stores all the objects in numbered arrays and provides access to the information + either based on names (KeyName, ValueName) or zero-based indices.

+

+ The objects of this class are created empty. You need to either load a file using ReadFile(), or + insert values by hand. Then you can store the object's contents to a disk file using WriteFile(), or + just forget everything by destroying the object. Note that the file operations are quite slow.

+

+ For storing high-volume low-latency data, use the {{sqlite}} class. For storing + hierarchically-structured data, use the XML format, using the LuaExpat parser in the {{lxp}} class. + ]], Functions = { - constructor = { Return = "{{cIniFile|cIniFile}}" }, - CaseSensitive = { Return = "" }, - CaseInsensitive = { Return = "" }, - Path = { Return = "" }, - Path = { Return = "string" }, - SetPath = { Return = "" }, - ReadFile = { Return = "bool" }, - WriteFile = { Return = "bool" }, - Erase = { Return = "" }, - Clear = { Return = "" }, - Reset = { Return = "" }, - FindKey = { Notes = "long i" }, - FindValue = { Notes = "long i" }, - NumKeys = { Notes = "unsigned i" }, - GetNumKeys = { Notes = "unsigned i" }, - AddKeyName = { Notes = "unsigned int" }, - KeyName = { Notes = "Stri" }, - GetKeyName = { Notes = "Stri" }, - NumValues = { Notes = "unsigned int" }, - GetNumValues = { Notes = "unsigned int" }, - NumValues = { Notes = "unsigned int" }, - GetNumValues = { Notes = "unsigned int" }, - ValueName = { Notes = "Stri" }, - GetValueName = { Notes = "Stri" }, - ValueName = { Notes = "Stri" }, - GetValueName = { Notes = "Stri" }, - GetValue = { Notes = "Stri" }, - GetValue = { Notes = "Stri" }, - GetValueI = { Notes = "i" }, - GetValueB = { Notes = "bo" }, - GetValueF = { Notes = "doub" }, - GetValueSet = { Notes = "Stri" }, - GetValueSetI = { Notes = "i" }, - GetValueSetB = { Notes = "bo" }, - GetValueSetF = { Notes = "doub" }, - SetValue = { Return = "bool" }, - SetValue = { Return = "bool" }, - SetValueI = { Return = "bool" }, - SetValueB = { Return = "bool" }, - SetValueF = { Return = "bool" }, - DeleteValueByID = { Return = "bool" }, - DeleteValue = { Return = "bool" }, - DeleteKey = { Return = "bool" }, - NumHeaderComments = { Notes = "unsigned int" }, - HeaderComment = { Return = "" }, - HeaderComment = { Notes = "Stri" }, - DeleteHeaderComment = { Return = "bool" }, - DeleteHeaderComments = { Return = "" }, - NumKeyComments = { Notes = "unsigned i" }, - NumKeyComments = { Notes = "unsigned i" }, - KeyComment = { Return = "bool" }, - KeyComment = { Return = "bool" }, - KeyComment = { Notes = "Stri" }, - KeyComment = { Notes = "Stri" }, - DeleteKeyComment = { Return = "bool" }, - DeleteKeyComment = { Return = "bool" }, - DeleteKeyComments = { Return = "bool" }, - DeleteKeyComments = { Return = "bool" }, + constructor = { Params = "", Return = "cIniFile", Notes = "Creates a new empty cIniFile object." }, + AddHeaderComment = { Params = "Comment", Return = "", Notes = "Adds a comment to be stored in the file header." }, + AddKeyComment = + { + { Params = "KeyID, Comment", Return = "", Notes = "Adds a comment to be stored in the file under the specified key" }, + { Params = "KeyName, Comment", Return = "", Notes = "Adds a comment to be stored in the file under the specified key" }, + }, + AddKeyName = { Params = "KeyName", Returns = "number", Notes = "Adds a new key of the specified name. Returns the KeyID of the new key." }, + CaseInsensitive = { Params = "", Return = "", Notes = "Sets key names' and value names' comparisons to case insensitive (default)." }, + CaseSensitive = { Params = "", Return = "", Notes = "Sets key names and value names comparisons to case sensitive." }, + Clear = { Params = "", Return = "", Notes = "Removes all the in-memory data. Note that , like all the other operations, this doesn't affect any file data." }, + DeleteHeaderComment = { Params = "CommentID", Return = "bool" , Notes = "Deletes the specified header comment. Returns true if successful."}, + DeleteHeaderComments = { Params = "", Return = "", Notes = "Deletes all headers comments." }, + DeleteKey = { Params = "KeyName", Return = "bool", Notes = "Deletes the specified key, and all values in that key. Returns true if successful." }, + DeleteKeyComment = + { + { Params = "KeyID, CommentID", Return = "bool", Notes = "Deletes the specified key comment. Returns true if successful." }, + { Params = "KeyName, CommentID", Return = "bool", Notes = "Deletes the specified key comment. Returns true if successful." }, + }, + DeleteKeyComments = + { + { Params = "KeyID", Return = "bool", Notes = "Deletes all comments for the specified key. Returns true if successful." }, + { Params = "KeyName", Return = "bool", Notes = "Deletes all comments for the specified key. Returns true if successful." }, + }, + DeleteValue = { Params = "KeyName, ValueName", Return = "bool", Notes = "Deletes the specified value. Returns true if successful." }, + DeleteValueByID = { Params = "KeyID, ValueID", Return = "bool", Notes = "Deletes the specified value. Returns true if successful." }, + FindKey = { Params = "KeyName", Return = "number", Notes = "Returns the KeyID for the specified key name, or the noID constant if the key doesn't exist." }, + FindValue = { Params = "KeyID, ValueName", Return = "numebr", Notes = "Returns the ValueID for the specified value name, or the noID constant if the specified key doesn't contain a value of that name." }, + GetHeaderComment = { Params = "CommentID", Return = "string", Notes = "Returns the specified header comment, or an empty string if such comment doesn't exist" }, + GetKeyComment = + { + { Params = "KeyID, CommentID", Return = "string", Notes = "Returns the specified key comment, or an empty string if such a comment doesn't exist" }, + { Params = "KeyName, CommentID", Return = "string", Notes = "Returns the specified key comment, or an empty string if such a comment doesn't exist" }, + }, + GetKeyName = { Params = "KeyID", Return = "string", Notes = "Returns the key name for the specified key ID. Inverse for FindKey()." }, + GetNumHeaderComments = { Params = "", Return = "number", Notes = "Retuns the number of header comments." }, + GetNumKeyComments = + { + { Params = "KeyID", Return = "number", Notes = "Returns the number of comments under the specified key" }, + { Params = "KeyName", Return = "number", Notes = "Returns the number of comments under the specified key" }, + }, + GetNumKeys = { Params = "", Return = "number", Notes = "Returns the total number of keys. This is the range for the KeyID (0 .. GetNumKeys() - 1)" }, + GetNumValues = + { + { Params = "KeyID", Return = "number", Notes = "Returns the number of values stored under the specified key." }, + { Params = "KeyName", Return = "number", Notes = "Returns the number of values stored under the specified key." }, + }, + GetValue = + { + { Params = "KeyName, ValueName", Return = "string", Notes = "Returns the value of the specified name under the specified key. Returns an empty string if the value doesn't exist." }, + { Params = "KeyID, ValueID", Return = "string", Notes = "Returns the value of the specified name under the specified key. Returns an empty string if the value doesn't exist." }, + }, + GetValueB = { Params = "KeyName, ValueName", Return = "bool", Notes = "Returns the value of the specified name under the specified key, as a bool. Returns false if the value doesn't exist." }, + GetValueF = { Params = "KeyName, ValueName", Return = "number", Notes = "Returns the value of the specified name under the specified key, as a floating-point number. Returns zero if the value doesn't exist." }, + GetValueI = { Params = "KeyName, ValueName", Return = "number", Notes = "Returns the value of the specified name under the specified key, as an integer. Returns zero if the value doesn't exist." }, + GetValueName = + { + { Params = "KeyID, ValueID", Return = "string", Notes = "Returns the name of the specified value Inverse for FindValue()." }, + { Params = "KeyName, ValueID", Return = "string", Notes = "Returns the name of the specified value Inverse for FindValue()." }, + }, + GetValueSet = { Params = "KeyName, ValueName, Default", Return = "string", Notes = "Returns the value of the specified name under the specified key. If the value doesn't exist, creates it with the specified default." }, + GetValueSetB = { Params = "KeyName, ValueName, Default", Return = "bool", Notes = "Returns the value of the specified name under the specified key, as a bool. If the value doesn't exist, creates it with the specified default." }, + GetValueSetF = { Params = "KeyName, ValueName, Default", Return = "number", Notes = "Returns the value of the specified name under the specified key, as a floating-point number. If the value doesn't exist, creates it with the specified default." }, + GetValueSetI = { Params = "KeyName, ValueName, Default", Return = "number", Notes = "Returns the value of the specified name under the specified key, as an integer. If the value doesn't exist, creates it with the specified default." }, + ReadFile = { Params = "FileName, [AllowExampleFallback]", Return = "bool", Notes = "Reads the values from the specified file. Previous in-memory contents are lost. If the file cannot be opened, and AllowExample is true, another file, \"filename.example.ini\", is loaded and then saved as \"filename.ini\". Returns true if successful, false if not." }, + SetValue = + { + { Params = "KeyID, ValueID, NewValue", Return = "bool", Notes = "Overwrites the specified value with a new value. If the specified value doesn't exist, returns false (doesn't add)." }, + { Params = "KeyName, ValueName, NewValue, [CreateIfNotExists]", Return = "bool", Notes = "Overwrites the specified value with a new value. If CreateIfNotExists is true (default) and the value doesn't exist, it is first created. Returns true if the value was successfully set, false if not (didn't exists, CreateIfNotExists false)." }, + }, + SetValueB = { Params = "KeyName, ValueName, NewValueBool, [CreateIfNotExists]", Return = "bool", Notes = "Overwrites the specified value with a new bool value. If CreateIfNotExists is true (default) and the value doesn't exist, it is first created. Returns true if the value was successfully set, false if not (didn't exists, CreateIfNotExists false)." }, + SetValueF = { Params = "KeyName, ValueName, NewValueFloat, [CreateIfNotExists]", Return = "bool", Notes = "Overwrites the specified value with a new floating-point number value. If CreateIfNotExists is true (default) and the value doesn't exist, it is first created. Returns true if the value was successfully set, false if not (didn't exists, CreateIfNotExists false)." }, + SetValueI = { Params = "KeyName, ValueName, NewValueInt, [CreateIfNotExists]", Return = "bool", Notes = "Overwrites the specified value with a new integer value. If CreateIfNotExists is true (default) and the value doesn't exist, it is first created. Returns true if the value was successfully set, false if not (didn't exists, CreateIfNotExists false)." }, + WriteFile = { Params = "FileName", Return = "bool", Notes = "Writes the current in-memory data into the specified file. Returns true if successful, false if not." }, }, Constants = { + noID = { Notes = "" }, }, AdditionalInfo = { { - Header = "Practical usage", + Header = "Code example: Reading a simple value", Contents = [[ - If you want to use cIniFile you need to know a couple of things; what is the key name and what - is the value name. Below is a demonstration of what is what.

-
-; Comment line
-[KeyName1]
-ValueName1=Value1
-ValueName2=Value2
-
-[KeyName2]
-ValueName1=Value3
-

-

cIniFile is very easy to use. For example, you can find out what port the server is supposed to use according to settings.ini by using this little snippet:

-local IniFile = cIniFile("settings.ini");
-if (IniFile:ReadFile()) then
+local IniFile = cIniFile();
+if (IniFile:ReadFile("settings.ini")) then
 	ServerPort = IniFile:GetValueI("Server", "Port");
 end
 
]], }, - }, - }, + { + Header = "Code example: Enumerating all objects in a file", + Contents = [[ + To enumerate all keys in a file, you need to query the total number of keys, using GetNumKeys(), + and then query each key's name using GetKeyName(). Similarly, to enumerate all values under a + key, you need to query the total number of values using GetNumValues() and then query each + value's name using GetValueName().

+

+ The following code logs all keynames and their valuenames into the server log: +

+local IniFile = cIniFile();
+IniFile:ReadFile("somefile.ini")
+local NumKeys = IniFile:GetNumKeys();
+for k = 0, NumKeys do
+	local NumValues = IniFile:GetNumValues(k);
+	LOG("key \"" .. IniFile:GetKeyName(k) .. "\" has " .. NumValues .. " values:");
+	for v = 0, NumValues do
+		LOG("  value \"" .. IniFile:GetValueName(k, v) .. "\".");
+	end
+end
+
+ ]], + }, + }, -- AdditionalInfo + }, -- cIniFile cInventory = { @@ -1167,7 +1221,7 @@ These ItemGrids are available in the API and can be manipulated by the plugins, invHotbarOffset = { Notes = "Starting slot number of the Hotbar part" }, invNumSlots = { Notes = "Total number of slots in a cInventory" }, }, - }, + }, -- cInventory cItem = { @@ -1254,7 +1308,7 @@ local Item5 = cItem(E_ITEM_DIAMOND_CHESTPLATE, 1, 0, "thorns=1;unbreaking=3"); ]], }, }, - }, + }, -- cItem cItemGrid = { @@ -1364,7 +1418,7 @@ end ]], }, }, -- AdditionalInfo - }, + }, -- cItemGrid cItems = { @@ -1394,7 +1448,7 @@ end Constants = { }, - }, + }, -- cItems cLineBlockTracer = { -- cgit v1.2.3 From 73e7d213878ca4ae8b89d1d999b6d80f487c6a27 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sat, 26 Oct 2013 19:54:51 +0200 Subject: APIDump: Documented cPickup. --- MCServer/Plugins/APIDump/APIDesc.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'MCServer') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index b60a6f746..dfada998f 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -1716,9 +1716,10 @@ a_Player:OpenWindow(Window); GetAge = { Params = "", Return = "number", Notes = "Returns the number of ticks that the pickup has existed." }, GetItem = { Params = "", Return = "{{cItem|cItem}}", Notes = "Returns the item represented by this pickup" }, IsCollected = { Params = "", Return = "bool", Notes = "Returns true if this pickup has already been collected (is waiting to be destroyed)" }, + IsPlayerCreated = { Params = "", Return = "bool", Notes = "Returns true if the pickup was created by a player" }, }, Inherits = "cEntity", - }, + }, -- cPickup cPlayer = { -- cgit v1.2.3 From 5d58457c9e950093ce14ce10eb74626ecec57025 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sun, 27 Oct 2013 09:29:02 +0100 Subject: APIDump: Documented cProjectileEntity. --- MCServer/Plugins/APIDump/APIDesc.lua | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) (limited to 'MCServer') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index dfada998f..b7a5b7e47 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -1040,7 +1040,7 @@ ValueName0=SomeOtherValue insert values by hand. Then you can store the object's contents to a disk file using WriteFile(), or just forget everything by destroying the object. Note that the file operations are quite slow.

- For storing high-volume low-latency data, use the {{sqlite}} class. For storing + For storing high-volume low-latency data, use the {{sqlite3}} class. For storing hierarchically-structured data, use the XML format, using the LuaExpat parser in the {{lxp}} class. ]], Functions = @@ -1943,8 +1943,26 @@ cPluginManager.AddHook(cPluginManager.HOOK_CHAT, OnChatMessage); cProjectileEntity = { Desc = "", - Functions = {}, - Constants = {}, + Functions = + { + GetCreator = { Params = "", Return = "{{cEntity}} descendant", Notes = "Returns the entity who created this projectile. May return nil." }, + GetMCAClassName = { Params = "", Return = "string", Notes = "Returns the string that identifies the projectile type (class name) in MCA files" }, + GetProjectileKind = { Params = "", Return = "ProjectileKind", Notes = "Returns the kind of this projectile (pkXXX constant)" }, + IsInGround = { Params = "", Return = "bool", Notes = "Returns true if this projectile has hit the ground." }, + }, + Constants = + { + pkArrow = { Notes = "The projectile is an {{cArrowEntity|arrow}}" }, + pkEgg = { Notes = "The projectile is a {{cThrownEggEntity|thrown egg}}" }, + pkEnderPearl = { Notes = "The projectile is a {{cThrownEnderPearlEntity|thrown enderpearl}}" }, + pkExpBottle = { Notes = "The projectile is a thrown exp bottle (NYI)" }, + pkFireCharge = { Notes = "The projectile is a {{cFireChargeEntity|fire charge}}" }, + pkFishingFloat = { Notes = "The projectile is a fishing float (NYI)" }, + pkGhastFireball = { Notes = "The projectile is a {{cGhastFireballEntity|ghast fireball}}" }, + pkSnowball = { Notes = "The projectile is a {{cThrownSnowballEntity|thrown snowball}}" }, + pkSplashPotion = { Notes = "The projectile is a thrown splash potion (NYI)" }, + pkWitherSkull = { Notes = "The projectile is a wither skull (NYI)" }, + }, Inherits = "cEntity", }, -- cgit v1.2.3 From 4871968bc9114de9db5ae52cd123641d8e909832 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sun, 27 Oct 2013 09:39:11 +0100 Subject: APIDump: Documented cRoot. --- MCServer/Plugins/APIDump/APIDesc.lua | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'MCServer') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index b7a5b7e47..14b4a3184 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -1968,11 +1968,18 @@ cPluginManager.AddHook(cPluginManager.HOOK_CHAT, OnChatMessage); cRoot = { - Desc = [[There is always only one cRoot object in MCServer. cRoot manages all the important objects such as {{cServer|cServer}} -]], + Desc = [[ + This class represents the root of MCServer's object hierarchy. There is always only one cRoot + object. It manages and allows querying all the other objects, such as {{cServer}}, + {{cPluginManager}}, individual {{cWorld|worlds}} etc.

+

+ To get the singleton instance of this object, you call the cRoot:Get() function. Then you can call + the individual functions on this object. Note that some of the functions are static and don't need + the instance, they are to be called directly on the cRoot class, such as cRoot:GetPhysicalRAMUsage() + ]], Functions = { - Get = { Params = "", Return = "Root object", Notes = "This function returns the cRoot object." }, + Get = { Params = "", Return = "Root object", Notes = "(STATIC)This function returns the cRoot object." }, BroadcastChat = { Params = "Message", Return = "", Notes = "Broadcasts a message to every player in the server." }, FindAndDoWithPlayer = { Params = "PlayerName, CallbackFunction", Return = "", Notes = "Calls the given callback function for the given player." }, ForEachPlayer = { Params = "CallbackFunction", Return = "", Notes = "Calls the given callback function for each player. The callback function has the following signature:

function Callback({{cPlayer|cPlayer}})
" }, @@ -1981,11 +1988,13 @@ cPluginManager.AddHook(cPluginManager.HOOK_CHAT, OnChatMessage); GetDefaultWorld = { Params = "", Return = "{{cWorld|cWorld}}", Notes = "Returns the world object from the default world." }, GetFurnaceRecipe = { Params = "", Return = "{{cFurnaceRecipe|cFurnaceRecipe}}", Notes = "Returns the cFurnaceRecipes object." }, GetGroupManager = { Params = "", Return = "{{cGroupManager|cGroupManager}}", Notes = "Returns the cGroupManager object." }, + GetPhysicalRAMUsage = { Params = "", Return = "number", Notes = "Returns the amount of physical RAM that the entire MCServer process is using, in KiB. Negative if the OS doesn't support this query." }, GetPluginManager = { Params = "", Return = "{{cPluginManager|cPluginManager}}", Notes = "Returns the cPluginManager object." }, GetPrimaryServerVersion = { Params = "", Return = "number", Notes = "Returns the servers primary server version." }, GetProtocolVersionTextFromInt = { Params = "Protocol Version", Return = "string", Notes = "Returns the Minecraft version from the given Protocol. If there is no version found, it returns 'Unknown protocol(Parameter)'" }, GetServer = { Params = "", Return = "{{cServer|cServer}}", Notes = "Returns the cServer object." }, GetTotalChunkCount = { Params = "", Return = "number", Notes = "Returns the amount of loaded chunks." }, + GetVirtualRAMUsage = { Params = "", Return = "number", Notes = "Returns the amount of virtual RAM that the entire MCServer process is using, in KiB. Negative if the OS doesn't support this query." }, GetWebAdmin = { Params = "", Return = "{{cWebAdmin|cWebAdmin}}", Notes = "Returns the cWebAdmin object." }, GetWorld = { Params = "WorldName", Return = "{{cWorld|cWorld}}", Notes = "Returns the cWorld object of the given world. It returns nil if there is no world with the given name." }, QueueExecuteConsoleCommand = { Params = "Message", Return = "", Notes = "Queues a console command for execution through the cServer class. The command will be executed in the tick thread The command's output will be sent to console " .. '"stop" and "restart" commands have special handling.' }, -- cgit v1.2.3 From 4f32079692e42e7d29520e4d22902ac15e7e16ea Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sun, 27 Oct 2013 09:45:02 +0100 Subject: APIDump: Documented cWorld. --- MCServer/Plugins/APIDump/APIDesc.lua | 1 + 1 file changed, 1 insertion(+) (limited to 'MCServer') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index 14b4a3184..8e9122ba2 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -2257,6 +2257,7 @@ Sign entities are saved and loaded from disk when the chunk they reside in is sa 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." }, 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." }, 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." }, -- cgit v1.2.3 From aca526d158b1b15f8e00a110313896878595f62f Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Mon, 28 Oct 2013 13:07:30 +0100 Subject: APIDump: Fixed a failure in documented classes with no functions. --- MCServer/Plugins/APIDump/main.lua | 1 + 1 file changed, 1 insertion(+) (limited to 'MCServer') diff --git a/MCServer/Plugins/APIDump/main.lua b/MCServer/Plugins/APIDump/main.lua index 2db8b4b1b..a9cdf143b 100644 --- a/MCServer/Plugins/APIDump/main.lua +++ b/MCServer/Plugins/APIDump/main.lua @@ -499,6 +499,7 @@ function ReadDescriptions(a_API) cls.Functions = DoxyFunctions; else -- if (APIDesc.Functions ~= nil) for j, func in ipairs(cls.Functions) do + local FnName = func.DocID or func.Name; if not(IsFunctionIgnored(cls.Name .. "." .. FnName)) then table.insert(cls.UndocumentedFunctions, FnName); end -- cgit v1.2.3 From 1a29c19619a70cd78ce7a2e18881ebdde83650ac Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Mon, 28 Oct 2013 13:08:14 +0100 Subject: APIDump: Documented HTTPFormData and HTTPRequest. --- MCServer/Plugins/APIDump/APIDesc.lua | 44 ++++++++++++++++++++++++++++++++---- 1 file changed, 39 insertions(+), 5 deletions(-) (limited to 'MCServer') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index 8e9122ba2..e3b804c32 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -2348,7 +2348,40 @@ World:ForEachEntity( ]], }, }, -- AdditionalInfo - }, + }, -- cWorld + + HTTPFormData = + { + Desc = "This class stores data for one form element for a {{HTTPRequest|HTTP request}}.", + Variables = + { + Name = { Type = "string", Notes = "Name of the form element" }, + Type = { Type = "string", Notes = "Type of the data (usually empty)" }, + Value = { Type = "string", Notes = "Value of the form element. Contains the raw data as sent by the browser." }, + }, + }, -- HTTPFormData + + HTTPRequest = + { + Desc = [[ + This class encapsulates all the data that is sent to the WebAdmin through one HTTP request. Plugins + receive this class as a parameter to the function handling the web requests, as registered in the + FIXME: {{cPluginLua}}:AddWebPage(). + ]], + Constants = + { + FormData = { Notes = "Array-table of {{HTTPFormData}}, contains the values of individual form elements submitted by the client" }, + Params = { Notes = "Map-table of parameters given to the request in the URL (?param=value); if a form uses GET method, this is the same as FormData. For each parameter given as \"param=value\", there is an entry in the table with \"param\" as its key and \"value\" as its value." }, + PostParams = { Notes = "Map-table of data posted through a FORM - either a GET or POST method. Logically the same as FormData, but in a map-table format (for each parameter given as \"param=value\", there is an entry in the table with \"param\" as its key and \"value\" as its value)." }, + }, + + Variables = + { + Method = { Type = "string", Notes = "The HTTP method used to make the request. Usually GET or POST." }, + Path = { Type = "string", Notes = "The Path part of the URL (excluding the parameters)" }, + Username = { Type = "string", Notes = "Name of the logged-in user." }, + }, + }, -- HTTPRequest TakeDamageInfo = { @@ -2360,7 +2393,7 @@ World:ForEachEntity( Constants = { }, - }, + }, -- TakeDamageInfo Vector3d = { @@ -2373,7 +2406,7 @@ World:ForEachEntity( Constants = { }, - }, + }, -- Vector3d Vector3f = { @@ -2385,7 +2418,7 @@ World:ForEachEntity( Constants = { }, - }, + }, -- Vector3f Vector3i = { @@ -2397,7 +2430,8 @@ World:ForEachEntity( Constants = { }, - }, + }, -- Vector3i + Globals = { Desc = [[These functions are available directly, without a class instance. Any plugin cal call them at any time.]], -- cgit v1.2.3 From 2bb1dd50152667eec230f49d75fd5b903a99f1a5 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Mon, 28 Oct 2013 13:32:10 +0100 Subject: APIDump: Documented cWindow. --- MCServer/Plugins/APIDump/APIDesc.lua | 54 ++++++++++++++++++++++-------------- 1 file changed, 33 insertions(+), 21 deletions(-) (limited to 'MCServer') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index e3b804c32..8b007101a 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -2108,36 +2108,48 @@ Sign entities are saved and loaded from disk when the chunk they reside in is sa cWindow = { - Desc = [[This class is the common ancestor for all window classes used by MCServer. It is inherited by the {{cLuaWindow|cLuaWindow}} class that plugins use for opening custom windows. It is planned to be used for window-related hooks in the future. It implements the basic functionality of any window. -

-

Note that one cWindow object can be used for multiple players at the same time, and therefore the slot contents are player-specific (e. g. crafting grid, or player inventory). Thus the GetSlot() and SetSlot() functions need to have the {{cPlayer|cPlayer}} parameter that specifies the player for which the contents are to be queried. -]], + Desc = [[ + This class is the common ancestor for all window classes used by MCServer. It is inherited by the + {{cLuaWindow|cLuaWindow}} class that plugins use for opening custom windows. It is planned to be + used for window-related hooks in the future. It implements the basic functionality of any + window.

+

+ Note that one cWindow object can be used for multiple players at the same time, and therefore the + slot contents are player-specific (e. g. crafting grid, or player inventory). Thus the GetSlot() and + SetSlot() functions need to have the {{cPlayer|cPlayer}} parameter that specifies the player for + whom the contents are to be queried.

+

+ Windows also have numeric properties, these are used to set the progressbars for furnaces or the XP + costs for enchantment tables. + ]], Functions = { + GetSlot = { Params = "{{cPlayer|Player}}, SlotNumber", Return = "{{cItem}}", Notes = "Returns the item at the specified slot for the specified player. Returns nil and logs to server console on error." }, GetWindowID = { Params = "", Return = "number", Notes = "Returns the ID of the window, as used by the network protocol" }, GetWindowTitle = { Params = "", Return = "string", Notes = "Returns the window title that will be displayed to the player" }, GetWindowType = { Params = "", Return = "number", Notes = "Returns the type of the window, one of the constants in the table above" }, - IsSlotInPlayerHotbar = { Params = "number", Return = "bool", Notes = "Returns true if the specified slot number is in the player hotbar" }, - IsSlotInPlayerInventory = { Params = "number", Return = "bool", Notes = "Returns true if the specified slot number is in the player's main inventory or in the hotbar. Note that this returns false for armor slots!" }, - IsSlotInPlayerMainInventory = { Params = "number", Return = "bool", Notes = "Returns true if the specified slot number is in the player's main inventory" }, - SetSlot = { Params = "{{cItem|cItem}}", Return = "", Notes = "Sets the contents of the specified slot for the specified player. Ignored if the slot number is invalid" }, + IsSlotInPlayerHotbar = { Params = "SlotNum", Return = "bool", Notes = "Returns true if the specified slot number is in the player hotbar" }, + IsSlotInPlayerInventory = { Params = "SlotNum", Return = "bool", Notes = "Returns true if the specified slot number is in the player's main inventory or in the hotbar. Note that this returns false for armor slots!" }, + IsSlotInPlayerMainInventory = { Params = "SlotNum", Return = "bool", Notes = "Returns true if the specified slot number is in the player's main inventory" }, + SetProperty = { Params = "PropertyID, PropartyValue, {{cPlayer|Player}}", Return = "", Notes = "Sends the UpdateWindowProperty (0x69) packet to the specified player; or to all players who are viewing this window if Player is not specified or nil." }, + SetSlot = { Params = "{{cPlayer|Player}}, SlotNum, {{cItem|cItem}}", Return = "", Notes = "Sets the contents of the specified slot for the specified player. Ignored if the slot number is invalid" }, SetWindowTitle = { Params = "string", Return = "", Notes = "Sets the window title that will be displayed to the player" }, }, Constants = { - Inventory = { Notes = "" }, - Chest = { Notes = "0" }, - Workbench = { Notes = "1" }, - Furnace = { Notes = "2" }, - DropSpenser = { Notes = "3" }, - Enchantment = { Notes = "4" }, - Brewery = { Notes = "5" }, - NPCTrade = { Notes = "6" }, - Beacon = { Notes = "7" }, - Anvil = { Notes = "8" }, - Hopper = { Notes = "9" }, - }, - }, + wtInventory = { Notes = "An inventory window" }, + wtChest = { Notes = "A {{cChestEntity|chest}} or doublechest window" }, + wtWorkbench = { Notes = "A workbench (crafting table) window" }, + wtFurnace = { Notes = "A {{cFurnaceEntity|furnace}} window" }, + wtDropSpenser = { Notes = "A {{cDropperEntity|dropper}} or a {{cDispenserEntity|dispenser}} window" }, + wtEnchantment = { Notes = "An enchantment table window" }, + wtBrewery = { Notes = "A brewing stand window" }, + wtNPCTrade = { Notes = "A villager trade window" }, + wtBeacon = { Notes = "A beacon window" }, + wtAnvil = { Notes = "An anvil window" }, + wtHopper = { Notes = "A {{cHopperEntity|hopper}} window" }, + }, + }, -- cWindow cWorld = { -- cgit v1.2.3 From d41d5c15b1828e71990c0e31d7c11c0ac768ed59 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Mon, 28 Oct 2013 13:44:57 +0100 Subject: Debuggers: Fixed after the cWindow API change. --- MCServer/Plugins/Debuggers/Debuggers.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'MCServer') diff --git a/MCServer/Plugins/Debuggers/Debuggers.lua b/MCServer/Plugins/Debuggers/Debuggers.lua index b895da05e..04a15a002 100644 --- a/MCServer/Plugins/Debuggers/Debuggers.lua +++ b/MCServer/Plugins/Debuggers/Debuggers.lua @@ -606,7 +606,7 @@ end function HandleTestWndCmd(a_Split, a_Player) - local WindowType = cWindow.Hopper; + local WindowType = cWindow.wtHopper; local WindowSizeX = 5; local WindowSizeY = 1; if (#a_Split == 4) then @@ -789,7 +789,7 @@ end function HandleEnchCmd(a_Split, a_Player) - local Wnd = cLuaWindow(cWindow.Enchantment, 1, 1, "Ench"); + local Wnd = cLuaWindow(cWindow.wtEnchantment, 1, 1, "Ench"); a_Player:OpenWindow(Wnd); Wnd:SetProperty(0, 10); Wnd:SetProperty(1, 15); -- cgit v1.2.3