DragonOSA RedPower revival

DragonBASIC machine commands

Every DragonBASIC command for bundled I/O, redstone, storage, Autocraft, Redbus and the network.

These commands connect DragonBASIC to the world. Addresses are Redbus addresses; see Redbus addresses.

Bundled I/O

For a Redbus I/O Expander. Colours are numbered 0 (white) to 15 (black).

Command Does
IOSET addr, color, state Switch one colour on (1) or off (0).
IOWRITE addr, mask Replace all sixteen outputs with a bit mask.
IOIN(addr) The sixteen inputs as a mask.
IOGET(addr, color) One input colour.
IOOUT(addr) The current outputs as a mask.

Redstone Adapter

For a Redstone Adapter (default address 10). A side is "front", "left", "right", "top", "bottom", a compass name such as "north" or "up", or a number.

Command Does
RSOUT addr, side, 0-15 Set a side's output strength.
RSPULSE addr, side, ticks Full strength for a number of ticks, then back to the set output.
RSIN(addr, side) The input strength arriving, 0 to 15.
RSOUT(addr, side) The output strength set on a side.
RSCMP(addr, side) What a comparator would read from the block there, such as a chest's fill level.
RSCOUNT(addr, side) Rising edges since the last call.
RSBLOCK$(addr, side) The block there, such as minecraft:wheat[age=7].
RSGROWN(addr, side) -1 when the crop there has finished growing.
10 IF RSCMP(10, "left") > 13 THEN PRINT "CHEST FULL" : GOTO 40
20 IF RSGROWN(10, "top") THEN RSPULSE 10, "front", 4
30 SLEEP 20 : GOTO 10
40 END

Storage and Autocraft

Command Does
STOCK("item id") How many of an item the connected drives hold.
FREE() Free space on the drives, in KB.
CRAFT "recipe id", times or CRAFT(…) Queue Autocraft crafts. The function returns how many were queued.
CANCRAFT("recipe id") Whether a recipe can be made now.
MISSING$("recipe id") What is missing for a recipe.
JOBS() How many of your jobs are queued.
EXPORT "item id", count or EXPORT(…) Send items from the drives out of a Storage Export Port.
PRINT STOCK("minecraft:oak_log")
CRAFT "minecraft:oak_planks", 4
PRINT MISSING$("minecraft:stick")

Note

CRAFT, CANCRAFT, MISSING$ and EXPORT act as the player who opened DragonBASIC, with that player's permissions, and work while that player is online. Redstone, Redbus and STOCK work without the player.

Raw Redbus

Command Does
RBREAD(addr, reg) Read a register of any Redbus device.
RBWRITE addr, reg, value Write a register.

Network

For the computer's Network Card. See IP, routing and DHCP.

Command Does
NETIP "10.0.0.5/24" Set the card's address and prefix.
NETIP$ The card's address.
NETMAC$ The card's MAC address.
NETGW "10.0.0.1", NETGW$ Set or read the default gateway.
NETDHCP Get an address from a DHCP server.
NETLINK Whether the card has a link.
NETSEND "ip", text$ or NETSEND(…) Send a text message. The function returns -1 when it was sent.
NETRECV$ The next waiting message, or "" when there is none.
NETFROM$ The sender of the message just received.
NETCOUNT How many messages are waiting.
PING("ip") Round trip in milliseconds, or -1.
NETHOSTS$ The computers the card can reach, as a comma list.
10 NETDHCP
20 PRINT "I AM "; NETIP$
30 M$ = NETRECV$
40 IF M$ <> "" THEN PRINT NETFROM$; ": "; M$
50 SLEEP 10 : GOTO 30