greentumbleweed Posted March 2, 2021 Share Posted March 2, 2021 setting = 1 local sx, sy = guiGetScreenSize() local dx, dy = 1920, 1080 -- GUI Window local guiWindow = guiCreateWindow(100/sx*dx, 160/sy*dy, 200/sx*dx, 160/sy*dy, 'Shader Resolution', false, false) local low = guiCreateRadioButton(20/sx*dx, 30/sy*dy, 150/sx*dx, 20/sy*dy, 'Low', false, guiWindow) local medium = guiCreateRadioButton(20/sx*dx, 60/sy*dy, 150/sx*dx, 20/sy*dy, 'Medium', false, guiWindow) local high = guiCreateRadioButton(20/sx*dx, 90/sy*dy, 150/sx*dx, 20/sy*dy, 'High', false, guiWindow) guiSetVisible(guiWindow, false) -- END bindKey('F1', 'down', function() guiSetVisible(guiWindow, not not guiGetVisible(guiWindow)) end) addEventHandler('onClientRender', root, function() if guiRadioButtonSetSelected(low) then setting = 1 elseif guiRadioButtonSetSelected(medium) then setting = 2 elseif guiRadioButtonSetSelected(high) then setting = 3 end end) function gg() --setting = 1 if setting == 1 then terrain = dxCreateTexture('image/testlow.jpg',"dxt5",true) elseif setting == 2 then terrain = dxCreateTexture('image/testmedium.jpg',"dxt5",true)33 elseif setting == 3 then terrain = dxCreateTexture('image/test.jpg',"dxt5",true) end shader = dxCreateShader("fx/shader.fx") dxSetShaderValue(shader, 'Tex0', terrain) engineApplyShaderToWorldTexture(shader, 'sw_sandlod') end addEvent("pp",true) addEventHandler("pp", getRootElement(), gg) save(setting) local myData = {} function save() local file = fileOpen('save.json') or fileCreate('save.json') local file = fileWrite(toJSON(myData)) fileClose(file) end function load() local file = fileOpen('save.json') if file then local buffer = fileRead(fileGetSize(file)) myData = fromJSON(buffer) fileClose(file) end end load(settings) I want to know how I can use save and load for the settings 1, 2, 3. this is a shader low, medium, high panel I've made. Link to comment
Tekken Posted March 2, 2021 Share Posted March 2, 2021 save(setting) -- there is no argument in that function function save(ARGUMENT) --add the argument here: if ARGUMENT then --check if exists; local file = fileOpen('save.json') or fileCreate('save.json') local file = fileWrite(toJSON(ARGUMENT)); --write to file; -- you should maybe save the file also ?? fileClose(file); end end The same for load() function I don't understand what it is that you want to write to the file? Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now