Xonotic Forums

Full Version: How do I change a variable by 0.5 when a key is pressed?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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?
bind YOURZOOMKEY "+zoom; cl_zoomfactor 5"
bind MOUSE4 "+zoom; cl_zoomfactor 4.5"
bind MOUSE5 "+zoom; cl_zoomfactor 5.5"
Not what I want. I want Mouse4 and Mouse5 to change the variable no matter what value it is.
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. Tongue
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});
Not possible without some mad alias script.
So, I need to do this a lot:
Code:
if cl_zoomfactor == 5 then set cl_zoomfactor 5.5
Code:
alias morezoom "menu_cmd rpn /cl_zoomfactor cl_zoomfactor 0.5 add def"
alias lesszoom "menu_cmd rpn /cl_zoomfactor cl_zoomfactor 0.5 sub def"
bind m4 morezoom
bind m5 lesszoom
Thanks!

Sadly has no limit
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.