Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines
(+3)

A nice, simple one this time-

The "enum" Contraption:


Works just like a "compact" slider widget, but instead of a numeric value within a range, it chooses a string from a list of newline-delimited "options". This widget respects the "font", "show", and "locked" properties, and produces a "change[]" event just like a slider.

%%WGT0{"w":[{"name":"enum1","type":"contraption","size":[100,25],"pos":[289,76],"script":"on change val do\n \nend","def":"enum","widgets":{"s":{"interval":[0,2],"format":"one"},"o":{"value":"one\ntwo\nthree"}}}],"d":{"enum":{"name":"enum","size":[100,25],"resizable":1,"margin":[5,5,5,5],"description":"select from among enumerated string values.","script":"on get_options   do o.text end\non get_value     do (\"\\n\" split o.text)[s.value] end\non set_options x do o.text:x s.value:0 view[] end\n\non set_value x do\n v:\"\\n\" split o.text\n d:v dict range count v\n s.interval:0,(count v)-1\n s.value:v[0] unless d[x]\n s.format:v[s.value]\n s.font:card.font\n s.show:card.show\n s.locked:card.locked\nend\n\non change do\n view[]\n card.event[\"change\" get_value[]]\nend\n\non view do\n v:\"\\n\" split o.text\n s.interval:0,(count v)-1\n s.format:v[s.value]\n s.font:card.font\n s.show:card.show\n s.locked:card.locked\nend\n","template":"on change val do\n \nend","attributes":{"name":["options"],"label":["Options"],"type":["code"]},"widgets":{"s":{"type":"slider","size":[100,25],"pos":[0,0],"interval":[0,100],"style":"compact"},"o":{"type":"field","size":[100,20],"pos":[0,-30],"locked":1,"style":"plain"}}}}}

A handy variation on the "enum",

The imageEnum Contraption:

Load this contraption with a selection of images, and then pick between them. Exposes attributes "value" (an Image interface, read-only!), "imageIndex" (an integer, read/write), respects the standard "show" and "locked" attributes, and provides a "change[]" event, just like enums and the slider.

%%WGT0{"w":[{"name":"imageEnum1","type":"contraption","size":[63,34],"pos":[229,154],"def":"imageEnum","widgets":{"s":{"size":[63,34]},"c":{"size":[33,30],"image":"%%IMG2ACEAHgD/AP8A/wDh"},"o":{"size":[44,31],"pos":[92,-20]}}}],"d":{"imageEnum":{"name":"imageEnum","size":[100,100],"resizable":1,"margin":[17,3,18,5],"description":"select from among enumerated image values.","script":"on images do\n extract arg where arg..type=\"image\" from o.value\nend\n\non get_options do o.value end\non set_options x do o.value:x view[] x end\non get_value do images[][s.value] end\non get_valueIndex do s.value end\non set_valueIndex x do s.value:x view[] x end\n\non view do\n im:images[]\n i:im[s.value]\n s.interval:0,0|(count im)-1\n s.locked:card.locked\n s.show  :card.show\n c.show  :card.show\n c.clear[]\n c.paste[i .5*c.size-i.size 1]\nend\n\non change do\n card.event[\"change\" get_value[] s.value]\n view[]\nend","template":"on change img index do\n \nend","attributes":{"name":["options"],"label":["Options"],"type":["rich"]},"widgets":{"s":{"type":"slider","size":[100,100],"pos":[0,0],"interval":[0,0],"format":"","style":"compact"},"c":{"type":"canvas","size":[70,96],"pos":[15,2],"locked":1,"border":0,"image":"%%IMG2AEYAYAD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8AWg==","scale":1},"o":{"type":"field","size":[44,53],"pos":[129,-20],"locked":1,"show":"none"}}}}}
(+1)

is there a way to have a kind of loop, so that when you click on the right arrow when you're at the last text, it goes back to the first text, and vice versa?