public interface Arguments
extends java.lang.Iterable<java.lang.Object>
Callback
.
It allows checking for the presence of arguments in a uniform manner, taking
care of proper type checking based on what can be passed along by Lua.
Note that integer values fetched this way are actually double values that
have been truncated. So if a Lua program passes 1.9 and you do a
checkInteger you'll get a 1.
The indexes passed to the various functions start at zero, i.e. to get the
first argument you would use checkAny(0). This is worth mentioning
because Lua starts its indexes at one.Modifier and Type | Method and Description |
---|---|
java.lang.Object |
checkAny(int index)
Get whatever is at the specified index.
|
boolean |
checkBoolean(int index)
Try to get a boolean value at the specified index.
|
byte[] |
checkByteArray(int index)
Try to get a byte array at the specified index.
|
double |
checkDouble(int index)
Try to get a double value at the specified index.
|
int |
checkInteger(int index)
Try to get an integer value at the specified index.
|
net.minecraft.item.ItemStack |
checkItemStack(int index)
Try to get an item stack representation at the specified index.
|
java.lang.String |
checkString(int index)
Try to get a string value at the specified index.
|
java.util.Map |
checkTable(int index)
Try to get a table at the specified index.
|
int |
count()
The total number of arguments that were passed to the function.
|
boolean |
isBoolean(int index)
Tests whether the argument at the specified index is a boolean value.
|
boolean |
isByteArray(int index)
Tests whether the argument at the specified index is a byte array.
|
boolean |
isDouble(int index)
Tests whether the argument at the specified index is a double value.
|
boolean |
isInteger(int index)
Tests whether the argument at the specified index is an integer value.
|
boolean |
isItemStack(int index)
Tests whether the argument at the specified index is an item stack.
|
boolean |
isString(int index)
Tests whether the argument at the specified index is a string value.
|
boolean |
isTable(int index)
Tests whether the argument at the specified index is a table.
|
java.lang.Object |
optAny(int index,
java.lang.Object def)
Get whatever is at the specified index.
|
boolean |
optBoolean(int index,
boolean def)
Try to get a boolean value at the specified index.
|
byte[] |
optByteArray(int index,
byte[] def)
Try to get a byte array at the specified index.
|
double |
optDouble(int index,
double def)
Try to get a double value at the specified index.
|
int |
optInteger(int index,
int def)
Try to get an integer value at the specified index.
|
net.minecraft.item.ItemStack |
optItemStack(int index,
net.minecraft.item.ItemStack def)
Try to get an item stack at the specified index.
|
java.lang.String |
optString(int index,
java.lang.String def)
Try to get a string value at the specified index.
|
java.util.Map |
optTable(int index,
java.util.Map def)
Try to get a table at the specified index.
|
java.lang.Object[] |
toArray()
Converts the argument list to a standard Java array, converting byte
arrays to strings automatically, since this is usually what others
want - if you need the actual raw byte arrays, don't use this method!
|
int count()
java.lang.Object checkAny(int index)
index
- the index from which to get the argument.java.lang.IllegalArgumentException
- if there is no argument at that index.boolean checkBoolean(int index)
index
- the index from which to get the argument.java.lang.IllegalArgumentException
- if there is no argument at that index,
or if the argument is not a boolean.int checkInteger(int index)
index
- the index from which to get the argument.java.lang.IllegalArgumentException
- if there is no argument at that index,
or if the argument is not a number.double checkDouble(int index)
index
- the index from which to get the argument.java.lang.IllegalArgumentException
- if there is no argument at that index,
or if the argument is not a number.java.lang.String checkString(int index)
index
- the index from which to get the argument.java.lang.IllegalArgumentException
- if there is no argument at that index,
or if the argument is not a string.byte[] checkByteArray(int index)
index
- the index from which to get the argument.java.lang.IllegalArgumentException
- if there is no argument at that index,
or if the argument is not a byte array.java.util.Map checkTable(int index)
index
- the index from which to get the argument.java.lang.IllegalArgumentException
- if there is no argument at that index,
or if the argument is not a table.net.minecraft.item.ItemStack checkItemStack(int index)
Database
component to get complete item stack descriptors.index
- the index from which to get the argument.java.lang.Object optAny(int index, java.lang.Object def)
checkAny(int)
otherwise.
The returned object will be one of the following, based on the conversion
performed internally:
index
- the index from which to get the argument.boolean optBoolean(int index, boolean def)
checkBoolean(int)
otherwise.index
- the index from which to get the argument.java.lang.IllegalArgumentException
- if the argument exists and is not a boolean.int optInteger(int index, int def)
checkInteger(int)
otherwise.index
- the index from which to get the argument.java.lang.IllegalArgumentException
- if the argument exists but is not a number.double optDouble(int index, double def)
checkDouble(int)
otherwise.index
- the index from which to get the argument.java.lang.IllegalArgumentException
- if the argument exists and is not a number.java.lang.String optString(int index, java.lang.String def)
checkString(int)
otherwise.
This will actually check for a byte array and convert it to a string
using UTF-8 encoding.index
- the index from which to get the argument.java.lang.IllegalArgumentException
- if the argument exists and is not a string.byte[] optByteArray(int index, byte[] def)
checkByteArray(int)
otherwise.index
- the index from which to get the argument.java.lang.IllegalArgumentException
- if the argument exists and is not a byte array.java.util.Map optTable(int index, java.util.Map def)
checkTable(int)
otherwise.index
- the index from which to get the argument.java.lang.IllegalArgumentException
- if the argument exists and is not a table.net.minecraft.item.ItemStack optItemStack(int index, net.minecraft.item.ItemStack def)
checkItemStack(int)
otherwise.index
- the index from which to get the argument.java.lang.IllegalArgumentException
- if the argument exists and is not an item stack.boolean isBoolean(int index)
index
- the index to check.boolean isInteger(int index)
index
- the index to check.boolean isDouble(int index)
index
- the index to check.boolean isString(int index)
index
- the index to check.boolean isByteArray(int index)
index
- the index to check.boolean isTable(int index)
index
- the index to check.boolean isItemStack(int index)
index
- the index to check.java.lang.Object[] toArray()