ArcEmu: [lua] How To Script As Modules - ArcEmu

Jump to content

Toggle shoutbox Lastest Announcements

dfighter  : (07 December 2014 - 12:06 PM) Arcemu is in hibernation mode, please read http://arcemu.org/fo...showtopic=26903
dfighter  : (01 January 2013 - 05:56 PM) Arcemu wishes you all a happy new year!
Hasbro  : (12 September 2012 - 10:01 AM) Please excuse our outage from the web! Our web host had a major malfunction!
dfighter  : (01 September 2012 - 04:05 PM) Since the spam bots just don't want to stop, I've enabled admin verification when registering.
dfighter  : (23 January 2012 - 09:56 PM) Please note that from now on you will need to confirm your email on the wiki in order to edit it!
Hasbro  : (31 December 2011 - 12:50 PM) Happy New Years all!
Navid  : (26 December 2011 - 04:09 AM) Merry Christmas !!!!!! Happy holidays all :)
WAmadeus  : (24 December 2011 - 03:54 PM) Merry Christmas to all!
dfighter  : (24 December 2011 - 11:05 AM) The Arcemu team wishes y'all a Merry Christmukkah!
Hasbro  : (05 October 2011 - 12:53 PM) Looking for web designers for upcoming web related project. If you're interested in designing user interfaces contact me
dfighter  : (02 September 2011 - 03:47 PM) So who here wants vehicles in Arcemu? :P http://arcemu.org/fo...showtopic=25440
Hasbro  : (14 August 2011 - 03:25 PM) Join us on irc, grab an irc client and connect to irc.freenode.net join channel #arcemu /server irc.freenode.net:6667 /join #arcemu
jackpoz  : (03 August 2011 - 05:33 AM) to all Lua Engine (old one) users: please check http://arcemu.org/fo...showtopic=25274
Hasbro  : (20 May 2011 - 05:27 PM) Looking for people experienced with CMake configuration and setup! Contact me asap
Hasbro  : (15 May 2011 - 05:03 PM) ArcEmu is recruiting C++ programmers, contact Hasbro if interested.
paroxysm  : (03 May 2011 - 06:26 PM) Updated luabridge gossip example to describe the whole gossip creation process rather than just how to create menu. Gossip tutorial
paroxysm  : (23 April 2011 - 11:35 AM) Lua writers can refer to the Luabridge Tutorials section in the Wiki to learn how to write gossip code correctly.
Hasbro  : (20 April 2011 - 05:22 PM) Thank you for your continuous contribution of bug reports, we are working on them.
Hasbro  : (17 April 2011 - 03:20 AM) Please consider donating to support our bills. Donations can be sent using PayPal to donations@arcemu.org - Thank you for your support.
paroxysm  : (10 April 2011 - 12:43 AM) Refer to the Luabridge Tutorials section in the Wiki to learn the new syntax of luabridge.
Resize Shouts Area

  • (2 Pages)
  • +
  • 1
  • 2
  • You cannot start a new topic
  • You cannot reply to this topic

[lua] How To Script As Modules Halls of Stone

#1 User is offline   paroxysm 

  • Chatty Cathy
  • Group: Retired
  • Posts: 320
  • Joined: 25-June 08
  • Gender:Male
  • Server OS:Windows

Posted 04 March 2010 - 03:10 PM

This release is Halls of Stone instance, atm, only Maiden of Virtue's script is blizzlike(I'll release the rest later)
This is a way of scripting instances in a modular way. Note that the actual boss files aren't loaded by the LuaEngine but by a script. This is to be able to control how the boss script loads and override the script's environment to be a table that we want. By overriding the environment, we can localize all, otherwise globally declared variables, to the environment. This way, all variables declared in that file, WILL NOT GO INTO THE GLOBAL NAMESPACE. If you don't believe me, after loading this files, display the contents of your _G table. The functions declared by the bosses ai script shouldn't display :P

1st lua file http://arcemu.pastebin.com/fCF1YSE4
module("INSTANCE_ULDUAR",package.seeall)

2nd lua file http://arcemu.pastebin.com/dnJucbHs
local mod = require("INSTANCE_ULDUAR")
assert(type(mod) == "table","Missing Ulduar module! Further script loading terminated.")
module(mod._NAME..".HOS",package.seeall)
mod = getfenv(1)
local info = debug.getinfo(1)
local src = string.reverse(info.short_src)
local file_sep;
if(GetPlatform() == "Win32") then
	file_sep = "\\"
