Quantcast How to make a Printscreen on level Up - WoWInterface
Thread Tools Display Modes
03-14-19, 12:19 PM   #1
Catastophe
A Kobold Labourer
Join Date: Mar 2019
Posts: 1
How to make a Printscreen on level Up

Hi,

I want to keep a diary of my WoW run and thought it would be funny to have a printscreen everytime I level up.

I try to make an (very simple) addon for this but the Screenshot is giving me some headache.

Can anyone tell me what I have done wrong or point me in the right direction?

When I use
Code:
local Congrats_EventFrame = CreateFrame("Frame")
Congrats_EventFrame:RegisterEvent("PLAYER_LEVEL_UP")
Congrats_EventFrame:SetScript("OnEvent",
    function(self, event, ...)
	    local arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9 = ...
		print(Congratulations on reaching level ' ..arg1.. ', ' .. UnitName("Player").. '! You gained ' ..arg2.. ' HP and ' ..arg3.. ' MP!') 
	end)
It works.

So I thought about adding the printscreen function like this:
Code:
local Congrats_EventFrame = CreateFrame("Frame")
Congrats_EventFrame:RegisterEvent("PLAYER_LEVEL_UP")
Congrats_EventFrame:SetScript("OnEvent",
    function(self, event, ...)
	    local arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9 = ...
		print(Congratulations on reaching level ' ..arg1.. ', ' .. UnitName("Player").. '! You gained ' ..arg2.. ' HP and ' ..arg3.. ' MP!') 
	end)

Congrats_EventFrame:SetScript("OnEvent",
    function(self, event, ...)
	    local Screenshot
	end)
But that doesn't work.

So if someone could point me in the right direction that would be great
  Reply With Quote
03-14-19, 12:52 PM   #2
Kanegasi
A Rage Talon Dragon Guard
 
Kanegasi's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2007
Posts: 316
This...

Lua Code:
  1. local Screenshot

...does nothing. It declares a local variable named "Screenshot" within that function, that's it.

You also can only do one SetScript of each kind for each frame object. The second time you declare the "OnEvent" will replace the first one. You're also missing a quote right before Congratulations, I'm surprised you didn't get an error for that.

This will do what you want:

Lua Code:
  1. local Congrats_EventFrame = CreateFrame("Frame")
  2. Congrats_EventFrame:RegisterEvent("PLAYER_LEVEL_UP")
  3. Congrats_EventFrame:SetScript("OnEvent", function(self, event, arg1, arg2, arg3)
  4.     if event=="PLAYER_LEVEL_UP" then
  5.         print("Congratulations on reaching level "..arg1..", "..UnitName("Player").."! You gained "..arg2.." HP and "..arg3.." MP!")
  6.         Screenshot()
  7.     end
  8. end)
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » How to make a Printscreen on level Up

Thread Tools
Display Modes

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