Adds a command (/copyval) which will convert the held Code Value into a string and copy it, if possible.
Configuration exists for the command to change the format of the string copied using Java's format syntax.
Intended Use:
This command is intended to be used by players using external DF programming languages. It provides a relatively convenient method to convert common code values into a custom string format to be pasted into a script.
Available Settings:
Note:
It is definitely possible to add some more advanced configuration, like some type of regex replacement rules or something, though that feels very overkill for this.
Files Changed:
CommandHandler.java - Registers CopyValueCommand
CopyValueCommand.kt - Holds logic for the command, bulk of the code
CommandsGroup.java - Adds a new group and settings related to the command
ValueItemUtils.kt - Helper file to add ItemStack#getDFValueItemData() for CopyValueCommand.
en_us.json - Descriptions and names for settings
Solo Testing:
Invalid Cases:
/copyval while holding air, correctly errors (Can't be air)
/copyval while holding a random item, correctly errors (Not a value)
/copyval while holding sound, correctly errors (Unsupported)
/copyval while holding particle, correctly errors (Unsupported)
/copyval while holding potion, correctly errors (Unsupported)
/copyval while holding variable, correctly errors (Unsupported)
/copyval while holding game value, correctly errors (Unsupported)
/copyval while holding parameter, correctly errors (Unsupported)
Number:
/copyval while holding a simple number item, correctly copies
/copyval while holding a number item with %math, correctly copies
/copyval while holding an unset number item, correctly treats it as 0
/copyval with 1 correctly treated as simple
/copyval with 1.0 correctly treated as simple
/copyval with 0.5 correctly treated as simple
/copyval with .5 correctly treated as simple
/copyval with 1.0002 correctly treated as non-simple
/copyval with %math(2) correctly treated as non-simple
Location:
/copyval while holding a location item, correctly copies
/copyval while holding an unset location item, correctly treats it as 0, 0, 0, 0, 0
Vector:
/copyval while holding a vector item, correctly copies
/copyval while holding an unset vector item, correctly treats it as 0, 0, 0
String
/copyval while holding a string item, correctly copies (With delim + esc)
/copyval while holding a string item, blank delimiter setting, correctly ignores escape and uses raw value
/copyval while holding a string item, blank escape setting, correctly ignores delimiter and uses raw value
/copyval while holding a string item, blank escape and delimiter setting, correctly uses raw value
/copyval while holding an unset string item, correctly treats it as "string"
Text:
/copyval while holding a text item, correctly copies (With delim + esc)
/copyval while holding a text item, blank delimiter setting, correctly ignores escape and uses raw value
/copyval while holding a text item, blank escape setting, correctly ignores delimiter and uses raw value
/copyval while holding a text item, blank escape and delimiter setting, correctly uses raw value
/copyval while holding an unset text item, correctly treats it as "text"
Overview:
Adds a command (
/copyval
) which will convert the held Code Value into a string and copy it, if possible. Configuration exists for the command to change the format of the string copied using Java's format syntax.Intended Use:
This command is intended to be used by players using external DF programming languages. It provides a relatively convenient method to convert common code values into a custom string format to be pasted into a script.
Available Settings:
Note:
It is definitely possible to add some more advanced configuration, like some type of regex replacement rules or something, though that feels very overkill for this.
Files Changed:
Solo Testing:
Invalid Cases:
/copyval
while holding air, correctly errors (Can't be air)/copyval
while holding a random item, correctly errors (Not a value)/copyval
while holding sound, correctly errors (Unsupported)/copyval
while holding particle, correctly errors (Unsupported)/copyval
while holding potion, correctly errors (Unsupported)/copyval
while holding variable, correctly errors (Unsupported)/copyval
while holding game value, correctly errors (Unsupported)/copyval
while holding parameter, correctly errors (Unsupported)Number:
/copyval
while holding a simple number item, correctly copies/copyval
while holding a number item with %math, correctly copies/copyval
while holding an unset number item, correctly treats it as 0/copyval
with1
correctly treated as simple/copyval
with1.0
correctly treated as simple/copyval
with0.5
correctly treated as simple/copyval
with.5
correctly treated as simple/copyval
with1.0002
correctly treated as non-simple/copyval
with%math(2)
correctly treated as non-simpleLocation:
/copyval
while holding a location item, correctly copies/copyval
while holding an unset location item, correctly treats it as 0, 0, 0, 0, 0Vector:
/copyval
while holding a vector item, correctly copies/copyval
while holding an unset vector item, correctly treats it as 0, 0, 0String
/copyval
while holding a string item, correctly copies (With delim + esc)/copyval
while holding a string item, blank delimiter setting, correctly ignores escape and uses raw value/copyval
while holding a string item, blank escape setting, correctly ignores delimiter and uses raw value/copyval
while holding a string item, blank escape and delimiter setting, correctly uses raw value/copyval
while holding an unset string item, correctly treats it as "string"Text:
/copyval
while holding a text item, correctly copies (With delim + esc)/copyval
while holding a text item, blank delimiter setting, correctly ignores escape and uses raw value/copyval
while holding a text item, blank escape setting, correctly ignores delimiter and uses raw value/copyval
while holding a text item, blank escape and delimiter setting, correctly uses raw value/copyval
while holding an unset text item, correctly treats it as "text"