forked from BlueMountainsIO/OnsetLuaScripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtext.lua
More file actions
56 lines (43 loc) · 1.61 KB
/
text.lua
File metadata and controls
56 lines (43 loc) · 1.61 KB
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
--[[
Copyright (C) 2019 Blue Mountains GmbH
This program is free software: you can redistribute it and/or modify it under the terms of the Onset
Open Source License as published by Blue Mountains GmbH.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the Onset Open Source License for more details.
You should have received a copy of the Onset Open Source License along with this program. If not,
see https://bluemountains.io/Onset_OpenSourceSoftware_License.txt
]]--
local textId = 0
function CreateText(text, x, y, fontsize)
textId = textId + 1
ExecuteWebJS(WebGuiId, "CreateText("..textId..", "..x..", "..y..", "..fontsize..", '"..text.."');")
return textId
end
AddRemoteEvent("CreateText", CreateText)
AddFunctionExport("CreateText", CreateText)
function CreateTextDuration(text, x, y, duration)
local id = CreateText(text, x, y, 3)
Delay(duration, function(id)
DestroyText(id)
end, id)
return id
end
AddRemoteEvent("CreateTextDuration", CreateTextDuration)
AddFunctionExport("CreateTextDuration", CreateTextDuration)
function SetText(id, text)
ExecuteWebJS(WebGuiId, "SetText("..id..", '"..text.."');")
end
AddFunctionExport("SetText", SetText)
function DestroyText(id)
ExecuteWebJS(WebGuiId, "DestroyText("..id..");")
end
AddFunctionExport("DestroyText", DestroyText)
function SetTextVisible(id, visible)
if visible then
ExecuteWebJS(WebGuiId, "ShowText("..id..");")
else
ExecuteWebJS(WebGuiId, "HideText("..id..");")
end
end
AddFunctionExport("SetTextVisible", SetTextVisible)