My problem is the following: I have got a game launcher with an edit button using InputText.dll, which sends a function to a LUA script, which changes lines from a variables.txt file.
The problem appears when trying to type in german umlauts (ä, ö, ü) and sending those to my script. About rainmeter gives me two errors:
Code: Select all
Script: File not valid
Script: EditGames.lua:1: unexpected symbol near 'þ'
I call the function like this in rainmeter:
Code: Select all
[MeasureInputText]
DynamicVariables=1
Measure=Plugin
Plugin=InputText
SolidColor=0, 0, 0
FontColor=f2f2f2
FontFace=Futura-CondensedLight
FontSize=18
X=5
Y=400
H=30
W=240
DefaultValue=""
Command1=[!SetVariable GameNumber "$UserInput$"][!Update] DefaultValue="Enter game number"
Command2=[!SetVariable NewName "$UserInput$"][!Update] DefaultValue="Enter new name"
Command3=[!SetVariable LeftAction "$UserInput$"][!Update] DefaultValue="Enter new game path"
Command4=[!SetVariable RightAction "$UserInput$"][!Update] DefaultValue="Enter new rightclick action"
[EditGames]
Measure=Script
ScriptFile=#@#EditGames.lua
;Setting the Variables via inputText.dll
[Edit]
Meter=Image
ImageTint=888888
ImageName=#@#Skyrim_Edit_Button.png
x=110
Y=885
H=25
Y=25
AntiAlias=1
MouseOverAction=[!SetOption Edit ImageTint f2f2f2][!Update]
MouseLeaveAction=[!SetOption Edit ImageTint 888888][!Update]
LeftMouseUpAction=[!HideMeterGroup AppButton][!ShowMeterGroup Edit][!CommandMeasure MeasureInputText "ExecuteBatch 1-4"][!Update]
;calling the function
[ReplaceButton]
Meter=Image
ImageTint=888888
ImageName=#@#ReplaceButton.png
x=30R
Y=r
H=20
Y=20
AntiAlias=1
MouseOverAction=[!SetOption ReplaceButton ImageTint f2f2f2][!Update]
MouseLeaveAction=[!SetOption ReplaceButton ImageTint 888888][!Update]
LeftMouseUpAction=[!CommandMeasure "EditGames" "replaceLine(#GameNumber#, #NewName#, #LeftAction#, #RightAction#)"][!Update][!Redraw][!Refresh]
Group = Edit
Hidden=1
Code: Select all
fileName = "C:\Censored\Filepath\variables.txt"
local file = io.open(fileName, "r")
local sContents = file:read("*all")
tContents={}
for line in io.lines(fileName) do table.insert (tContents, line) end
function save(t, txt)
local f = io.open(txt, "w")
io.output(f)
for i = 1, #t do io.write(t[i].."\n") end
end
function open(t, txt)
local file = io.open(txt, "r")
local sContents = file:read("*all")
t={}
for line in io.lines(txt) do table.insert (t, line) end
return(t)
end
function replaceLine(gameNumber, NewName, NewLeft, NewRight)
lineNumber=gameNumber*4-2
open(tContents, fileName)
if not gameNumber then print("No number given") return end
if not NewName then print("No name given") return end
if not NewLeft then print("No nath given")return end
if not NewRight then NewRight="" end
for i=1, 3, 1 do
table.remove(tContents, lineNumber)
end
table.insert(tContents, lineNumber, "Game"..gameNumber.."Name=\""..NewName.."\"")
table.insert(tContents, lineNumber+1, "Game"..gameNumber.."Path=\""..NewLeft.."\"")
table.insert(tContents, lineNumber+2, "Game"..gameNumber.."PathRight=\""..NewRight.."\"")
save(tContents, FileName)
end
Thanks in advance.
TheBlubb