Thread Tools Display Modes
02-08-14, 04:24 PM   #1
vereonix
A Murloc Raider
Join Date: Feb 2014
Posts: 7
Script help: Using /console screenshotFormat tga

Hi, this is the first time I've tried to make an addon, and its been going fine until I tried to get this working:

/console screenshotFormat tga
/run TakeScreenshot()
/console screenshotFormat jpg

Of course this is it as in-game commands, but I can't seem to get it working as a script (and also these 3 lines don't work together in-game either, and I don't know why, as each on its own does).

TakeScreenshot() works in the script, but I can't figure out how to structure the others, as the in-game errors say expected "=" so I've tried:

screenshotFormat jpg()
screenshotFormat = jpg()
screenshotFormat = "jpg"()
SET screenshotFormat = "jpg"()

None of which seem to work :/

Also I should mention the parameters I've set for this to trigger work, as it works fine if I just have it set to take a screenshot, it is just the format changing.
  Reply With Quote
02-08-14, 04:43 PM   #2
Resike
A Pyroguard Emberseer
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,290
Use this:

SetCVar("screenshotFormat", jpg) or SetCVar("screenshotFormat", tga)

Also you don't need to use the "/run" command from addons, just
Lua Code:
  1. TakeScreenshot()

Last edited by Resike : 02-09-14 at 09:59 AM.
  Reply With Quote
02-08-14, 04:49 PM   #3
vereonix
A Murloc Raider
Join Date: Feb 2014
Posts: 7
Hmmm

Originally Posted by Resike View Post
Use this:

SetCVar("screenshotFormat ", jpg) or SetCVar("screenshotFormat ", tga)
Gives error "Couldn't find CVar named 'screenshotFormat '"

and yeah I know about the /run etc, that was just because I was testing them in game together.

Last edited by vereonix : 02-08-14 at 04:54 PM.
  Reply With Quote
02-08-14, 09:31 PM   #4
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Originally Posted by Resike View Post
SetCVar("screenshotFormat ", jpg) or SetCVar("screenshotFormat ", tga)
You need quotes around the second arguments. As written, that code will look for variables named jpg or tga and pass their values to SetCVar -- which, unless you wrote local jpg = "jpg" before running that line, will most likely be nil because no variables by those names exist.

SetCVar("screenshotFormat", "jpg")

Originally Posted by vereonix View Post
Gives error "Couldn't find CVar named 'screenshotFormat '"
There is absolutely a CVar named "screenshotFormat". I'm looking at it in my Config.wtf file right now, and was able to /run SetCVar("screenshotFormat", "jpg") in-game without any issue. Fix the missing quotes as mentioned above, and then make sure you don't have a typo in the CVar name.
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote
02-09-14, 05:45 AM   #5
Resike
A Pyroguard Emberseer
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,290
Originally Posted by Phanx View Post
You need quotes around the second arguments. As written, that code will look for variables named jpg or tga and pass their values to SetCVar -- which, unless you wrote local jpg = "jpg" before running that line, will most likely be nil because no variables by those names exist.

SetCVar("screenshotFormat", "jpg")
Yeah i wasn't sure about that, since the config wtf is a plain text file, and i wasn't ingame either.
  Reply With Quote
02-09-14, 08:54 AM   #6
p3lim
A Pyroguard Emberseer
 
p3lim's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2007
Posts: 1,710
Originally Posted by vereonix View Post
Hmmm



Gives error "Couldn't find CVar named 'screenshotFormat '"

and yeah I know about the /run etc, that was just because I was testing them in game together.
You have a space at the end, remove it.
  Reply With Quote
02-10-14, 07:49 AM   #7
vereonix
A Murloc Raider
Join Date: Feb 2014
Posts: 7
Originally Posted by p3lim View Post
You have a space at the end, remove it.
Ah yes, silly mistake thank you

and

Originally Posted by Phanx View Post

SetCVar("screenshotFormat", "jpg")
Now I get no errors, the ss is taken at the right time, but the format is jpg, just tested it without the change back to jpg code, and it seems to do the format code straight away, and only the ss when the IF is met, even though its all within the same section.

Last edited by vereonix : 02-10-14 at 08:48 AM.
  Reply With Quote
02-10-14, 08:59 AM   #8
Resike
A Pyroguard Emberseer
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,290
Try this one:

Lua Code:
  1. local event = CreateFrame("Frame", nil, UIParent)
  2. event:RegisterEvent("SCREENSHOT_SUCCEEDED")
  3.  
  4. function TakeSSTga()
  5.     SetCVar("screenshotFormat", "tga")
  6.     TakeScreenshot()
  7. end
  8.  
  9. local function ScreenShotOnEvent(self, event, ...)
  10.     if event == "SCREENSHOT_SUCCEEDED" then
  11.         SetCVar("screenshotFormat", "jpg")
  12.     end
  13. end
  14.  
  15. event:SetScript("OnEvent", ScreenShotOnEvent)
  Reply With Quote

WoWInterface » AddOns, Compilations, Macros » AddOn Help/Support » Script help: Using /console screenshotFormat tga


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off