@@ -11,9 +11,10 @@ function createDialog(title, text, ...)
1111 dialogs [id ] = {
1212 title = title ,
1313 text = text ,
14- columns = {},
14+ columns = { { inputs = {}, buttons = {} } },
1515 buttons = {... },
16- variables = {}
16+ variables = {},
17+ autoclose = " true"
1718 }
1819 return id
1920end
@@ -122,6 +123,16 @@ function setVariable(dialog, name, value)
122123 end
123124 dialogs [dialog ].variables [name ] = value
124125end
126+ function setDialogAutoclose (dialog , autoclose )
127+ if dialogs [dialog ] == nil then
128+ return
129+ end
130+ if autoclose then
131+ dialogs [dialog ].autoclose = " true"
132+ else
133+ dialogs [dialog ].autoclose = " false"
134+ end
135+ end
125136function replaceVariables (text , variables )
126137 for k ,v in pairs (variables ) do
127138 text = text :gsub (" {" .. k .. " }" , v )
@@ -148,9 +159,9 @@ function showDialog(dialog)
148159 end
149160 lastOpened = dialog
150161 local d = dialogs [dialog ]
151- local json = " "
162+ local json = " autoclose: " .. d . autoclose .. " , "
152163 if d .title ~= nil then
153- json = " title:\" " .. replaceVariables (d .title , d .variables ).. " \" ,"
164+ json = json .. " title:\" " .. replaceVariables (d .title , d .variables ).. " \" ,"
154165 end
155166 if d .text ~= nil then
156167 json = json .. " text:\" " .. replaceVariables (d .text , d .variables ).. " \" ,"
@@ -221,7 +232,6 @@ function showDialog(dialog)
221232 json = json .. " \" " .. replaceVariables (d .buttons [i ], d .variables ).. " \" "
222233 end
223234 end
224- print (" SetDialog(" .. dialog .. " ,{" .. json .. " ]});" )
225235 ExecuteWebJS (web , " SetDialog(" .. dialog .. " ,{" .. json .. " ]});" )
226236 SetIgnoreLookInput (true )
227237 SetIgnoreMoveInput (true )
@@ -245,4 +255,5 @@ AddFunctionExport("show", showDialog)
245255AddFunctionExport (" close" , closeDialog )
246256AddFunctionExport (" destroy" , destroyDialog )
247257AddFunctionExport (" setSelectOptions" , setDialogSelectOptions )
248- AddFunctionExport (" setSelectLabeledOptions" , setDialogSelectOptionsWithLabels )
258+ AddFunctionExport (" setSelectLabeledOptions" , setDialogSelectOptionsWithLabels )
259+ AddFunctionExport (" setAutoClose" , setDialogAutoclose )
0 commit comments