Posts: 273
Threads: 47
Joined: Apr 2011
Lol, thats beginner lua. But If you can script something like this
*I didn't do this*
function Elemental_OnCombat(Unit, Event)
Unit:SendChatMessage(13, 0, "Thunder will destroy you!")
Unit:RegisterEvent("Elemental_Arc", 2000, 0)
Unit:RegisterEvent("Elemental_Chain", 20000, 0)
Unit:RegisterEvent("Elemetal_Shield", 10000, 0)
Unit:RegisterEvent("Elemetal_Change", 1000, 1)
Unit:RegisterEvent("SummonWater",1000, 1)
Unit:RegisterEvent("SummonThunder", 1000, 1)
Unit:RegisterEvent("SummonEarth", 1000, 1)
Unit:RegisterEvent("Phase2", 1000, 1)
end
Posts: 239
Threads: 13
Joined: Apr 2011
Reputation:
0
(06-24-2011, 07:38 AM)Eric Wrote: Lol, thats beginner lua. But If you can script something like this
*I didn't do this*
function Elemental_OnCombat(Unit, Event)
Unit:SendChatMessage(13, 0, "Thunder will destroy you!")
Unit:RegisterEvent("Elemental_Arc", 2000, 0)
Unit:RegisterEvent("Elemental_Chain", 20000, 0)
Unit:RegisterEvent("Elemetal_Shield", 10000, 0)
Unit:RegisterEvent("Elemetal_Change", 1000, 1)
Unit:RegisterEvent("SummonWater",1000, 1)
Unit:RegisterEvent("SummonThunder", 1000, 1)
Unit:RegisterEvent("SummonEarth", 1000, 1)
Unit:RegisterEvent("Phase2", 1000, 1)
end
That's pretty basic. Doesn't even do any thing.
Posts: 273
Threads: 47
Joined: Apr 2011
Well, blizzard give me a (hard) lua script.
Posts: 239
Threads: 13
Joined: Apr 2011
Reputation:
0
No real thing such as hard. But advanced would involve stuff like tables and coroutines, not just functions.
[lua]virtual_map = {}
virtual_map[1] = {name = "Place 1", ways = {down = 4, right = 2}}
virtual_map[2] = {name = "Place 2", ways = {down = 5, left = 1, right = 3}}
virtual_map[3] = {name = "Place 3", ways = {down = 6, left = 2}}
virtual_map[4] = {name = "Place 4", ways = {up = 1, down = 7, right = 5}}
virtual_map[5] = {name = "Place 5", ways = {up = 2, down = 8, left = 4, right = 6}}
virtual_map[6] = {name = "Place 6", ways = {up = 3, down = 9, left = 5}}
virtual_map[7] = {name = "Place 7", ways = {up = 4, right = 8}}
virtual_map[8] = {name = "Place 8", ways = {up = 5, left = 7, right = 9}}
virtual_map[9] = {name = "Place 9", ways = {up = 6, left = 8}}
function create_searcher(value, way)
local way = way or {}
return {current = value, way = way}
end
function create_path(start, goal)
local open_set = {create_searcher(start)}
local closed_set = {}
while #open_set > 0 do
local new_finder = {}
for index, value in pairs(open_set) do
if virtual_map[value.current] then
local ways = virtual_map[value.current].ways
for key, content in pairs(ways) do
if not closed_set[content] then
closed_set[content] = true
new_way = {}
table.foreach(value.way, function(index, value) table.insert(new_way, value) end)
table.insert(new_way, key)
if content == goal then
return new_way
end
table.insert(new_finder, create_searcher(content, new_way))
end
end
end
end
open_set = new_finder
end
print("Could not find a valid path from ", virtual_map[start].name, " to ", virtual_map[goal].name, ".")
end[/lua]
Not my code, couldn't be bothered fishing out one of my pieces of work.
Posts: 2,126
Threads: 444
Joined: Jan 2013
Reputation:
0
O.O
I won't be learning to script for a while…
Posts: 1,959
Threads: 140
Joined: Apr 2011
Reputation:
0
Ima horrible scripter. ! but welcome back
Posts: 2,531
Threads: 300
Joined: Apr 2011
Reputation:
0
Except this time, you should stay-stay.
Posts: 3,002
Threads: 200
Joined: Mar 2011
Reputation:
0
You keep leaving, it's no surprise...
Posts: 1,677
Threads: 99
Joined: Apr 2011
Reputation:
0
*reading magazine*
*Lift eyes up from magazine*
You back again? oh wait, you are inactive again
*while changing page* no surprise there
*keeps reading*
Posts: 2,647
Threads: 177
Joined: Feb 2011
Reputation:
0
|