Modding:Lua/Tables/ScriptCanvas

From Starbounder - Starbound Wiki
Jump to: navigation, search

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)

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

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?

Quick Navigation

Quick Navigation