Add Definitions for Luanalysis #192
@ -45,10 +45,10 @@ Das Script System auf SteamWar.de basiert auf [Lua](https://www.lua.org/docs.htm
|
||||
Der Code wird einfach in ein Minecraft Buch geschrieben und kann mit einem Links-Klick ausgeführt werden.
|
||||
|
||||
## Nutzung mit einer IDE
|
||||
Im Repository liegen [Lua-Definitionen](definitions.lua) für [Luanalysis](https://plugins.jetbrains.com/plugin/14698-luanalysis).
|
||||
Im Repository liegen [Lua-Definitionen](sw.def.lua) für [Luanalysis](https://plugins.jetbrains.com/plugin/14698-luanalysis).
|
||||
Diese können in der IDE genutzt werden, um die APIs zu nutzen.
|
||||
|
||||
Einfach die `definitions.lua` in den selben Ordner wie das Script legen und die IDE sollte die APIs erkennen.
|
||||
Einfach die `definitions.lua` in denselben Ordner wie das Script legen und die IDE sollte die APIs erkennen.
|
||||
|
||||
# Basis-Apis
|
||||
Es werden folgende Standard-Apis zur Verfügung gestellt:
|
||||
|
317
sw.def.lua
Normale Datei
317
sw.def.lua
Normale Datei
@ -0,0 +1,317 @@
|
||||
-- This file is a part of the SteamWar software.
|
||||
--
|
||||
-- Copyright (C) 2021 SteamWar.de-Serverteam
|
||||
--
|
||||
-- This program is free software: you can redistribute it and/or modify
|
||||
-- it under the terms of the GNU Affero General Public License as published by
|
||||
-- the Free Software Foundation, either version 3 of the License, or
|
||||
-- (at your option) any later version.
|
||||
--
|
||||
-- This program is distributed in the hope that it will be useful,
|
||||
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
-- GNU Affero General Public License for more details.
|
||||
--
|
||||
-- You should have received a copy of the GNU Affero General Public License
|
||||
-- along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
---
|
||||
--- This file contains the definitions for the SteamWar.de script API.
|
||||
--- It is used by the IDE to provide code completion and type checking.
|
||||
--- Created by Chaoscaot
|
||||
---
|
||||
|
||||
inventory = {}
|
||||
|
||||
---@param title string
|
||||
---@param size number
|
||||
---@return Inventory
|
||||
function inventory.create(title, size) return nil end
|
||||
|
||||
---@alias InventoryClick 'LEFT' | 'SHIFT_LEFT' | 'RIGHT' | 'SHIFT_RIGHT' | 'MIDDLE' | 'NUMBER_KEY'
|
||||
|
||||
---@class Inventory
|
||||
local Inventory = {}
|
||||
|
||||
---@overload fun(slot: number, material: string, name: string, handler: fun(click: InventoryClick)): void
|
||||
---@overload fun(slot: number, material: string, name: string, handler: fun(click: InventoryClick), lore: string[]): void
|
||||
---@overload fun(slot: number, material: string, name: string, handler: fun(click: InventoryClick), lore: string[], enchanted: boolean): void
|
||||
---@param slot number
|
||||
---@param material string
|
||||
---@param name string
|
||||
---@param handler fun(click: InventoryClick): void
|
||||
---@param lore string[]
|
||||
---@param enchanted boolean
|
||||
---@param amount number
|
||||
---@return void
|
||||
function Inventory.item(slot, material, name, handler, lore, enchanted, amount) end
|
||||
|
||||
---@param handler fun(): void
|
||||
---@return void
|
||||
function Inventory.setCloseHandler(handler) end
|
||||
|
||||
---@return void
|
||||
function Inventory.open() end
|
||||
|
||||
player = {}
|
||||
|
||||
---@return string
|
||||
---Get the name of the player.
|
||||
function player.name() return "" end
|
||||
|
||||
---@return void
|
||||
function player.chat(...) end
|
||||
|
||||
---@return void
|
||||
---Send a message to the actionbar of the player.
|
||||
function player.actionbar(...) end
|
||||
|
||||
---@overload fun(): number
|
||||
---@param newX number
|
||||
function player.x(newX) end
|
||||
|
||||
---@overload fun(): number
|
||||
---@param newY number
|
||||
function player.y(newY) end
|
||||
|
||||
---@overload fun(): number
|
||||
---@param newZ number
|
||||
function player.z(newZ) end
|
||||
|
||||
---@overload fun(): number
|
||||
---@param newYaw number
|
||||
function player.yaw(newYaw) end
|
||||
|
||||
---@overload fun(): number
|
||||
---@param newPitch number
|
||||
function player.pitch(newPitch) end
|
||||
|
||||
---@return boolean
|
||||
function player.sneaking() return nil end
|
||||
|
||||
---@return boolean
|
||||
function player.sprinting() return nil end
|
||||
|
||||
---@overload fun(): number
|
||||
---@param newSlot number
|
||||
function player.slot(newSlot) end
|
||||
|
||||
---@return string
|
||||
function player.item() return nil end
|
||||
|
||||
---@return string
|
||||
function player.offHandItem() return nil end
|
||||
|
||||
---@return void
|
||||
function player.closeInventory() end
|
||||
|
||||
---@field nextBool fun(): boolean
|
||||
random = {}
|
||||
|
||||
---@overload fun(): number
|
||||
---@overload fun(bound: number): number
|
||||
---@param origin number
|
||||
---@param bound number
|
||||
---@return number
|
||||
function random.nextInt(origin, bound) return nil end
|
||||
|
||||
---@overload fun(): number
|
||||
---@overload fun(bound: number): number
|
||||
---@param origin number
|
||||
---@param bound number
|
||||
---@return number
|
||||
function random.nextDouble(origin, bound) return nil end
|
||||
|
||||
---@return boolean
|
||||
function random.nextBool() return nil end
|
||||
|
||||
---@alias RegionType 'wg' | 'mwg' | 'as' | 'ws' | 'ws_inner' | 'ws_rumpf' | 'ws_rahmen' | 'spawn'
|
||||
|
||||
---@class region
|
||||
---@field tnt tnt
|
||||
---@field trace trace
|
||||
region = {}
|
||||
|
||||
---@return string
|
||||
function region.name() return nil end
|
||||
|
||||
---@return RegionType
|
||||
function region.type() return nil end
|
||||
|
||||
---@return boolean
|
||||
function region.fire() return nil end
|
||||
|
||||
---@return boolean
|
||||
function region.freeze() return nil end
|
||||
|
||||
---@return boolean
|
||||
function region.protect() return nil end
|
||||
|
||||
---@return string
|
||||
function region.loader() return nil end
|
||||
|
||||
---@alias TNTMode 'ALLOW' | 'DENY' | 'ONLY_TB'
|
||||
|
||||
---@class tnt
|
||||
local tnt = {}
|
||||
|
||||
---@return TNTMode
|
||||
function tnt.mode() return nil end
|
||||
|
||||
---@return boolean
|
||||
function tnt.enabled() return nil end
|
||||
|
||||
---@return boolean
|
||||
function tnt.onlyTb() return nil end
|
||||
|
||||
---@class trace
|
||||
local trace = {}
|
||||
|
||||
---@return boolean
|
||||
function trace.active() return nil end
|
||||
|
||||
---@return boolean
|
||||
function trace.auto() return nil end
|
||||
|
||||
---@return string
|
||||
function trace.status() return nil end
|
||||
|
||||
---@return number
|
||||
function trace.time() return nil end
|
||||
|
||||
---@class Position
|
||||
---@field x number
|
||||
---@field y number
|
||||
---@field z number
|
||||
|
||||
---@class server
|
||||
---@field tps tps
|
||||
server = {}
|
||||
|
||||
---@return string
|
||||
function server.time() return nil end
|
||||
|
||||
---@return number
|
||||
function server.ticks() return nil end
|
||||
|
||||
---@param position Position
|
||||
---@return string
|
||||
function getBlockAt(position) return nil end
|
||||
|
||||
---@param position Position
|
||||
---@param material string
|
||||
---@return void
|
||||
function setBlockAt(position, material) return nil end
|
||||
|
||||
---@class tps
|
||||
local tps = {}
|
||||
|
||||
---@return number
|
||||
function tps.oneSecond() return nil end
|
||||
|
||||
---@return number
|
||||
function tps.tenSecond() return nil end
|
||||
|
||||
---@return number
|
||||
function tps.oneMinute() return nil end
|
||||
|
||||
---@return number
|
||||
function tps.fiveMinute() return nil end
|
||||
|
||||
---@return number
|
||||
function tps.tenMinute() return nil end
|
||||
|
||||
---@return number
|
||||
function tps.current() return nil end
|
||||
|
||||
---@return number
|
||||
function tps.limit() return nil end
|
||||
|
||||
---@class storage
|
||||
---@field global storageLib
|
||||
---@field player storageLib
|
||||
---@field region storageLib
|
||||
storage = {}
|
||||
|
||||
---@class storageLib
|
||||
local storageLib = {}
|
||||
|
||||
---@param key string
|
||||
---@return any
|
||||
function storageLib.get(key) return nil end
|
||||
|
||||
---@param key string
|
||||
---@param value any
|
||||
---@return void
|
||||
function storageLib.set(key, value) end
|
||||
|
||||
---@class Selection
|
||||
---@field max Position
|
||||
---@field min Position
|
||||
|
||||
---@class _worldedit
|
||||
_worldedit = {}
|
||||
|
||||
---@overload fun(pos: Position[]): void
|
||||
---@return Selection
|
||||
function _worldedit.selection() return nil end
|
||||
|
||||
---@param msg string
|
||||
---@param callback fun(value: string): void
|
||||
---@return void
|
||||
function input(msg, callback) end
|
||||
|
||||
---@param ticks number
|
||||
---@param callback fun(): void
|
||||
---@return void
|
||||
function delayed(ticks, callback) end
|
||||
|
||||
---@param x number
|
||||
---@param y number
|
||||
---@param z number
|
||||
---@return Position
|
||||
function pos(x, y, z) return nil end
|
||||
|
||||
---@return void
|
||||
function exec(...) end
|
||||
|
||||
---@param obj any
|
||||
---@return number
|
||||
function length(obj) return 0 end
|
||||
|
||||
---@param separator string
|
||||
---@param table any[]
|
||||
---@return string
|
||||
function join(separator, table) return "" end
|
||||
|
||||
---@class EventType
|
||||
---@class events
|
||||
---@field DoubleSwap EventType
|
||||
---@field PlaceBlock EventType
|
||||
---@field BreakBlock EventType
|
||||
---@field RightClick EventType
|
||||
---@field LeftClick EventType
|
||||
---@field TNTSpawn EventType
|
||||
---@field TNTExplode EventType
|
||||
---@field TNTExplodeInBuild EventType
|
||||
---@field SelfJoin EventType
|
||||
---@field SelfLeave EventType
|
||||
---@field DropItem EventType
|
||||
---@field EntityDeath EventType
|
||||
events = {}
|
||||
|
||||
|
||||
---@param id EventType
|
||||
---@param handler fun(params: any): void
|
||||
---@return void
|
||||
function event(id, handler) end
|
||||
|
||||
---@param command string
|
||||
---@param handler fun(params: string[]): void
|
||||
---@return void
|
||||
function command(command, handler) end
|
||||
|
||||
---@param trigger string
|
||||
---@param handler fun(pressed: boolean): void
|
||||
---@return void
|
||||
function hotkey(trigger, handler) end
|
In neuem Issue referenzieren
Einen Benutzer sperren