Package dan200.computercraft.api.lua
Interface LuaTable<K,V>
- Type Parameters:
K- The type of keys in a table, will typically be a wildcard.V- The type of values in a table, will typically be a wildcard.
- All Superinterfaces:
Map<K,V>
- All Known Implementing Classes:
ObjectLuaTable
A view of a Lua table.
Much like IArguments, this allows for convenient parsing of fields from a Lua table.
- See Also:
-
Nested Class Summary
-
Method Summary
Modifier and TypeMethodDescriptiondefault voidclear()default booleangetBoolean(int index) Get an array entry as a boolean.default booleangetBoolean(String key) Get a table entry as a boolean.default doublegetDouble(int index) Get an array entry as a double.default doubleGet a table entry as a double.default doublegetFiniteDouble(int index) Get an argument as a finite number (not infinite or NaN).default doublegetFiniteDouble(String key) Get an argument as a finite number (not infinite or NaN).default intgetInt(int index) Get an array entry as an integer.default intGet a table entry as an integer.default longgetLong(int index) Get an array entry as an integer.default longGet a table entry as an integer.default StringgetString(int index) Get an array entry as a string.default StringGet a table entry as a string.default Map<?, ?> getTable(int index) Get an array entry as a table.default Map<?, ?> Get a table entry as a table.default intlength()Compute the length of the array part of this table.optBoolean(int index) Get an array entry as a boolean.optBoolean(String key) Get a table entry as a boolean.optDouble(int index) Get an array entry as a double.Get a table entry as a double.optFiniteDouble(int index) Get an argument as a finite number (not infinite or NaN).optFiniteDouble(String key) Get an argument as a finite number (not infinite or NaN).optInt(int index) Get an array entry as an integer.Get a table entry as an integer.optLong(int index) Get an array entry as an integer.Get a table entry as an integer.optString(int index) Get an array entry as a double.Get a table entry as a string.optTable(int index) Get an array entry as a table.Get a table entry as a table.default @Nullable Vdefault voiddefault VMethods inherited from interface java.util.Map
compute, computeIfAbsent, computeIfPresent, containsKey, containsValue, entrySet, equals, forEach, get, getOrDefault, hashCode, isEmpty, keySet, merge, putIfAbsent, remove, replace, replace, replaceAll, size, values
-
Method Details
-
length
default int length()Compute the length of the array part of this table.- Returns:
- This table's length.
-
getDouble
Get an array entry as a double.- Parameters:
index- The index in the table, starting at 1.- Returns:
- The entry's value.
- Throws:
LuaException- If the value is not a number.- Since:
- 1.116
- See Also:
-
getDouble
Get a table entry as a double.- Parameters:
key- The name of the field in the table.- Returns:
- The field's value.
- Throws:
LuaException- If the value is not a number.- Since:
- 1.116
- See Also:
-
getLong
Get an array entry as an integer.- Parameters:
index- The index in the table, starting at 1.- Returns:
- The entry's value.
- Throws:
LuaException- If the value is not an integer.
-
getLong
Get a table entry as an integer.- Parameters:
key- The name of the field in the table.- Returns:
- The field's value.
- Throws:
LuaException- If the value is not an integer.
-
getInt
Get an array entry as an integer.- Parameters:
index- The index in the table, starting at 1.- Returns:
- The entry's value.
- Throws:
LuaException- If the value is not an integer.
-
getInt
Get a table entry as an integer.- Parameters:
key- The name of the field in the table.- Returns:
- The field's value.
- Throws:
LuaException- If the value is not an integer.
-
getFiniteDouble
Get an argument as a finite number (not infinite or NaN).- Parameters:
index- The index in the table, starting at 1.- Returns:
- The entry's value.
- Throws:
LuaException- If the value is not finite.- Since:
- 1.116
-
getFiniteDouble
Get an argument as a finite number (not infinite or NaN).- Parameters:
key- The name of the field in the table.- Returns:
- The field's value.
- Throws:
LuaException- If the value is not finite.- Since:
- 1.116
-
getBoolean
Get an array entry as a boolean.- Parameters:
index- The index in the table, starting at 1.- Returns:
- The entry's value.
- Throws:
LuaException- If the value is not a boolean.- Since:
- 1.116
-
getBoolean
Get a table entry as a boolean.- Parameters:
key- The name of the field in the table.- Returns:
- The field's value.
- Throws:
LuaException- If the value is not a boolean.- Since:
- 1.116
-
getString
Get an array entry as a string.- Parameters:
index- The index in the table, starting at 1.- Returns:
- The entry's value.
- Throws:
LuaException- If the value is not a string.- Since:
- 1.116
-
getString
Get a table entry as a string.- Parameters:
key- The name of the field in the table.- Returns:
- The field's value.
- Throws:
LuaException- If the value is not a string.- Since:
- 1.116
-
getTable
Get an array entry as a table.The returned table may be converted into a
LuaTable(usingObjectLuaTable) for easier parsing of table keys.- Parameters:
index- The index in the table, starting at 1.- Returns:
- The entry's value.
- Throws:
LuaException- If the value is not a table.- Since:
- 1.116
-
getTable
Get a table entry as a table.The returned table may be converted into a
LuaTable(usingObjectLuaTable) for easier parsing of table keys.- Parameters:
key- The name of the field in the table.- Returns:
- The field's value.
- Throws:
LuaException- If the value is not a table.- Since:
- 1.116
-
optDouble
Get an array entry as a double.- Parameters:
index- The index in the table, starting at 1.- Returns:
- The entry's value, or
Optional.empty()if not present. - Throws:
LuaException- If the value is not a number.- Since:
- 1.116
- See Also:
-
optDouble
Get a table entry as a double.- Parameters:
key- The name of the field in the table.- Returns:
- The field's value, or
Optional.empty()if not present. - Throws:
LuaException- If the value is not a number.- Since:
- 1.116
- See Also:
-
optLong
Get an array entry as an integer.- Parameters:
index- The index in the table, starting at 1.- Returns:
- The entry's value, or
Optional.empty()if not present. - Throws:
LuaException- If the value is not an integer.- Since:
- 1.116
-
optLong
Get a table entry as an integer.- Parameters:
key- The name of the field in the table.- Returns:
- The field's value, or
Optional.empty()if not present. - Throws:
LuaException- If the value is not an integer.- Since:
- 1.116
-
optInt
Get an array entry as an integer.- Parameters:
index- The index in the table, starting at 1.- Returns:
- The entry's value, or
Optional.empty()if not present. - Throws:
LuaException- If the value is not an integer.- Since:
- 1.116
-
optInt
Get a table entry as an integer.- Parameters:
key- The name of the field in the table.- Returns:
- The field's value, or
Optional.empty()if not present. - Throws:
LuaException- If the value is not an integer.- Since:
- 1.116
-
optFiniteDouble
Get an argument as a finite number (not infinite or NaN).- Parameters:
index- The index in the table, starting at 1.- Returns:
- The entry's value, or
Optional.empty()if not present. - Throws:
LuaException- If the value is not finite.- Since:
- 1.116
-
optFiniteDouble
Get an argument as a finite number (not infinite or NaN).- Parameters:
key- The name of the field in the table.- Returns:
- The field's value, or
Optional.empty()if not present. - Throws:
LuaException- If the value is not finite.- Since:
- 1.116
-
optBoolean
Get an array entry as a boolean.- Parameters:
index- The index in the table, starting at 1.- Returns:
- The entry's value, or
Optional.empty()if not present. - Throws:
LuaException- If the value is not a boolean.- Since:
- 1.116
-
optBoolean
Get a table entry as a boolean.- Parameters:
key- The name of the field in the table.- Returns:
- The field's value, or
Optional.empty()if not present. - Throws:
LuaException- If the value is not a boolean.- Since:
- 1.116
-
optString
Get an array entry as a double.- Parameters:
index- The index in the table, starting at 1.- Returns:
- The entry's value, or
Optional.empty()if not present. - Throws:
LuaException- If the value is not a string.- Since:
- 1.116
-
optString
Get a table entry as a string.- Parameters:
key- The name of the field in the table.- Returns:
- The field's value, or
Optional.empty()if not present. - Throws:
LuaException- If the value is not a string.- Since:
- 1.116
-
optTable
Get an array entry as a table.The returned table may be converted into a
LuaTable(usingObjectLuaTable) for easier parsing of table keys.- Parameters:
index- The index in the table, starting at 1.- Returns:
- The entry's value, or
Optional.empty()if not present. - Throws:
LuaException- If the value is not a table.- Since:
- 1.116
-
optTable
Get a table entry as a table.The returned table may be converted into a
LuaTable(usingObjectLuaTable) for easier parsing of table keys.- Parameters:
key- The name of the field in the table.- Returns:
- The field's value, or
Optional.empty()if not present. - Throws:
LuaException- If the value is not a table.- Since:
- 1.116
-
put
-
remove
-
putAll
-
clear
default void clear()
-