Add Definitions for Luanalysis #192
@ -48,7 +48,7 @@ Der Code wird einfach in ein Minecraft Buch geschrieben und kann mit einem Links
|
|||||||
Im Repository liegen [Lua-Definitionen](sw.def.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.
|
Diese können in der IDE genutzt werden, um die APIs zu nutzen.
|
||||||
|
|
||||||
Einfach die `definitions.lua` in denselben Ordner wie das Script legen und die IDE sollte die APIs erkennen.
|
Einfach die `sw.def.lua` in denselben Ordner wie das Script legen und die IDE sollte die APIs erkennen.
|
||||||
|
|
||||||
# Basis-Apis
|
# Basis-Apis
|
||||||
Es werden folgende Standard-Apis zur Verfügung gestellt:
|
Es werden folgende Standard-Apis zur Verfügung gestellt:
|
||||||
|
185
definitions.lua
185
definitions.lua
@ -1,185 +0,0 @@
|
|||||||
-- 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
|
|
||||||
---
|
|
||||||
|
|
||||||
---@class inventory @define class inventory
|
|
||||||
---@field create fun(title: string, size: number): Inventory
|
|
||||||
inventory = {}
|
|
||||||
|
|
||||||
---@alias InventoryClick 'LEFT' | 'SHIFT_LEFT' | 'RIGHT' | 'SHIFT_RIGHT' | 'MIDDLE' | 'NUMBER_KEY'
|
|
||||||
|
|
||||||
---@shape Inventory
|
|
||||||
---@field item fun(slot: number, material: string, name: string, handler: fun(click: InventoryClick), lore?: string[], enchanted?: boolean, amount?: number: void)
|
|
||||||
---@field setCloseHandler fun(handler: fun(): void): void
|
|
||||||
---@field open fun(): void
|
|
||||||
|
|
||||||
---@class Callable<T>
|
|
||||||
---@overload fun(): T
|
|
||||||
---@overload fun(value: T): void
|
|
||||||
|
|
||||||
---@class player
|
|
||||||
---@field name fun(): string
|
|
||||||
---@field chat fun(message: string...): void
|
|
||||||
---@field actionbar fun(message: string...): void
|
|
||||||
---@field x fun(value?: number): void | number
|
|
||||||
---@field y fun(value?: number): void | number
|
|
||||||
---@field z fun(value?: number): void | number
|
|
||||||
---@field yaw fun(value?: number): void | number
|
|
||||||
---@field pitch fun(value?: number): void | number
|
|
||||||
---@field sneaking fun(): boolean
|
|
||||||
---@field sprinting fun(): boolean
|
|
||||||
---@field slot fun(value?: number): void | number
|
|
||||||
---@field item fun(): string
|
|
||||||
---@field offHandItem fun(): string
|
|
||||||
---@field closeInventory fun(): void
|
|
||||||
player = {}
|
|
||||||
|
|
||||||
---@class random
|
|
||||||
---@field nextInt fun(a?: number, b?: number): number
|
|
||||||
---@field nextDouble fun(a?: number, b?: number): number
|
|
||||||
---@field nextBool fun(): boolean
|
|
||||||
random = {}
|
|
||||||
|
|
||||||
---@alias RegionType 'wg' | 'mwg' | 'as' | 'ws' | 'ws_inner' | 'ws_rumpf' | 'ws_rahmen' | 'spawn'
|
|
||||||
|
|
||||||
---@class region
|
|
||||||
---@field name fun(): string
|
|
||||||
---@field type fun(): RegionType
|
|
||||||
---@field tnt tnt
|
|
||||||
---@field fire fun(): boolean
|
|
||||||
---@field freeze fun(): boolean
|
|
||||||
---@field protect fun(): boolean
|
|
||||||
---@field trace trace
|
|
||||||
---@field loader fun(): string
|
|
||||||
region = {}
|
|
||||||
|
|
||||||
---@alias TNTMode 'ALLOW' | 'DENY' | 'ONLY_TB'
|
|
||||||
|
|
||||||
---@class tnt
|
|
||||||
---@field mode fun(): TNTMode
|
|
||||||
---@field enabled fun(): boolean
|
|
||||||
---@field onlyTb fun(): boolean
|
|
||||||
|
|
||||||
---@class trace
|
|
||||||
---@field active fun(): boolean
|
|
||||||
---@field auto fun(): boolean
|
|
||||||
---@field status fun(): string
|
|
||||||
---@field time fun(): number
|
|
||||||
|
|
||||||
---@shape Position
|
|
||||||
---@field x number
|
|
||||||
---@field y number
|
|
||||||
---@field z number
|
|
||||||
|
|
||||||
---@class server
|
|
||||||
---@field time fun(): string
|
|
||||||
---@field ticks fun(): number
|
|
||||||
---@field getBlockAt fun(position: Position): string
|
|
||||||
---@field setBlockAt fun(position: Position, material: string): void
|
|
||||||
---@field tps tps
|
|
||||||
server = {}
|
|
||||||
|
|
||||||
---@class tps
|
|
||||||
---@field oneSecond fun(): number
|
|
||||||
---@field tenSecond fun(): number
|
|
||||||
---@field oneMinute fun(): number
|
|
||||||
---@field fiveMinute fun(): number
|
|
||||||
---@field tenMinute fun(): number
|
|
||||||
---@field current fun(): number
|
|
||||||
---@field limit fun(): number
|
|
||||||
|
|
||||||
---@class storage
|
|
||||||
---@field global storageLib
|
|
||||||
---@field player storageLib
|
|
||||||
---@field region storageLib
|
|
||||||
storage = {}
|
|
||||||
|
|
||||||
---@class storageLib
|
|
||||||
---@field get fun(key: string): any
|
|
||||||
---@field set fun(key: string, value: any): void
|
|
||||||
|
|
||||||
---@shape Selection
|
|
||||||
---@field max Position
|
|
||||||
---@field min Position
|
|
||||||
|
|
||||||
---@class _worldedit
|
|
||||||
---@field selection fun(pos?: Position[]): Selection | void
|
|
||||||
_worldedit = {}
|
|
||||||
|
|
||||||
---@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
|
|
||||||
|
|
||||||
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