--[[ Constants * (all lua builtins that don't allow io/executing code) color (interface) gui (interface) multi (interface bound to a processor) no thread module callback true/false correct/wrong ]] local label local imageHolder local function index(window, q, callback) if not q.sound or q.sound == "" then error("Missing 'sound' field for question!") callback() return end local frame = window:newFrame(0,0,0,0,0,.2,1,.8) frame.visibility = 0 label = window:newTextLabel(" " ..q.title.. " ",0,0,0,0,0,0,1,.2) label.align = ALIGN_CENTER label.textColor = color.question_font label.color = color.question_bg label:scaleFont(.4) label:centerFont() label.drawBorder = false imageHolder = window:newImageButton("assets/images/speaker.png",0,0,0,0,0,0,.3,.3) imageHolder.scale = "h" imageHolder:centerX(true) imageHolder:centerY(true) local sound = newSource(q.sound,"stream") imageHolder:OnReleased(function() if tonumber(q.start) then sound:seek(q.start) end sound:play() timer(tonumber(q.playFor) or 10, function() sound:stop() sound:seek(0) end) end) useDefaultHandler(callback) -- Return the expected types return { {sound=AUDIO, description="Sound that will be played"} } end local function update(dt) -- time in seconds that has passed since end return { index = index, update = update }