Modding:Lua/Tables/ScriptCanvas
From Starbounder - Starbound Wiki
< Modding:Lua | Tables
Note: this page is mostly outdated. These bindings will be moved to the widget table in 1.3 --😺 (talk) 21:31, 1 May 2017 (BST)
Contents
scriptCanvas
The scriptCanvas is an awesome tool you can use to make custom interfaces.
See the original dev blog entry for more information.
Functions
- canvasDrawText(text, {position = x, y}}, fontsize, {r, g, b [, a]})
- canvasDrawImage("/interface/quest.png", {50, 50}, 1)
- canvasDrawImageRect("someimage.png", {sourceX,sourceY, sourceX2,sourceY2}, {destX, destY, destX2,destY2}, {r,g,b[,a]})
- canvasDrawRect({x1, y1, x2, y2}, {color})
- configParameter() -- retrieve values from .config file
- canvasMousePosition()
- canvasDrawLine({x1, y1}, {x2, y2}, {color}, width)
- sourceEntity() -- entity id of the object tied to the console
- canvasDrawPoly({list of coordinate pairs},{color})
- canvasDrawImageCentered("/interface/quest.png", {50, 50}, 1)
- dismiss() -- close window
- playSound
Callbacks
- canvasKeyEvent(key, keyDown)
- canvasClickEvent(position, button, buttonDown)
The Origin Story
<kyren> what about <kyren> what about what about whata bout <kyren> whaaaaaat about <kyren> a client side, lua based <kyren> window <kyren> that has a connection to an object <kyren> and drawing primitive operations ... <kyren> okay doing that <kyren> this weekend
...And the rest was history!
Links
- Available functions and arguments: http://pastebin.com/3Ekd3by4 (fixed drawRect)
- A couple sample mods, including Metadept's "Pong" and Kyren's "Lights Out": http://metadept.com/starbound/testconsoles.zip
- API dump from within Kyren's testconsole: http://pastebin.com/3m2kEieU
- SeveredSkullz IMGUI library project for interface API: http://community.playstarbound.com/index.php?threads/imgui-library-for-interface-api.85161/
- Neurisko's computer project: http://community.playstarbound.com/index.php?threads/my-in-game-scriptcanvas-based-computer-apex64-bananastar-8200.85178/
- Member function documentation: http://doc.playstarbound.com/classStar_1_1CanvasWidget.html#a8b0ccf7e472ab70120fd5fc4575985b6
- Text color codes: http://pastebin.com/Tr0AGj4G
- scriptCanvas Environment Dump: http://pastebin.com/xcyNXQEk
- MrMagical's Persistent Storage: http://pastebin.com/DtWDSWZ4
- SpiderDave's spider fighting game and his circle drawing function.
- PenguinToast's Object-oriented GUI library: http://penguintoast.github.io/PenguinGUI/
- RPC-like functionality (healthire) http://pastebin.com/RjTZWLAc
- PenguinToast's StarModMenu mod for mod user interfaces: http://community.playstarbound.com/index.php?resources/starmodmenu.2368/
Notes
-
You have to click on a canvas window to gain focus before it will recognize input.Fixed - There is an off-by-one error with displaying graphics within the canvas; the right and bottom sides are off by one pixel. Maybe? I dunno, maybe I'm doing it wrong. --Neurisko
- canvasClickEvent now has a third parameter "buttonDown". The Lights Out Game needs a small modification to account for this.
- canvasDrawText has weird behavior where if the string starts with a space, it will remove that space, but not any following spaces. Bug?
Portal - Basics - JSON - Lua - Assets - Guides
Tables - Hooks - Tips & Tricks - Libraries - All Pages