This repository was archived by the owner on Jul 3, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnode.lua
77 lines (68 loc) · 2.13 KB
/
node.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
util.init_hosted()
if CONFIG.auto_resolution then
gl.setup(NATIVE_WIDTH, NATIVE_HEIGHT)
else
gl.setup(CONFIG.width, CONFIG.height)
end
node.alias("walkin/event-slide")
local loaded_event_id
local event_slide = CONFIG.default_slide.get_surface()
local function get_additional_image(filename)
local images = CONFIG.additional_images
for i = 1, #images do
if images[i].file.filename == filename then
print(images[i].file.asset_name)
return true, images[i].file.get_surface()
end
end
return false
end
local function load_event_slide(event_id)
print("ATTEMPTNG TO LOAD EVENT SLIDE FOR: " .. event_id)
local filename = event_id .. ".png"
local got_additional, surface = get_additional_image(filename)
if got_additional then
event_slide = surface
loaded_event_id = event_id
print("USING ADDITIONAL IMAGE FOR: " .. event_id)
else
local file_exists, openfile = pcall(resource.open_file, filename)
if file_exists then
event_slide = resource.load_image(openfile)
loaded_event_id = event_id
print("LOADING EVENT SLIDE FOR: " .. event_id)
else
event_slide = CONFIG.default_slide.get_surface()
loaded_event_id = nil
print("NO EVENT SLIDE FOUND FOR: " .. event_id)
end
end
end
util.data_mapper {
["eventid"] = function(eventid)
load_event_slide(eventid)
end;
}
node.event("input", function(line, client)
if line == "howsitgoing" then
print("HIG recieved")
local status = "Currently showing "
if loaded_event_id then
status = status .. loaded_event_id
else
status = status .. "DEFAULT"
end
node.client_write(client, status)
end
end)
node.event("content_update", function(filename, file)
if loaded_event_id and CONFIG.auto_update then
if filename == loaded_event_id .. ".png" then
load_event_slide(loaded_event_id)
end
end
end)
function node.render()
gl.clear(0, 0, 0, 1)
util.draw_correct(event_slide, 0, 0, WIDTH, HEIGHT)
end