Functions
<>
around them are optional.HOME
key at any point to jump to the top of the pageEND
key at any point to jump to the bottom of the pageattack
attack( <Number: millis> )
Causes the player to rapidly click or hold the attack
keybinding (lmb
) when millis is…
Value | Result |
---|---|
nil | Instantly press and release the attack kebind. |
-1 | Hold the attack keybind continuously. |
0 | Cancel’s the action |
millis > 0 | Attack keybind is held for that many milliseconds. |
back
back( Number: millis )
Causes the player hold the back
keybinding (s
) when millis is…
Value | Result |
---|---|
-1 | Hold the back keybind continuously. |
0 | Cancel’s the action |
millis > 0 | Back keybind is held for that many milliseconds. |
connect
connect( String: serverIP )
Attempts to connect you to a server.
customizeSkin
customizeSkin( String: Part, Boolean: value )
Turns skin layers on or off for the player.
Parts | Alias |
---|---|
hat | helmet |
jacket | chest |
left leg | |
right leg | |
left arm | |
right arm | |
cape |
disconnect
disconnect()
Leaves the server you are connected too.
drop
drop( <Boolean: Drop All> )
Throw your currently held item. (like q
) If true
is given as an arg then it will drop the whole stack. If no arg is passed
entityRayTrace
entityRayTrace{ … }
everything is optional
Arg | Type | Alias | Note |
---|---|---|---|
yaw | Number | If set, pitch defaults to player pitch | |
pitch | Number | If set, yaw defaults to player yaw | |
to | Table | target ,dest ,destination | Alternative to yaw & pitch , {x,y,z} end point of the vector |
from | Table | src , source | defaults to player eyePos |
fluids | Boolean | fluid , liquid , liquids , stopOnLiquid | |
reach | Number | dist ,distance ,range | if using to vector is scaled to reach length |
Defaults player eye pos, player look direction, player reach amount, and fluids true
Returns
Key | Type | Note |
---|---|---|
entityID | Number | |
getEntityInfo | Function | shortcut for getEntity( .entityID ) |
subHit | Number | idk |
vec | Table | {x,y,z} of the hit pos |
forward
Causes the player hold the forward
keybinding (w
) when millis is…
Value | Result |
---|---|
-1 | Hold the forward keybind continuously. |
0 | Cancel’s the action |
millis > 0 | forward keybind is held for that many milliseconds. |
getBiome
getBiome( <Number: BlockX, Number: BlockZ> )
Returns a table with details about the biome either at the players location or the given location.
Output:
key | type |
---|---|
canSnow | Boolean |
canRain | Boolean |
rainfall | Number |
temp | String |
Tempatures |
---|
ocean |
cold |
medium |
warm |
getBlock
getBlock( Number: x, Number: y, Number: z )
Returns a table with information about a block at the given position. If the block requested is not loaded or is void air
then it will return false.
Key | Type | Description |
---|---|---|
id | String | The block id, such as “minecraft:stone” |
name | String | The block name, such as “Stone” |
nbt | Table | NBT tag data about the block This is limited to tile entites and client side info. |
harvestTool | String | The best tool to break this block. Not every block has a harvest tool and this may be omited |
mapColor | Table | The color this block would be on a map in {r,g,b,a} format |
getBlockLight
getBlockLight(<Number: x, Number: y, Number: z>)
Returns the current block light level at a given position. If no position is given it will use the players position.
getBlockList
getBlockList()
A bit of a misnomer, this function returns a table of all blocks
and items
in the game (including mods). Each entry will be what it would look like if you had an item stack of 1
in an inventory and log
ed it. The table uses the item id (such as minecraft:birch_stairs
) as the key, and the example item as the value.
getBoundingBox
getBoundingBox( Number: blockX, Number: blockY, Number: blockZ )
getBoundingBox( {Number: blockX, Number: blockY, Number: blockZ} )
getBoundingBox( Number: EntityID )
Returns a table with functions relating to a bounding box of a block or entity.
For blocks, a second return value of true
or false
will be returned indicating if the block is solid.
function name | args | return value(s) | description |
---|---|---|---|
contains | Number: x, Number: y, Number: z | Boolean | Checks if a point exists inside the bounding box |
contract | Number: x, Number: y, Number: z | Makes the bounding box smaller in a direction. Negative numbers reduce the side on the negative of that axis | |
expand | Number: x, Number: y, Number: z | Makes the bounding box bigger in a direction. Negative numbers effect the negative sides. | |
getCenter | Number: x, Number: y, Number: z | Returns the center point of this bounding box | |
getPoints | Number: xMin, Number: yMin, Number: zMin Number: xMax, Number: yMax, Number: zMax | Returns the points defining this bounding box | |
grow | Number: amount | Expands a bounding box on all sides. | |
intersects | BoundingBox | Boolean | Returns true if the two bounding boxes overlap |
intersect | BoundingBox | BoundingBox | Creates a new bounding box where the two bounding boxes overlap. |
offset | Number: x, Number: y, Number: z | Moves the bounding box by the given amount | |
shrink | Number: amount | Contracts the bounding box on all sides | |
Union | BoundingBox | BoundingBox | Creates a new bounding box using the MIN of one and the MAX of another |
findEntityOnPath | Number: x, Number: y, Number: z or {x, y, z} | Creates a line starting from the bounding box’s center to the center + the vector. The first entity that is found to cross this region (including the box’s size) is returned. |
getChunkUpdateCount
getChunkUpdateCount()
Returns the number of chunk updates as seen in the F3
debug menu.
getEntity
getEntity( Number:ID <,Boolean coerce> )
Returns a table with information about an entity much like getPlayer()
.getEntityList()
can be used to locate an entity’s ID number.
If coerce
is true
then a luajava
version of the entity is returned instead.
Key | Type | Note | |
---|---|---|---|
name | String | ||
class | String | Recommended for checking if a mob is the correct type. (Name tags will affect ‘name’) | |
pos | Table | Entity position as {x,y,z} | |
dimension | Table | ||
pitch | Number | The Up/Down rotation of the entity’s head | |
yaw | Number | The Left/Right rotation of the entity’s head | |
fallDist | Number | How far the entity has fallen. 0 if the entity is not falling. | |
height | Number | ||
width | Number | ||
hurtResTime | Number | How long until the entity can take damage again. | |
isCollidedHoriz | Boolean | ||
isCollidedVert | Boolean | ||
isNoClip | Boolean | If the entity can pass through blocks like a spectator | |
onGround | Boolean | ||
isInvulnerable | Boolean | ||
team | String | none or the teams name | |
velocity | {Number, Number, Number} | {x, y, z} velocity of the entity | |
health | Number | ||
isOnLadder | Boolean | ||
potionEffects | Table | Each entry describes another potion effect | |
air | Number | Amount of air remaining until the entity starts drowning | |
isInWater | Boolean | ||
isInLava | Boolean | ||
immuneToFire | Boolean | ||
isImmuneToExplosion | Someone, give this to a creeper | ||
isOnFire | Boolean | ||
isSprinting | Boolean | ||
entityRiding | Table | Lists all the stuff in this table, but for the entity that is being ridden. | |
isInvisible | Boolean | ||
nbt | Table* | In some cases nbt may show up as false if an error occured getting it | |
uuid | String | ||
lookingAt | {Number, Number, Number} | What block the entity is looking at |
getEntityList
getEntityList()
Returns a list of entities loaded in your chunks.
Each entity will have…
name | Either the nametag name, player name, or entity type |
id | ID number used to get more information about this entity |
class | Exact type of entity |
getEntityNBT
getEntityNBT( Number: ID )
Return a table with just the NBT data for an entity.
ID number is from the getEntityList()
function.
getFps
getFps()
Returns the current FPS as seen in the F3
debug menu.
getHotbar
getHotbar()
Returns the currently selected hotbar index.
(1
-9
)
getInventory
getInventory( <String: name> )
Returns a table listing the players inventory contents.
If a name is given it will return the visible part of another players inventory (or false if no player is found).
getJarLibLoaders
….Looks like this returns a table where jars can be added so require can find them..?
getLight
getLight(<Number: x, Number: y, Number: z>)
Returns the current block and sky light level at a given position. If no position is given it will use the players position.
Return values:
light level, sky, block
getLoadedPlayers
getLoadedPlayers()
Returns a list of any players in your loaded chunks.
getPlayer
getPlayer( <String: name> )
Returns a hoard of information in a table about your player (no arg), or the target player (name arg).
Key | Type | Note |
---|---|---|
name | String | |
inventory | Table | Lists everything you’d see in getInventory() |
pos | Table | Entity position as {x,y,z} |
mainHand | Table | Item held in mainHand or false |
offHand | Table | Item held in offHand or false |
invSlot | int | equivilant of getHotbar() |
dimension | Table | |
pitch | Number | The Up/Down rotation of the entity’s head |
yaw | Number | The Left/Right rotation of the entity’s head |
exp | Number | Players experience points in this level |
expLevel | Number | Player experience level |
expTotal | Number | Total experience with prior levels |
eyeHeight | Number | How far from the ground the players eyes are located. Changes when sneaking. |
fallDist | Number | How far the entity has fallen. 0 if the entity is not falling. |
height | Number | |
width | Number | |
swingProgress | Number | Precentage before swing motion is complete and ready to attack again. |
maxHurtResTime | Number | How long until the entity can take damage again. |
isCollidedHori | Boolean | |
isCollidedVert | Boolean | |
isNoClip | Boolean | If the entity can pass through blocks like a spectator |
onGround | Boolean | |
isInvulnerable | Boolean | |
bedLocation | {Number, Number, Number} | May be omitted if unset or unavailable. |
team | String | none or the teams name |
luck | Number | Current luck amount |
velocity | {Number, Number, Number} | {x, y, z} velocity of the entity |
health | Number | |
hunger | Number | |
isOnLadder | Boolean | |
hasNoGravity | Boolean | |
potionEffects | Table | Each entry describes another potion effect |
air | Number | Amount of air remaining until the entity starts drowning |
isInWater | Boolean | |
isInLava | Boolean | |
immuneToFire | Boolean | |
isImmuneToExplosion | Boolean | Someone, give this to a creeper |
isOnFire | Boolean | |
isSprinting | Boolean | |
isSneaking | Boolean | |
isEyltraFlying | Boolean | |
isSleeping | Boolean | |
entityID | Number | Used in entity highlighting |
gamemode | String | spectator , creative , survival Seems adventure mode may show up as survival. [BUG] |
entityRiding | Table | Lists all the stuff in this table, but for the entity that is being ridden. |
isInvisible | Boolean | |
uuid | String | |
lookingAt | {Number, Number, Number} | What block the entity is looking at |
getPlayerBlockPos
getPlayerBlockPos( <String: name> )
Returns the block position of either yourself or a player by name.
If a player can not be found the function will return false
The position will always be whole numbers.
If you want the decimal part, use getPlayerPos()
getPlayerList
getPlayerList()
Returns a list of players on the server. This is not limited to loaded chunks like getLoadedPlayers()
.
getPlayerNBT
getPlayerNBT( <String: PlayerName> )
Returns the NBT data for a player or yourself.
getPlayerPos
getPlayerPos( <String: Player Name >)
Returns the exact players position of your player or the given player. If the player can’t be found then it will return false
local x, y, z = getPlayerPos()
getProfile
getProfile()
Returns the name of the current profile from the bindings menu.
getRecipes
getRecipes( <String: item> )
Returns a list of crafting recipes. If an item
is specified, any recipes whos output item id contains item
in the string will be added to the list.
For example: stone
will add minecraft:stone
’s recipe as well as minecraft:cobblestone_stairs
because it has the word stone
in it.
For
local recipes = getRecipes()
The output is formated as follows: recipes[recipeType
][recipeNumber
]['in'
/'out'
]
For input
items:
- shaped recipes will list items as [x][y][options]
- shapless recipes will list items as [x][options] For
output
items: - Will list the output item directly
getScreen
getScreen()
Returns a new image
with controls with the pixel data being a screenshot of the game.
getSettings
getSettings()
Returns a table containing any mod settings and controls for Minecraft settings.
Some useful stuff: getSettings().editor.colors.textFill
controls the background color in the editor. (Transparent colors are allowed) All of the mod’s colors are defined in the settings and can be changed to whatever you like.
getSettings().chat.maxLines
Controls the number of lines the chat can store before it starts removing messages. By default Minecraft has this as 100
. Changing this can be useful for looking at large tables in chat. A good number to use would be 1000
.
maxLines
too large may cause lag after many messages accumulate.getSettings().scriptBrowser.columns
Controls how many columns are in the file browser. (Too many may cause them to overlap) getSettings().profiles
This is the table where each binding profile is saved. You can edit them from here if you want to do so. getSettings().minecraft
Returns a table with functions for changing Minecraft settings
Function Name | Args | Return Value(s) | Description |
---|---|---|---|
getFov | Number | Current FOV | |
setFov | Number:FOV | Sets FOV. Can be out of normal range. | |
getVolume | String:Category | Number | Gets the volume for a selected sound category. [See table below] |
setVolume | String:Category, Number:volume | Sets the volume for some category. [See table below] | |
setRenderDistance | Number | Sets your render distance. Value is clamped to range of 2 to 32 | |
getRenderDistance | Number | Returns the render distance setting. | |
setFullscreen | Arg defaults true. Sets the game to fullscreen or exits fullscreen with false. | ||
isFullscreen | Boolean | Is the game full screen. | |
getSkinCustomization | Table | Returns a table listing if a skin layer is on or off. | |
getSkinCustomization | String | Boolean | Returns a boolean indicating if a skin layer is on or off. |
getMaxFps | Number | Returns the FPS limit | |
setMaxFps | Number | Sets the max FPS | |
setAdvancedItemTooltips | Boolean | Enable or disable advanced tooltips. (shows durability and id on items) | |
isAdvancedItemTooltips | Boolean | Check if advanced tooltips are visible | |
getSmoothLighting | String | Lighting mode of off , min , or max | |
setSmoothLighting | String:Mode | Sets smooth lighting mode. Modes are off , min , or max | |
setAutoJump | Boolean:autoJump | Sets if the player uses auto jump. | |
isAutoJump | Boolean | Returns if the player has auto jump enabled. | |
getChatOpacity | Number | Returns current opacity of the chat | |
setChatOpacity | Number | ||
getChatScale | Number | ||
setChatScale | Number | ||
getChatHeightFocused | Number | ||
setChatHeightFocused | Number | ||
getChatHeightUnfocused | Number | ||
setChatHeightUnfocused | Number | ||
setChatWidth | Number | ||
getChatWidth | Number | ||
setCloudsMode | String | Sets the mode for cloud rendering. Modes are off , fast , or fancy .(not case senstive) | |
getCloudsMode | String | Returns render mode for clouds. Modes are off , fast , or fancy | |
setDifficulty | String | Sets the difficulty using the difficulty name. peaceful ,easy ,normal ,hard | |
setDifficulty | Number | Sets the difficulty using:0 forpeaceful1 foreasy2 fornormal3 forhard | |
getDifficulty | String | Returns the current difficulty as a string | |
setVsync | Boolean | Sets if the game should use vsync | |
isVsync | Boolean | Returns true if render settings has vsync enabled | |
setEntityShadows | Boolean | Set if the game should render shadows for entities | |
isEntityShadows | Returns true if the game currently renders entity shadows | ||
setFancyGraphics | Boolean | Sets if the game should use fancy graphics | |
isFancyGraphics | Boolean | Returns true if the game is currently using fancy graphics | |
setGuiScale | String | Sets the GUI scale to one of the following modes:auto , small , normal , large | |
getGuiScale | String | Returns the current GUI scale as a string. | |
setHeldItemTooltips | Boolean | For versions 9.0.2 and earlier, function acts the same as: setAdvancedItemTooltips Sets if held item tooltips are enabled. | |
isHeldItemTooltips | Boolean | Returns true if held item tooltips are enabled | |
setInvertMouse | Boolean | Sets if the mouse should be inverted | |
isInvertMouse | Boolean | Returns true if the mouse is being inverted | |
getLanguage | String | Returns the language code for the current language. Example: en_us | |
getLanguages | Table | Returns a table with all valid language codes. | |
setLanguage | String | Sets the current language used by the game | |
getLastServer | String | Returns the ip of the last server the player was connected to. | |
getMainHandSide | String | Returns which hand is used as the main hand. Sides are left and right | |
setMainHandSide | String | Set which hand is used as your main hand | |
getMipmapLevels | Returns the current mipmap level | ||
setMipmapLevels | Number | Sets the number of mimpap levels used. | |
getMouseSensitivity | Number | Returns the current mouse sensitivity setting | |
setMouseSensitivity | Number | Sets the mouse sensitivity | |
setParticleLevel | String | Sets the particle level for rendering. Options are:all decreased minimal | |
getParticleLevel | String | Returns the current particle level as a string | |
setPauseOnLostFocus | Boolean | Sets if the game should pause if you switch out of the game. Equivilant of: F3 +P | |
isPauseOnLostFocus | Check if the game will pause if no longer focused. | ||
setSmoothCamera | Boolean | Set if smooth camera is enabled | |
isSmoothCamera | Check if smooth camera is enabled | ||
setPerspective | String | Changes the players camera view like F5 . Options are:first front back | |
getPerspective | Return the players perspective as a string | ||
setTouchscreenMode | Boolean | Set if touchscreen mode should be used | |
isTouchscreenMode | Boolean | Check if touchscreen mode is enabled | |
setViewBobbing | Boolean | Set if view bobbing should be used. | |
isViewBobbing | Check if view bobbing is enabled. |
Sound Categories |
---|
master |
music |
record |
weather |
block |
hostile |
neutral |
player |
ambient |
voice |
getSettings().save()
Saves all changes you made to settings. Be sure to call this after making changes.
getSkyLight
getSkyLight( <Number:x, Number:y, Number:z> )
Returns the light level provided from the sky at a given position or the players current block pos.
getSound
getSound( String:file ) Returns a table with controls for playing a sound. When a sound stops because it has finished playing or has been stopped with the stop
function the resources are released and are not reuseable.
playSound
, getSound
follows the same file access rules the rest of the mod follows [Link needed].With no prefix on the file this is the same folder as your script runs from
Controls:
Function Name | Args | Return Value(s) | Description |
---|---|---|---|
isPlaying | Boolean | Returns true if this instance of the sound is currently playing. | |
stop | Stops this instance of a sound also causeing an resources used to be released. | ||
loop | Number | Sets the number of times to play the sound.-1 and nil will loop endlessly | |
pause | Stops the audio without discarding resources. Playing will resume where the sound stopped. | ||
play | Starts or resumes playing of an audio clip. | ||
setVolume | Number | Sets the volume for the sound. Volume should be between 0 and 1 . |
getWorld
getWorld()
Returns a table containing information about the current world or false
if you are not currently in a world.
Key | Type | Note |
---|---|---|
border | Table | world border |
cleanWeatherTime | Number | seems to always be 0 … |
difficulty | String | "peaceful" ,"easy" ,"normal" ,"hard" |
gameType | String | "creative" ,"spectator" ,"survival" ,"adventure" |
isDaytime | Boolean | |
isDifficultyLocked | Boolean | |
isHardcore | Boolean | |
isRemote | Boolean | …true even in single player? |
moonPhase | Number | |
name | String | |
rainTime | Number | also always 0 … |
seed | Number | minecraft world seed, 0 if unavailable |
spawn | Table | {x ,y ,z } |
weather | String | clear ,rain ,thunder Never clear directly to thunder or back |
worldTime | Number | in ticks |
border
Key | Type | Note |
---|---|---|
centerX | Number | |
centerZ | Number | |
dmgAmount | Number | |
radius | Number | |
size | Number | slightly smaller than radius |
warningDist | Number |
moonPhase
value | name | |
---|---|---|
0 | Full moon | |
1 | Waning gibbous | |
2 | Last quarter | |
3 | Waning crescent | |
4 | New Moon | |
5 | Waxing crescent | |
6 | First quarter | |
7 | Waxing Gibbous |
highlightEntity
highlightEntity( Number: entityID, String: action <,Boolean: active> )
Causes an entity to be rendered as glowing or rendered on top of everything else.
actions | |
---|---|
glow | Glowing effect |
xray | Render on top |
httpRequest
**httpRequest{ args… }
Arg | Type | Optional | Default | Note |
---|---|---|---|---|
url | string | No | http: or https: is required in url | |
requestMethod | string | Yes | GET | |
requestProperties | table | Yes | nil | |
timeout | number | Yes | 10 | value is in seconds |
doOutput | boolean | Yes | false | set to true if you need to send data to the server |
followRedirects | boolean | Yes | ? |
Returns
Table
Value | Type | Note |
---|---|---|
disconnect | Function | disconnect from the server |
err | Function | returns error input stream |
getContentEncoding | Function | |
getContentLength | Function | returns number of bytes |
getFollowRedirects | Function | |
getHeaderFields | Function | returns table with headers |
getResponseCode | Function | returns number |
getURL | Function | returns url used for this request |
input | Function | returns input stream used to read from server |
httpQuick
httpQuick( String:url )
Returns
Table
Value | Type | Note |
---|---|---|
.code | Number | http response code integer |
.headers | Table | response headers from server |
.length | Number | length of response in bytes |
.response | String | string returned by server |
:parse() | Boolean | turns json response into table, returns success |
.json | Table | when parsed, json as table |
:save( String:file ) | saves as file in "~/downloads/"..file | |
:status() | fancy print on chat | |
.time | Number | milliseconds since request and full receive |
.type | Table | .response.headers['Content-Type'] |
.url | String | Url from function call |
Since
MC | AM |
---|---|
1.12.2 | 7.11.0 |
isKeyDown
isKeyDown(String: keyName)
Returns a boolean if a key is held or mouse button is held. The key name will match the name used in the bindings menu.
jump
jump() Makes the player jump
key
key( String:keyName <, Number:duration> )
Holds the key with the matching name down for duration
seconds.
Default duration is 0
,
When duration <= 0
the key is released
left
left( <Number: duration>)
Holds the left strafe key (a
) for the provided duration.
Default duration is 0
,
When duration <= 0
the key is released
listTextures
listTextures() returns a list of textures.
Try in REPL
tex = listTextures()
b = hud3D.newBlock()
b.changeTexture("block:"..tex[11])
b.enableDraw()
loader
?
log
log( … ) Writes text to the chat.
log
Basic usage
log"Hello world!"
log("Hello"," ","world!")
log("You're using AM v",_MOD_VERSION)
Coloring & Formatting
You can add &
codes to color/format your text.
Formatting is applied up until the next color change or arg
log("&aHello World") --green
log("&aHello &BWorld") --green then green &bold
log("&BHello &aworld") --bold & white, then green and not bold
log("&aHello"," world") --world is written with wite text
&
by writing them as &&
log"This && That"
& Code | Effect |
---|---|
0 | Reset all formating, Color to BLACK |
1 | Reset all formating, Color to DARK BLUE |
2 | Reset all formating, Color to DARK GREEN |
3 | Reset all formating, Color to DARK AQUA |
4 | Reset all formating, Color to DARK RED |
5 | Reset all formating, Color to DARK PURPLE |
6 | Reset all formating, Color to GOLD |
7 | Reset all formating, Color to GRAY |
8 | Reset all formating, Color to DARK GRAY |
9 | Reset all formating, Color to BLUE |
a | Reset all formating, Color to GREEN |
b | Reset all formating, Color to AQUA |
c | Reset all formating, Color to RED |
d | Reset all formating, Color to LIGHT PURPLE |
e | Reset all formating, Color to YELLOW |
f | Reset all formating, Color to WHITE |
B | Bold |
I | Italics |
O | Obfuscated |
S | Strikethru |
U | Underlined |
Click Events
When a click &
code is added, the next argument after the string is consumed
log("&a&NHover here&f &b&U&FClickMe","A &atooltip&f!",function(formatted,unformatted) log"You clicked it!" end, " &d&U&FAnother clickable", {hover="Do it!", click=function(formatted,unformatted) log("&a&BIt worked!") end})
& Code | Effect | Consumes |
---|---|---|
F | Function - Triggeres a function, receives args (formattedText, unformattedText) | Function |
R | Run - Causes the player to say something, usually used for commands | String |
T | Type - Suggest text, puts text into the chat input without pressing enter | String |
L | Link - URL | String URL or table {click=”url”, hover=”tooltip text”} |
N | None - No click action, only tooltip | String tooltip or table {hover=”tooltip text”} |
* | Open File - Like the link for a screenshot | String file |
look
look( Number:yaw, Number:pitch <, Number:millis> )
Make the player turn their head to some yaw
and pitch
.
If millis
is not provided, head instantly snaps to the angle
If millis
is provided, head smoothly turns over that many milliseconds.
(Non blocking)
lookAt
**lookAt( Number:x, Number:y, Number:z <, Number:millis>)
Make the player turn their head to some x
,y
,z
.
If millis
is not provided, head instantly snaps to the angle
If millis
is provided, head smoothly turns over that many milliseconds.
(Non blocking)
.5
to the x
,y
& z
narrate
narrate( String text <, Boolean:stopCurrentSpeach> )
Does text to speach for text
if the narrator is already saying somethign and stopCurrentSpeach
is true
, the narrator will be interrupted, else queued.
Default: false
newMutex
newMutex( String:name )
Creates a reference to a mutex used for thread saftey.
A mutex created with the same name as another both refer to the same lock.
Behavior
When a mutex is locked, no other threads will be able to lock until the thread that locked it unlocks it (or is cleaned up).
Example
Preventing spam
local function noSpam()
local mutex = newMutex"theincgi_noSpam" --unique name
if not mutex.tryLock() then
return
end
playSound("chimes.wav").play()
sleep(2000) --cooldown for playing the sound
mutex.unlock() --important!
end
for i=1,10 do
noSpam()
--try it without the mutex if you want to hear the difference
--playSound("chimes.wav").play()
waitTick()
end
Preventing race conditon
openInventory
openInventory()
Returns a table containing controls for interacting with inventories
Returned table contains…
Key | Value | Note |
---|---|---|
LMB | 0 | Constant used for left mouse button |
MMB | 2 | Constant used for middle mouse button |
RMB | 1 | Constant used for right mouse button |
click | function | |
close | function | |
closeAndDrop | ||
dragClick | ||
drop | ||
getHeld | ||
getMap | ||
getSlot | ||
getTotalSlots | ||
getType | ||
grabAll | ||
hotSwap | ||
mapping | ||
quick | ||
setRecipe | ||
split | ||
swap |
Click
.click( Number:slot <,Number:button> ) As if you clicked on a slot using your mouse
Close
.close() Closes the gui without dropping items held by the mouse
CloseAndDrop
.closeAndDrop() Normal behavior of closing the inventory screen, items dropped to ground if held by mouse.
DragClick
.dragClick( Table:slots <,Number:button> ) Distribute items across slots in order
Drop
.drop( Number:slot <,Boolean:stack>) Drop the item in the provided inventory slot.
If stack
is true, the whole stack is dropped instead of 1 item.
Default: false
GetHeld()
**.getHeld(
If coerce
is true, a the ItemStack is returned as userdata
GetMap()
.getMap() returns the slot mappings for the current container/inventory.
Typical Usage
local inv = openInventory()
local map = inv.getMap()
inv.click( map.hotbar[3] ) --clicks 3rd slot in hotbar
Possible Sections
Name | Type | Note |
---|---|---|
hotbar | Table | Players hotbar |
main | Table | The first 3 rows of your inventory |
boots | Number | Equipment slot |
leggings | Number | Equipment slot |
chestplate | Number | Equipment slot |
helmet | Number | Equipment slot |
offHand | Number | |
craftingIn | Table | keys are 1 to 4 or 1 to 9 depending on screen |
craftingOut | Number | |
slot | Number | The only slot in a beacon |
fuel | Number | in brewing stand or furnace |
input | Number | Top slot in brewing stand, anvil, villager or furnace |
output | Number | In brewing stand, anvil, villager or furnace |
contents | Table | When viewing a chest, dispenser, dropper or hopper |
item | Number | Left slot in anvil |
material | Number | Second slot in anvil |
tool | Number | Enchanting table |
lapis | Number | Enchanting table |
GetSlot
**.getSlot( Number:slot <,Boolean:coerce> )
If coerce
is true, a the ItemStack is returned as userdata
GetTotalSlots()
.getTotalSlots() returns the total number of slots for the current inventory
GetType()
.getType() returns the name of the current inventory
common ones with mappings are:
inventory |
enchantment table |
villager |
anvil |
beacon |
brewing stand |
chest |
double chest |
crafting table |
dispenser |
furnace |
hopper |
horse inventory |
shulker box |
GrabAll
.grabAll( Number:slot )
Like when you quickly double click an item to pick up all of the same type
HotSwap
**.hotSwap( Number:slot, Number:hotbarSlot ) Like when you hover an item in your inventory and hit a number key to switch items
1
-9
Mapping
table This is used by .getMap()
and contains all container mappings listed by inventory type .getMap()
basically does this:
local map = inv.mapping[ inv.getType() ]
Quick
**.quick( Table:slots, <,Number: limit> ) ** **.quick( Table:slots ) **
For quickly transfering inventory contents into a container #CHECK_ME
SetRecipe
.setRecipe( Number:recipeID <,Boolean:makeAll> )
Emulates clicking on a recipe from the recipe book.recipeID
is from getRecipes
If makeAll
is true
then it acts like shift clicking the recipe pulling in as many ingredients as it can.
pRun
pRun( String:file ) pcall, but for run
pickBlock
pickBlock() Middle click action
Survival: select hotbar slot with item or move item from inventory to current hotbar slot
Creative: select hotbar slot with item orcopy item to hand
pickItem
**pickItem( String:name <, Number:slot )
Attempts to pick an item from your inventory If it exists it is picked from hotbar or moved to the prefered slot Slot number is returned or false if none found
Source can be found here
playSound
playSound( String:soundName )
Counterintuitively this returns controls for playing a sound.
Sounds are located in ~/sounds
(AM Root dir)
If you’re planning to share your code, it’s instead recommended to use getSound
.
Controls | Returns | Note |
---|---|---|
.isPlaying() | Boolean | |
.stop() | stopped, next play is from start | |
.loop( | Loop times times, forever if <code> nil` | |
.pause() | pause audio, can resume | |
.play() | play/resume audio | |
.setVolume( Number:volume ) | volume is a % , so 0 to 1 | |
.getClip() | Userdata | LuaJava of audio clip |
print(…)
Puts text in the console.
rayTrace
**rayTrace(
vector2d
can be either yaw
,pitch
or {yaw,pitch}
vector3d
can be either x
,y
,z
or {x,y,z}
Returns false or a table containing info about the trace result
If hit block:
Key | Note |
---|---|
block | Table containing dmg , id and name |
pos | {x,y,z} block pos |
side | up down north east west south |
subHit | idk |
vec | {x,y,z} exact location of ray intersection |
right
right( <Number: duration>)
Holds the right strafe key (d
) for the provided duration.
Default duration is 0
,
When duration <= 0
the key is released
run
run( String:file, … )
Runs a script like a function returning any results.
Unlike require this does not save the returned results and instead runs it each time.
File access rules apply. File is local to the directory of the caller.
filesystem.resolve("",2)
to get the local directory of something earlier in the stack trace, 1 being the current scope and 2 being the previous callerrunThread
runThread( String file, … ) runThread( function:task, … )
Instantly starts the given file or function in a new thread with provided args.
Returns a table with thread controls for checking status and killing the thread if needed.
If you don’t wish to start the thread immediatly you can instead do
local myThread = thread.new( myFunction )
--or
local myThread = thread.new( function(...) run( "myScript.lua", ...)) end )
--then later
myThread.start()
say
say( String:msg ) Causes the player to speak into the chat. This can be used to run commands as well, just don’t forget the /
!
setHotbar
setHotbar( Number:slot ) Selects the hotbar slot.
Slot numbers are 1
through 9
setProfile
setProfile( String:profileName ) Changes the active profile in the bindings menu
returns false
if the profile could not be found.
sleep
sleep( Number:milliseconds )
Causes the script to pause for the given number of milliseconds.
sneak
**sneak(
Holds the sneak key (shift
) for the provided duration.
Default duration is 0
,
When duration <= 0
the key is released
sprint
**sprint(
Default: true, start sprinting
Causes the player to start or stop sprinting
stopAllScripts
stopAllScripts
Kills all running scripts. Like hitting CTRL
+AM Menu Key
and clicking each little [x]
CTRL
+ALT
+SHIFT
+AM Menu Key
swapHand
swapHand()
Switches your main hand’s item with your off hand’s item.
toast
**toast(
Default text for both is nil
use
use( <Number: duration> ) use()
Holds the use key (a
) for the provided duration.
When duration <= 0
the key is released
If no number is provided then it does an instantaneous click
waitTick
waitTick()
Causes the script to sleep until the next Minecraft tick starts.