else
	file_sep = '/'
end
-- Directory resolving algo
local startpos,endpos = string.find(src,file_sep),string.len(src)
local directory = string.reverse(string.sub(src,startpos,endpos))
print("Resolved directory is :"..directory)
--now we construct our modules based on the resolved directory.
local modules = { directory.."maidenofgrief.script",directory.."krystallus.script"}
for _,v in pairs(modules) do
	local loader_function,errormsg= loadfile(v)
	if(loader_function == nil) then
		print(errormsg)
	else
		setfenv(loader_function,mod)
		local ret,errormsg = pcall(loader_function)
		if(ret == false) then
			print(errormsg)
		else
			print(string.format("Successfully loaded script file: \"%s\"",v))
		end
	end
end

3rd script, contains maiden's ai http://arcemu.pastebin.com/makzS4Vg
local mod = getfenv(1)
assert(type(mod) == "table","Critical Error, Halls of Stone module missing!")
module(mod._NAME..".MAIDEN_OF_GRIEF",package.seeall)
local self = getfenv(1)
function OnCombat(unit,evt,mTarget)
	unit:MonsterYell("You shouldn't have come...now you will die!")
	unit:PlaySoundToSet(13487)
	local sunit = tostring(unit)
	if(self[sunit] == nil) then
		self[sunit] = {}
	end
	local ref = self[sunit]
	ref.storm = math.random(7,10)
	ref.pillar = math.random(9,12)
	ref.shock = math.random(20,30)
	ref.sorrow = math.random(9,12)
	ref.isHeroic = false
	ref.startTime = os.time()
	if(mTarget:IsPlayer() ) then
		ref.isHeroic = mTarget:IsHeroic()
	end
	unit:RegisterEvent(HandleSpells,1000,0)
end

function OnTargetDied(unit)
	local randsay = math.random(4)
	if(randsay == 1) then
		unit:MonsterYell("Why must it be this way?")
		unit:PlaySoundToSet(13488)
	elseif(randsay == 2) then
		unit:MonsterYell("You had it coming!")
		unit:PlaySoundToSet(13489)
	elseif(randsay == 3) then
		unit:MonsterYell("My burden grows heavier.")
		unit:PlaySoundToSet(13490)
	else
		unit:MonsterYell("This is your own fault!")
		unit:PlaySoundToSet(13491)
		
	end
end
function OnWipe(unit)
	unit:RemoveEvents()
end
function OnDied(unit)
	local ref = self[tostring(unit)]
	unit:MonsterYell("I hope you all rot! I never...wanted...this.")
	unit:PlaySoundToSet(13493)
	unit:RemoveEvents()
	local curTime = os.time()
	local totalTime = curTime - ref.startTime
	totalTime = totalTime / 60
	if(totalTime > 0) then
		local raiders = unit:GetInRangePlayers()
		for _,v in pairs(raiders) do
			if(v:IsInGroup() ) then
				v:AddAchievement(1866)
			end
		end
	end
end

function HandleSpells(unit)
	print(unit:GetNextTarget())
	if(unit:GetNextTarget() == nil) then
		unit:WipeThreatList()
	end
	local args = self[tostring(unit)]
	args.storm = args.storm -1
	args.pillar = args.pillar -1
	args.shock = args.shock -1
	if(args.isHeroic ) then
		args.sorrow = args.sorrow -1
	end
	--Handle casting
	if(args.storm <= 0) then
		args.storm = math.random(15,22)
		if(args.isHeroic) then
			unit:FullCastSpell(59772)
		else
			unit:FullCastSpell(50752)
		end
	elseif(args.pillar <= 0) then
		args.pillar = math.random(9,12)
		local plr = unit:GetRandomPlayer(0)
		if(type(plr) ~= "userdata") then
			error("Expected userdata value, got ->"..type(plr),1)
		end
		if(args.isHeroic) then
			unit:FullCastSpellOnTarget(50761,plr)
		else
			unit:FullCastSpellOnTarget(59727,plr)
		end
	elseif(args.shock <= 0) then
		args.shock = math.random(20,30)
		if(args.isHeroic) then
			unit:FullCastSpell(59726)
		else
			unit:FullCastSpell(50760)
		end
		unit:MonsterYell("So much lost time... that you'll never get back!")
		unit:PlaySoundToSet(13492)
	elseif(args.sorrow <= 0) then
		args.sorrow = math.random(9,12)
		local plr = unit:GetRandomPlayer(4)
		if(type(plr) ~= "userdata") then
			error("Expected userdata value, got ->"..type(plr),1)
		end
		unit:FullCastSpellOnTarget(59723,plr)
	end
