SteamWar/BauSystem2.0
Archiviert
12
0

Add Definitions for Luanalysis
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Signed-off-by: Chaoscaot <chaoscaot@zohomail.eu>
Dieser Commit ist enthalten in:
Chaoscaot 2023-07-26 01:02:07 +02:00
Ursprung 9d644782a8
Commit f9c61808bb
Signiert von: Chaoscaot
GPG-Schlüssel-ID: BDF8FADD7D5EDB7A
2 geänderte Dateien mit 175 neuen und 0 gelöschten Zeilen

Datei anzeigen

@ -4,6 +4,7 @@
<!-- TOC -->
* [SteamWar.de - Script System](#steamwarde---script-system)
* [Einleitung](#einleitung)
* [Nutzung mit einer IDE](#nutzung-mit-einer-ide)
* [Basis-Apis](#basis-apis)
* [SteamWar.de-Api](#steamwarde-api)
* [player](#player)
@ -43,6 +44,12 @@
Das Script System auf SteamWar.de basiert auf [Lua](https://www.lua.org/docs.html).
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).
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.
# Basis-Apis
Es werden folgende Standard-Apis zur Verfügung gestellt:
- [`math`](https://www.lua.org/manual/5.4/manual.html#6.7)

168
definitions.lua Normale Datei
Datei anzeigen

@ -0,0 +1,168 @@
---
--- 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