Happy New Year! Please enjoy a major update that makes your duckyPad even more powerful!
This update features a complete scripting engine overhaul, adds many long-requested features, and significantly expands duckyScript’s capabilities, making it even more general-purpose and versatile than ever before.
Highlights:
Click me for older update notes
Click & follow guides below:
dekuNukem gmail.com$ prefix is no longer required when working with variables
+=, -=, *= etc.
VAR foo = 100
foo += 5
STRING Value is: $foo
!THEN is no longer required in IF statements//
IF !foo
DELAY 100 // only if foo is 0
END_IF
C-Style Format Specifiers are now supported when printing variables!
Use it to adjust print format and padding.
VAR foo = -10
STRING Value is $foo
Value is -10
To add a specifier: Immediately after the variable name, type %, then a data-type indicator letter.
%d to print variable as Signed Decimal
%u to print variable as Unsigned Decimal%x to print variable as Lowercase Hexadecimal%X to print variable as Uppercase HexadecimalVAR $foo = -10
STRING Value is: $foo%d
STRING Value is: $foo%u
STRING Value is: $foo%x
STRING Value is: $foo%X
Value is: -10
Value is: 4294967286
Value is: fffffff6
Value is: FFFFFFF6
% and before the letterVAR $foo = 5
STRING I have $foo%10d apples!
I have 5 apples!
%, add a 0, then width number, then the letter.0VAR $foo = 5
STRING I have $foo%010d apples!
I have 0000000005 apples!
⚠️ This method replaces _STR_PRINT_FORMAT and _STR_PRINT_PADDING, which have been removed.
Functions now support arguments, return values, local variables, and recursive calls, making them much more powerful and versatile.
You can now use FUN and END_FUN to declare functions.
Old FUNCTION and END_FUNCTION still works of course.
As before, plain functions are handy for performing repetitive tasks.
FUN print_addr()
STRINGLN 123 Ducky Lane
STRINGLN Pond City, QU 12345
END_FUN
print_addr() // call it
But now, you can also pass arguments into a function and specify a return value.
FUN add_number(a, b)
RETURN a + b
END_FUN
VAR total = add_number(10, 20)
Variables declared outside functions have global scope, they can be accessed anywhere.
Variables declared inside functions now have local scope, they are only accessible within the function.
If a local variable has the same name as a global variable, the local var takes priority within that function.
// Both global scope
VAR x = 10
VAR y = 20
FUN scope_demo()
VAR x = 5 // This x is local, will shadow the global x.
x = x + y
STRINGLN Local x is: $x
END_FUN
Local x is: 25
You can now also call the same function within itself!
FUN factorial(n)
IF n <= 1
RETURN 1
END_IF
RETURN n * factorial(n - 1)
END_FUN
VAR fact = factorial(5)
With much more powerful function calls, a set of handy helper functions are provided as a StdLib.
To use them, add USE_STDLIB in your code.
USE_STDLIB
STRINGLN Press Key 3 to continue...
WAITKEY(3)
VAR high_score = MAX(100, 500)
STRINGLN The high score is: $high_score
You can now also create your own header for custom helper functions and more.
Edit Headers ButtonUSE_UH to your script to include them
Some built-in functions have been added.
They are always available, intended for low-level tinkering.
PUTS() RANDINT()
RANDCHR() HIDTX()
RANDUINT()
1024 Bytes of user scratch memory is available with PEEK() and POKE() commands.
Now available for VS Code and Sublime Text
FMOUSE: Forward side button
BMOUSE: Backward side button
MOUSE_SCROLL h vScroll mouse wheel Horizontal h lines, and Vertical v lines.
h: Positive scrolls RIGHT, negative scrolls LEFT.v: Positive scrolls UP, negative scrolls DOWN.0 for no scrollPrints message Center-Aligned on the current Y cursor position.
OLED_CPRINT hello world!OLED_CIRCLE and OLED_RECT now supports drawing in color black.
Types a random letter. Added from official duckyScript specs.
RANDOM_LOWERCASE_LETTER RANDOM_NUMBER
RANDOM_UPPERCASE_LETTER RANDOM_SPECIAL
RANDOM_LETTER RANDOM_CHAR
RANDOM_NUMBER
REPEAT 7
// types 8 random numbers
For more granular control, use RANDCHR() built-in function.
_SW_BITFIELD: Read status of all buttons at once_KBLED_BITFIELD: Holds keyboard LED statusPASS CommandDoes nothing, can be used as empty statement block.
6KROGlad you made it this far!
Please enjoy a flappy bird clone showcasing many of the new features in this update!

Let me know if you run into any bugs or have comments / suggestions.
dekuNukem gmail.com