end
RegisterUnitEvent(27975,1,OnCombat)
RegisterUnitEvent(27975,2,OnWipe)
RegisterUnitEvent(27975,3,OnTargetDied)
RegisterUnitEvent(27975,4,OnDied)

4rd script file Krystallus http://arcemu.pastebin.com/qxjCdbMy
local mod = getfenv(1)
assert(type(mod) == "table","Critical Error, Halls of Stone module missing!")
module(mod._NAME..".KRYSTALLUS",package.seeall)
local self = getfenv(1)
function OnCombat(unit, evt, mTarget)
	local sunit = tostring(unit)
	if(self[sunit] == nil) then
		self[sunit] = {}
	end
	local ref = self[sunit]
	ref.boulder = math.random(8,15)
	ref.stomp = math.random(19,25)
	ref.spike = math.random(20,30)
	ref.slam = math.random(25,35)
	ref.isHeroic = false
	if(mTarget:IsPlayer() ) then
		ref.isHeroic = mTarget:IsHeroic()
	end
	unit:MonsterYell("Crush....")
	unit:PlaySoundToSet(14176)
	unit:RegisterEvent(HandleSpells,1000,0)
end
function OnWipe(unit)
	unit:RemoveEvents()
end
function OnTargetDied(unit)
	unit:MonsterYell("Ha...ha...ha...ha...")
	unit:PlaySoundToSet(14177)
end
function OnDied(unit)
	unit:MonsterYell("Uuuuhhhhhhhhhh......")
	unit:PlaySoundToSet(14179)
end
function Shatter(unit,event_phase)
	if(event_phase == 1) then
		unit:DisableMelee(true)
		unit:FullCastSpell(50827)
		unit:MonsterYell("Break.... you....")
		unit:PlaySoundToSet(14178)
		unit:RegisterLuaEvent(Shatter,7000,1,2)
	elseif(event_phase == 2) then
		local vars = self[tostring(unit)]
		local plrs = unit:GetInRangePlayers()
		for _,v in pairs(plrs) do
			if(v:HasAura(50836) ) then
				v:CastSpell(52656)
			end
		end
		if(vars.isHeroic) then
			unit:FullCastSpell(61546)
		else
			unit:FullCastSpell(50810)
		end
		unit:RegisterLuaEvent(Shatter,1200,1,3)
	elseif(event_phase == 3) then
		unit:DisableMelee(false)
		unit:RegisterEvent(HandleSpells,1000,0)
	end
end
function ScriptEffect(_,spell)
	local boss = spell:GetCaster()
	local vars = self[tostring(boss)]
	assert(boss:IsCreature() and vars ~= nil)
	local plrs = boss:GetInRangePlayers()
	for _,v in pairs(plrs) do
		if(v:HasAura(52656) ) then
			if(vars.isHeroic == true) then
				v:CastSpell(61547)
			else
				v:CastSpell(50811)
			end
			v:RemoveAura(52656)
		end
	end
	Shatter(unit,3)
end
function HandleSpells(unit)
	if(unit:GetNextTarget() == nil) then
		unit:WipeThreatList()
	end
	local ref = self[tostring(unit)]
	ref.boulder = ref.boulder -1
	ref.stomp = ref.stomp -1
	ref.spike = ref.spike -1
	ref.slam = ref.slam -1
	
	if(ref.slam <= 0) then
		ref.slam = math.random(25,35)
		unit:RemoveEvents()
		Shatter(unit,1)
	elseif(ref.spike <= 0) then
		ref.spike = math.random(20,30)
		local tank = unit:GetMainTank()
		if(type(tank) ~= "userdata") then
			error("Expected userdata got ->"..type(tank),1)
		end
		unit:FullCastSpellOnTarget(59750,tank)
	elseif(ref.boulder <= 0) then
		ref.boulder = math.random(8,15)
		local chance = math.random(1,10) -- 10% chance to cast boulder on the tank
		local target = nil
		if(chance == 1) then
			target = unit:GetMainTank()
		else
			target = unit:GetRandomPlayer(7) -- not tank flag
		end
		if(type(target) ~= "userdata") then
			error("Expected userdata got ->"..type(target),1)
		end
		if(ref.isHeroic == true) then
			unit:FullCastSpellOnTarget(59742,target)
		else
			unit:FullCastSpellOnTarget(50843,target)
		end
	elseif(ref.stomp <= 0) then
		ref.stomp = math.random(19,25)
		if(ref.isHeroic ) then
			unit:FullCastSpell(59744)
		else
			unit:FullCastSpell(50868)
		end
	end
