From 487398ab6f3047af4720ea0153fec69bb6f36bd2 Mon Sep 17 00:00:00 2001 From: s-ol Date: Sun, 23 Mar 2025 22:39:32 +0100 Subject: glsl-view: resolve relative paths for video --- alv-lib/glsl-view.moon | 10 +++++++--- alv/copilot/base.moon | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/alv-lib/glsl-view.moon b/alv-lib/glsl-view.moon index 4c27be0..c2d57ee 100644 --- a/alv-lib/glsl-view.moon +++ b/alv-lib/glsl-view.moon @@ -58,11 +58,13 @@ video = Constant.meta setup: (inputs, scope) => { socket, name, filename, type } = pattern\match inputs + @prefix = COPILOT.active_module.file\match'(.*/)[^/]*$' + super socket: Input.hot socket or scope\get '*oscout*' - name: Input.hot name - filename: Input.hot filename - type: Input.hot type or Constant.str "2D" + name: Input.cold name + filename: Input.cold filename + type: Input.cold type or Constant.str "2D" samplertype = assert GLSL_SAMPLER_TYPES[@inputs.type!] @setup_out '=', (Struct type: T.str, val: T.str), type: samplertype, val: @inputs.name! @@ -71,6 +73,8 @@ video = Constant.meta { :socket, :name, :type, :filename } = @unwrap_all! with @inputs.socket! + if @prefix and not (filename\match '^/') or (filename\match '^%w:\\') + filename = @prefix .. filename \send Message.pack { address: "/texture/#{name}/video", types: "ss", "TEXTURE_#{type}", filename } -- destroy: => diff --git a/alv/copilot/base.moon b/alv/copilot/base.moon index b7823e6..cb82689 100644 --- a/alv/copilot/base.moon +++ b/alv/copilot/base.moon @@ -84,7 +84,7 @@ class Copilot mod.root\make_ref! else last = @active_module - prefix = if b = last.file\match'(.*)/[^/]*$' then b .. '/' else '' + prefix = if b = last.file\match'(.*/)[^/]*$' then b else '' mod = @last_modules[name] or FSModule "#{prefix}#{name}.alv" L\trace "entering module #{mod}" @modules[name] = mod -- cgit v1.2.3