Toggle Macro for Camera Water Collision

Hi there!

I’ve wanted to use a single macro for toggling the Water Collision setting for the Camera. Sometimes it’s useful, sometimes it’s infuriating. It’s not very convenient to open the settings and change it every time.

I didn’t really find a single-macro solution for the problem, I’ve used two separate macros for quite some time but now I dove into the API and LUA scripting a little and found a simple solution. I wanted to share it, as it might be useful for some of you.

Water Collision toggle:
/run if(GetCVar(“cameraWaterCollision”) == “0”) then SetCVar(“cameraWaterCollision”, 1) else SetCVar(“cameraWaterCollision”, 0) end

You can make a new macro and just copy and paste this command as is (you may need to replace the " characters). I’ve just put the macro on the action bar and there is my fast toggle.

Take care! :heart:


Final iteration with chat message feedback:

/run SetCVar("cameraWaterCollision", 1-GetCVar("cameraWaterCollision")) print("Camera Water Collision: " .. (GetCVar("cameraWaterCollision") == "1" and "Enabled" or "Disabled"))

See also:

2 Likes

Might want to update it to the new functions

/run local k = "cameraWaterCollision" C_CVar.SetCVar(k, 1 - C_CVar.GetCVar(k))

Also, if you wrap your code in code tags quotes won’t get smartquoted.

With current state output:

/run local k,v = "cameraWaterCollision" v = C_CVar.GetCVar(k) C_CVar.SetCVar(k, 1 - v) print("Water Collision " .. (v == "1" and "Disabled" or "Enabled"))

You can trim a lot of the whitespace if you need to free up more chars for different commands etc.

2 Likes

I like the [1 - current value solution], nice way to get rid of the if statement.
Thanks!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.