end
RegisterUnitEvent(27977,1,OnCombat)
RegisterUnitEvent(27977,2,OnWipe)
RegisterUnitEvent(27977,3,OnTargetDied)
RegisterUnitEvent(27977,4,OnDied)
RegisterDummySpell(50810,ScriptEffect)
RegisterDummySpell(61546,ScriptEffect)

0

#2 User is offline   Shadoxfix 

  • Enthusiast
  • PipPipPip
  • Group: Members
  • Posts: 312
  • Joined: 30-December 09
  • Gender:Male
  • Location:Netherlands

Posted 04 March 2010 - 03:26 PM

This is an example
But what is modular scripting?
0

#3 User is offline   paroxysm 

  • Chatty Cathy
  • Group: Retired
  • Posts: 320
  • Joined: 25-June 08
  • Gender:Male
  • Server OS:Windows

Posted 04 March 2010 - 04:04 PM

Everything that the script file declares(functions,variables,tables etc) will be stored inside the that script's environment table. Normally when you declare a variable/function w/o a local keyword, the environment is usually the global table _G. However, when we override the environment of the function that loads our script(one retrieved by loadfile(..)), all global variables that the script declares get stored inside the new environment table rather than the default _G. This is a very good way to encapsulate functions of ai to properly named namespaces, and since the Register functions can take a function directly rather than a string leading to the function, it complements this encapsulation method. Note this is very similar to doing :
MYGOAI = {}
function MYGOAI.OnActivate(...)
end
RegisterGameObjectEvent(...,4,MYGOAI.OnActivate)

So rather than go through all that table declaration and painfully have to type MYGOAI every time you want to access the table. We take advantage of how Lua loads files as a function and manipulate that functions environment to accomplish the same effect. In the 2nd posted lua file, you notice it creates a table called INSTANCE_ULDUAR.HOS, then for every script we want to load, it goes through and calls loadfile on each and stores the return value( a function). It then calls setfenv() on the function with INSTANCE_ULDUAR.HOS to override the environment, and then calls the function through pcall().

Then inside one of the .script files, it is able to get INSTANCE_ULDUAR.HOS through calling getfenv(1) - passing one means get the environment of the function that is executing the current code. Once the file gets this table, it creates a new table inside that the 1st table reflecting the name of boss being scripted by calling module(...). The neat thing about module is that when it finishes creating the table, it automatically changes the environment of the currently running function to the newly created table. Thus every global variable declared there on, will be stored in the created table. To achieve the same OO programming feeling, we declare the local variable self = getfenv(1). This way, self will point to our newly created table and the functions inside that script can still access the `self` table to store their variables.

Hope this was clear enough for you guys, the concept of environment manipulation is slightly complex and requires general Lua programming knowledge to fully grasp and exploit.
0

#4 User is offline   gambini 

  • Member
  • Pip
  • Group: Members
  • Posts: 69
  • Joined: 24-October 08

Posted 19 March 2010 - 12:06 AM

Okay, so after reading this http://lua-users.org...9/msg00278.html
I think I found a paragraph that cleared a lot up for me:

Quote

package.seeall if you want to have access to all global lua function
such as print() ...
all global variables/functions declared after module() will be inserted
in the module
local variables/functions won't be acessible outside of the module
module("modname") will place all that stuf in global table modname and
will also place it in package.loaded.modname. So require() will use it
directly.


So what the line
module(mod._NAME..".MAIDEN_OF_GRIEF",package.seeall)

