This is a read only copy without any forum functionality of the old Modcraft forum.
If there is anything that you would like to have removed, message me on Discord via Kaev#5208.
Big thanks to Alastor for making this copy!

Menu

Author Topic: [QUESTION] Print chat message in WoW  (Read 1460 times)

Cuana

  • Registred Member
  • BLP Convertor
  • *****
  • Posts: 9
    • View Profile
[QUESTION] Print chat message in WoW
« on: August 08, 2013, 03:11:06 pm »
Hi,


Is it possible using LUA or otherwise to send a chat message to WoW like ".morph $id" where the $id part iterates from 1-30,000 every 5 seconds for example?

It would need to act as if the player is typing it, so the command is ran OK. What I'm hoping is to go through every Display ID in the WoW database and take a screenshot, saving the file as the Display ID.

Thanks!
« Last Edit: January 01, 1970, 01:00:00 am by Admin »

stoneharry

  • Contributors
  • Creator of Worlds
  • *****
  • Posts: 617
    • View Profile
Re: [QUESTION] Print chat message in WoW
« Reply #1 on: August 08, 2013, 04:09:50 pm »
An addon to do this can be made with two files.

The XML part:

Code: [Select]
<Frame name="MinigameFrame" hidden="true" setAllPoints="true">
<Frames>
<Button name="MiniGameResourcesButton" inherits="DestinyButtonTemplate" parentKey="allianceButton">
<Anchors>
<Anchor point="RIGHT" x="-135" y="120"/>
</Anchors>
<Scripts>
<OnLoad>
self.label:SetText("Resources:n0");
self.TimeSinceLastUpdate = 0;
</OnLoad>
<OnUpdate function="update_all_buttons"/>    
</Scripts>
</Button>
</Frames>
</Frame>

Script:

Code: [Select]
local screenshot = false
local morph = 1

function update_all_buttons(self, elapsed)
self.TimeSinceLastUpdate = self.TimeSinceLastUpdate + elapsed;    
if (self.TimeSinceLastUpdate > 2.5) then
if screenshot then
Screenshot()
end
screenshot = not screenshot
SendChatMessage(".morph "..tostring(morph))
self.TimeSinceLastUpdate = 0;
morph = morph + 1
end
end

Something like this would work (taken code snippets from my modified FrameXML).

You would need an external program to rename the sceenshots to the morph ID - you could synchronise this with the WoW script.

Or you could order screenshots by time created then rename them ascending. :)
« Last Edit: January 01, 1970, 01:00:00 am by Admin »

Cuana

  • Registred Member
  • BLP Convertor
  • *****
  • Posts: 9
    • View Profile
Re: [QUESTION] Print chat message in WoW
« Reply #2 on: August 11, 2013, 11:49:48 pm »
Thank you, stoneharry. Very much appreciate your help! If I'm completely honest I don't even know how to code an addon, I'm (as you can probably tell) quite new to modding!

Anyway, I managed to get the addon to run, and then I created an XML button linked to the function. However I will most likely need to learn some of the basics before I can make use of your code snippet, as so far I've had no luck... not that lucks involved, just actual knowledge/skill :P

Nevertheless you've inspired me to continue; as long as I know it's possible then I have good reason to!

Thanks.

/Cuana
« Last Edit: January 01, 1970, 01:00:00 am by Admin »

stoneharry

  • Contributors
  • Creator of Worlds
  • *****
  • Posts: 617
    • View Profile
Re: [QUESTION] Print chat message in WoW
« Reply #3 on: August 12, 2013, 12:29:25 am »
Quote from: "Cuana"
Thank you, stoneharry. Very much appreciate your help! If I'm completely honest I don't even know how to code an addon, I'm (as you can probably tell) quite new to modding!

Anyway, I managed to get the addon to run, and then I created an XML button linked to the function. However I will most likely need to learn some of the basics before I can make use of your code snippet, as so far I've had no luck... not that lucks involved, just actual knowledge/skill :P

Nevertheless you've inspired me to continue; as long as I know it's possible then I have good reason to!

Thanks.

/Cuana

When you create a frame (you don't have to use a button I just did in that code snippet, you could create a empty frame in Lua), you can give it various functionality.

The OnUpdate function in WoW is called constantly. The Lua engine will have a while loop that loops around until shutdown that consistently goes through all the events, fires them, and returns to the start after firing all the events. The OnUpdate function is called every loop. So usually every 0.00001 seconds or something stupid depending on computer speed.

What I am doing in this snippet is hooking OnUpdate and then checking for time passed.

To check time pass, I store the current time of the computer in a variable. Then every loop I check if the current time + X seconds is more than the current system time. When system time is greater than old stored time + X, then we can execute our function.

The function just increments a variable (which will be displayid), and sends the message with that variable.

I use a boolean so that the function does one of two things every call. Either send the message and increment the counter or take a screenshot.

Feel free to ask more questions.

E.g:

Code: [Select]
local frame = CreateFrame("Frame")
frame:SetScript('OnUpdate', 'test')

function test(self, elapsed)
        print("TEST!")
end
« Last Edit: January 01, 1970, 01:00:00 am by Admin »