[SOLVED] How do I change a variable by 0.5 when a key is pressed? - Printable Version +- Xonotic Forums (https://forums.xonotic.org) +-- Forum: Support (https://forums.xonotic.org/forumdisplay.php?fid=3) +--- Forum: Xonotic - Configuration Tips (https://forums.xonotic.org/forumdisplay.php?fid=19) +--- Thread: [SOLVED] How do I change a variable by 0.5 when a key is pressed? (/showthread.php?tid=7609) |
How do I change a variable by 0.5 when a key is pressed? - Kriss7475 - 01-06-2018 I'd like to set cl_zoomfactor to cl_zoomfactor + 0.5 when Mouse5 is pressed and to cl_zoomfactor - 0.5 when Mouse4 is pressed. How can I do this? RE: How do I change a variable by 0.5 when a key is pressed? - Mirio - 01-06-2018 bind YOURZOOMKEY "+zoom; cl_zoomfactor 5" bind MOUSE4 "+zoom; cl_zoomfactor 4.5" bind MOUSE5 "+zoom; cl_zoomfactor 5.5" RE: How do I change a variable by 0.5 when a key is pressed? - Kriss7475 - 01-06-2018 Not what I want. I want Mouse4 and Mouse5 to change the variable no matter what value it is. RE: How do I change a variable by 0.5 when a key is pressed? - Mirio - 01-06-2018 Adjust the binds then, unless you're telling me that you have several binds to change the zoomfactor. 0.5 is literally no change at all anyway. RE: How do I change a variable by 0.5 when a key is pressed? - Kriss7475 - 01-06-2018 What I want is: Zoomfactor is 10 I press m5 Now it's 10.5 I press m4 11 times Now it's 5 This thing in JS (pseudocode): mouse4.on("click", => {cl_zoomfactor = cl_zoomfactor - 0.5}); mouse5.on("click", => {cl_zoomfactor = cl_zoomfactor + 0.5}); RE: How do I change a variable by 0.5 when a key is pressed? - Mirio - 01-06-2018 Not possible without some mad alias script. RE: How do I change a variable by 0.5 when a key is pressed? - Kriss7475 - 01-06-2018 So, I need to do this a lot: Code: if cl_zoomfactor == 5 then set cl_zoomfactor 5.5 RE: How do I change a variable by 0.5 when a key is pressed? - It'sMe - 01-06-2018 Code: alias morezoom "menu_cmd rpn /cl_zoomfactor cl_zoomfactor 0.5 add def" RE: How do I change a variable by 0.5 when a key is pressed? - Kriss7475 - 01-06-2018 Thanks! Sadly has no limit RE: How do I change a variable by 0.5 when a key is pressed? - martin-t - 01-06-2018 If you want something more complex, here is a lot more info about our RPN scripting. You can probably find more examples on the forums or in cfg files. |