does is similar to a function, correct? Because from the article, "all global variables/functions declared after module() will be inserted in the module" I realize they don't do the same thing, I'm just trying to make a connection to something I'm familiar with.

I'm probably going to have to read through all this stuff about 10 more times, since just about every sentence has a paragraph's worth of substance.
0

#5 User is offline   paroxysm 

  • Chatty Cathy
  • Group: Retired
  • Posts: 320
  • Joined: 25-June 08
  • Gender:Male
  • Server OS:Windows

Posted 19 March 2010 - 04:15 PM

When you call module() it creates the table and sets the environment of the current function to that table. From that point on, any global declarations that do not explicitly access _G, such as _G[name] = "Test", will be stored inside that table. All local declarations will still be local to the function that was returned when you loaded the file. I am pointing out that this behaves the same as if you declared a table and all its functions/variables explicitly.
mytbl = {}
function mytbl.OnCombat(....)
end

module() simply creates the table and stores it in some module tables that lua has and simply changes the environment.
If you do not want a global table to be created, then you will have to create it locally. However, you must also write code that you would have otherwise written in a different file, in the same file because that local table will not be visible outside that file.
0

#6 User is offline   HalestormXV 

  • The Ultimatum
  • PipPipPipPipPipPip
  • Group: Members
  • Posts: 1,031
  • Joined: 07-June 08
  • Gender:Male

Posted 21 March 2010 - 01:44 PM

Does using this method eliminate the need for the Table Method of scripting posted HERE or is this more of an addon for that? Or is this an alternative to that method? From reading your posts it seems that this is another method, am i correct? And if this is an alternative method does this still prevent variable collision since everything is stored within its own module?
**Owner of the Serenade of Sorrow Funserver**
My Most Recent Video: The Book of Kidou
Posted Image
0

#7 User is offline   paroxysm 

  • Chatty Cathy
  • Group: Retired
  • Posts: 320
  • Joined: 25-June 08
  • Gender:Male
  • Server OS:Windows

Posted 21 March 2010 - 08:07 PM

1. This method doesn't eliminate, it is the same as table scripting except that it implicitly does table oo rather than explicit where you had to specify that you are declaring a table value.
2. Yes it does prevent variable collision from other scripts unless both script files store their values in the same module table. However, you will still have instance variable collision since there is no way to prevent that until runtime.
0

#8 User is offline   HalestormXV 

  • The Ultimatum
  • PipPipPipPipPipPip
  • Group: Members
  • Posts: 1,031
  • Joined: 07-June 08
  • Gender:Male

Posted 21 March 2010 - 08:30 PM

View Postparoxysm, on 21 March 2010 - 08:07 PM, said:

1. This method doesn't eliminate, it is the same as table scripting except that it implicitly does table oo rather than explicit where you had to specify that you are declaring a table value.
2. Yes it does prevent variable collision from other scripts unless both script files store their values in the same module table. However, you will still have instance variable collision since there is no way to prevent that until runtime.


When you say until run time I imagine you are meaning once the script starts running the variables are assigned properly as with current table method correct?
**Owner of the Serenade of Sorrow Funserver**
My Most Recent Video: The Book of Kidou
Posted Image
0

#9 User is offline   paroxysm 

  • Chatty Cathy
  • Group: Retired
  • Posts: 320
  • Joined: 25-June 08
  • Gender:Male
  • Server OS:Windows

Posted 21 March 2010 - 09:36 PM

No I just mean there will always be instance variable collision unless you store the variables per instance table.
0

#10 User is offline   HalestormXV 

  • The Ultimatum
  • PipPipPipPipPipPip
  • Group: Members
  • Posts: 1,031
  • Joined: 07-June 08
  • Gender:Male

Posted 21 March 2010 - 11:15 PM

Hmm I see, well I will say this looks new and I think I will give it a shot. What method do you use personally to prevent instance collision and store it per instance ID?

I also noticed this line:
local modules = { directory.."maidenofgrief.script",directory.."krystallus.script"}

So does this mean the name of your scripts are maidenofgreif and krystallus or are they maidenofgrief.script and krystallus.script? I see these are in quotes so i would imagine it means that this is the exact string of the name of your scripts or is the .scripts something that is read in the environment. (I am probably overthinking this, bit i tend to do that with new Techniques)
**Owner of the Serenade of Sorrow Funserver**
My Most Recent Video: The Book of Kidou
Posted Image
0

