--[[ Raw Poker Live for OBS Paste your Raw Poker stream link once and get every overlay widget as its own source in the current scene: the board and pot, plus one per seat. Drag them wherever you like. Empty seats stay invisible. Install: OBS → Tools → Scripts → + → pick this file. Update after "Reset links" in Raw Poker: paste the new link and click the button again. Sources keep their positions; only the link changes. ]] obs = obslua local PREFIX = "Raw Poker · " local MAX_SEATS = 9 -- Browser source sizes at scale 1, in canvas pixels. local SEAT_W, SEAT_H = 380, 130 local BOARD_W, BOARD_H = 500, 175 local MARGIN = 24 local link = "" local scale = 1.0 function script_description() return "Paste the link from Raw Poker → Stream to OBS, then click Add widgets." end function script_properties() local p = obs.obs_properties_create() obs.obs_properties_add_text(p, "link", "Raw Poker link", obs.OBS_TEXT_DEFAULT) obs.obs_properties_add_button(p, "apply", "Add widgets", on_apply) obs.obs_properties_add_float_slider(p, "scale", "Widget size", 0.5, 2.5, 0.1) return p end function script_defaults(settings) obs.obs_data_set_default_double(settings, "scale", 1.0) end function script_update(settings) link = obs.obs_data_get_string(settings, "link") scale = obs.obs_data_get_double(settings, "scale") end -- "https://rawpoker.app/live/?t=x&w=seat&seat=2" → base, { "t=x", ... } -- minus the widget-specific params, which are added per source. local function split_link(raw) local s = raw:gsub("^%s+", ""):gsub("%s+$", "") local base, query = s:match("^([^?#]+)%??([^#]*)") if not base or not query or not query:find("t=") then return nil end local keep = {} for pair in query:gmatch("[^&]+") do local key = pair:match("^([^=]+)") if key ~= "w" and key ~= "seat" and key ~= "scale" then table.insert(keep, pair) end end return base, keep end local function widget_url(base, params, extra) local all = {} for _, v in ipairs(params) do table.insert(all, v) end for _, v in ipairs(extra) do table.insert(all, v) end if math.abs(scale - 1.0) > 0.001 then table.insert(all, string.format("scale=%.2f", scale)) end return base .. "?" .. table.concat(all, "&") end -- Default spots on the canvas: board bottom centre; seats clockwise from -- bottom-left: up the left side, across the top, down the right side. local function seat_position(i, cw, ch, sw, sh) local top = MARGIN * 2 + sh local bottom = ch - BOARD_H * scale - MARGIN * 2 - sh local rows = { bottom, (top + bottom) / 2, top } local left, right = MARGIN, cw - sw - MARGIN local mid = (cw - sw) / 2 local spots = { { left, rows[1] }, { left, rows[2] }, { left, rows[3] }, { mid - sw - MARGIN, MARGIN }, { mid, MARGIN }, { mid + sw + MARGIN, MARGIN }, { right, rows[3] }, { right, rows[2] }, { right, rows[1] }, } return spots[i][1], spots[i][2] end -- Create the source in `scene` at (x, y), or update its link and size if it -- already exists (keeping wherever the streamer dragged it). local function upsert(scene, name, url, w, h, x, y) local settings = obs.obs_data_create() obs.obs_data_set_string(settings, "url", url) obs.obs_data_set_int(settings, "width", math.floor(w)) obs.obs_data_set_int(settings, "height", math.floor(h)) obs.obs_data_set_bool(settings, "shutdown", false) obs.obs_data_set_bool(settings, "restart_when_active", false) local source = obs.obs_get_source_by_name(name) local created = false if source ~= nil then obs.obs_source_update(source, settings) else source = obs.obs_source_create("browser_source", name, settings, nil) created = true end if obs.obs_scene_find_source(scene, name) == nil then local item = obs.obs_scene_add(scene, source) local pos = obs.vec2() pos.x = x pos.y = y obs.obs_sceneitem_set_pos(item, pos) end obs.obs_source_release(source) obs.obs_data_release(settings) return created end function on_apply(props, prop) local base, params = split_link(link or "") if not base then obs.script_log(obs.LOG_WARNING, "Raw Poker: paste the link from Stream to OBS (it contains ?t=…)") return false end local current = obs.obs_frontend_get_current_scene() if current == nil then obs.script_log(obs.LOG_WARNING, "Raw Poker: no scene selected") return false end local scene = obs.obs_scene_from_source(current) local video = obs.obs_video_info() obs.obs_get_video_info(video) local cw, ch = video.base_width, video.base_height local bw, bh = BOARD_W * scale, BOARD_H * scale local sw, sh = SEAT_W * scale, SEAT_H * scale local added = 0 if upsert(scene, PREFIX .. "Board", widget_url(base, params, { "w=board" }), bw, bh, (cw - bw) / 2, ch - bh - MARGIN) then added = added + 1 end for i = 1, MAX_SEATS do local x, y = seat_position(i, cw, ch, sw, sh) if upsert(scene, PREFIX .. "Seat " .. i, widget_url(base, params, { "w=seat", "seat=" .. i }), sw, sh, x, y) then added = added + 1 end end obs.obs_source_release(current) obs.script_log(obs.LOG_INFO, string.format("Raw Poker: %d widgets added, the rest updated", added)) return false end