#11 User is offline   paroxysm 

  • Chatty Cathy
  • Group: Retired
  • Posts: 320
  • Joined: 25-June 08
  • Gender:Male
  • Server OS:Windows

Posted 22 March 2010 - 12:13 AM

For bosses, I simply store it's variables inside a tostring(unit) table inside my module.
For events, such as escorts, I use the global_var_management function get/setvars.

Yes, the script files do have a .script extension.
0

#12 User is offline   HalestormXV 

  • The Ultimatum
  • PipPipPipPipPipPip
  • Group: Members
  • Posts: 1,031
  • Joined: 07-June 08
  • Gender:Male

Posted 22 March 2010 - 05:40 PM

View Postparoxysm, on 22 March 2010 - 12:13 AM, said:

For bosses, I simply store it's variables inside a tostring(unit) table inside my module.
For events, such as escorts, I use the global_var_management function get/setvars.

Yes, the script files do have a .script extension.


What made you use a .scripts extension instead of a .lua extension? Unless it is because .lua will load with the server and you do not want that to happen so you use the .script extension instead which makes sense from reading your first post.

And I myself am still learning exactly the method behind the tostring(unit), I understand it but not fully or when it would be best to use and such. Any clarification or even documentation?
**Owner of the Serenade of Sorrow Funserver**
My Most Recent Video: The Book of Kidou
Posted Image
0

#13 User is offline   paroxysm 

  • Chatty Cathy
  • Group: Retired
  • Posts: 320
  • Joined: 25-June 08
  • Gender:Male
  • Server OS:Windows

Posted 22 March 2010 - 07:52 PM

Using tostring on a creature unit, returns a unique string that designates that creature only. So, to create protected variables it only makes sense that you create a new table, and store it preferably in your module, and have its key be tostring(unit), that way when you want to access the table containing these variables, you had to invoke tostring(unit). The concept is pretty basic, I don't think it needs any documentation. To give you a visual, the following layout are the contents of a bosses module when several instances of the same boss running at the same time time.
//Inside the boss module(table), printing out its contents during several encounters at the same time would display something like this.
   key                 value
Unit (44343232)  : table (22443234)
Unit (23224411)  : table (22221334)
Unit (12345678)  : table (12341234)

You can see that for each boss that has it's encounter started, a unique table is created to hold its variables, this way, you can only grab the variables that belong to that boss
0

#14 User is offline   HalestormXV 

  • The Ultimatum
  • PipPipPipPipPipPip
  • Group: Members
  • Posts: 1,031
  • Joined: 07-June 08
  • Gender:Male

Posted 22 March 2010 - 09:10 PM

Putting it into perspective and the comparing what you just replied with and looking at your script up above helps clear things up a bit. So i noticed that you only declare the sunit into it's own table once and then no longer do a nil check. I imagine because this unique table using the tostring[unit] in combination with the "self" automatically creates and assigns the table so you no longer need to check if it is nil correct? But now I noticed that in your onWipe function you do not reset the table to nil. Is there a reason for that or is it done automatically and once the unit reengages a new key is assigned and the old one discarded?
**Owner of the Serenade of Sorrow Funserver**
My Most Recent Video: The Book of Kidou
Posted Image
0

#15 User is offline   paroxysm 

  • Chatty Cathy
  • Group: Retired
  • Posts: 320
  • Joined: 25-June 08
  • Gender:Male
  • Server OS:Windows

Posted 23 March 2010 - 12:45 AM

Actually, your right, I forgot to set the table to nil once the encounter ends, a mistake on my part; but yes, you need to set variable to nil after your encounter ends otherwise that table will persist forever consuming memory that could be recycled.
0

#16 User is offline   HalestormXV 

  • The Ultimatum
  • PipPipPipPipPipPip
  • Group: Members
  • Posts: 1,031
  • Joined: 07-June 08
  • Gender:Male

Posted 24 March 2010 - 06:33 PM

I must be failing to see something here. I took exact copies of what you psoted above just to try this out and it still fails. I am wondering if I missing something? Perhaps the names of the files have to be named specifically (other then Maiden and Krystallus) is there another .dll I am suppose to have? I think I am missing something of importance here because I am getting error out the gazoo. Unless it is because i wasn't running the latest rev of the engine?
**Owner of the Serenade of Sorrow Funserver**
My Most Recent Video: The Book of Kidou
Posted Image
0

#17 User is offline   paroxysm 

  • Chatty Cathy
  • Group: Retired
  • Posts: 320
  • Joined: 25-June 08
  • Gender:Male
  • Server OS:Windows

Posted 24 March 2010 - 08:27 PM

posting the error message might help too xD
0

#18 User is offline   HalestormXV 

  • The Ultimatum
  • PipPipPipPipPipPip
  • Group: Members
  • Posts: 1,031
  • Joined: 07-June 08
  • Gender:Male

Posted 24 March 2010 - 09:39 PM

View Postparoxysm, on 24 March 2010 - 08:27 PM, said:

posting the error message might help too xD


EDIT AGAIN: I think i figured it out. Basically the main module file was not loading first causing everything else to fail to load. So i simply put a 0 in front of the main module file to make sure it loaded first along with Defined variables. But I do have a question now. Since these actual AI files are .script extensions and not standard Lua that gets loaded with the server how does the server read them and translate them into Lua? Was that what the package.seeall thing was since it inherits the entire global environment into that one mod and essentially our particular global environment is all of the Lua commands and functions that we have in the engine? It allows those .script files to use all of Lua's functions, and that is why we do not need to name them .lua files because the module is essentially the controller of those .script files? And also does it matter what we name those files or as long as we load them properly into the module it doesn't matter?

Sorry for all these questions but hell this is interesting stuff.

basically it is saying the module is not found and it is looking for a .dll file. That is pretty much the exact message. What are the names of the actual scripts suppose to be or does that matter and are they supposed to be in the scripts folder?

EDIT:
scripts\WORLD_EVENT.lua: module WORLD_EVENT not found:
no file '.\WORLD_EVENT.lua'
no file <directory name>\WORLD_EVENT\init.lua
no file <directory name>\WORLD_EVENT.lua
no file <directory name>\WORLD_EVENT\init.lua
no file .\WORLD_EVENT.dll
no file <directory name>\WORLD_EVENT.dll
no file <directory name>\Loadall.dll


where i have <directory name> it says my directory name. But when i name it to INSTANCE_ULDUAR it loads.....?? Does this have something to do with linking to the .dll files? Because i know Ulduar is compiled with the CORE, however my custom one isnt and it isn't loading. So does this have an effect on it?

Because i saw what you said in the first post "Note that the actual boss files aren't loaded by the LuaEngine but by a script" -> So I assumed that means the .script files or does it have something to do with the .dll files?

**Owner of the Serenade of Sorrow Funserver**
My Most Recent Video: The Book of Kidou
Posted Image
0

#19 User is offline   paroxysm 

  • Chatty Cathy
  • Group: Retired
  • Posts: 320
  • Joined: 25-June 08
  • Gender:Male
  • Server OS:Windows

Posted 25 March 2010 - 08:18 PM

The .script files are loaded through the instance's module script. In this example, the second script file gets the current directory that the script is in. Then it constructs paths to our .script files by concatenating the directory string by the script file, for ex, "directory.."maiden.script"", and simply calls loadfile() with the new string pointing to our .script path. This is simply the same way the server loads normal .lua files except the reason we do it this way is to manipulate the environment of the loading function.
0

#20 User is offline   HalestormXV 

  • The Ultimatum
  • PipPipPipPipPipPip
  • Group: Members
  • Posts: 1,031
  • Joined: 07-June 08
  • Gender:Male

Posted 25 March 2010 - 08:51 PM

View Postparoxysm, on 25 March 2010 - 08:18 PM, said:

The .script files are loaded through the instance's module script. In this example, the second script file gets the current directory that the script is in. Then it constructs paths to our .script files by concatenating the directory string by the script file, for ex, "directory.."maiden.script"", and simply calls loadfile() with the new string pointing to our .script path. This is simply the same way the server loads normal .lua files except the reason we do it this way is to manipulate the environment of the loading function.


And because it is loaded through the module and calls the loadfile() we can use all of the Lua commands even though it is not a .lua file correct? And does the extension have to be script?
**Owner of the Serenade of Sorrow Funserver**
My Most Recent Video: The Book of Kidou
Posted Image
0

Share this topic:


  • (2 Pages)
  • +
  • 1
  • 2
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users