View Single Post
  #1  
Old 11-09-2013, 07:40 PM
rencro
Hill Giant
 
Join Date: Sep 2008
Location: So. California
Posts: 219
Default Which is a better script format?

I am trying to convert to lua but finding that I always go back to what "works" with perl. I have a custom check in my global_player that checks if a character has a certain list of items when zoning, and removes them if true.

Which of these would be more efficient, assuming that the list will be much larger in size?

Perl
Code:
sub EVENT_ENTERZONE
{
	my @meats1 = qw(1001 1002 1003);
	for ($j = 0; $j < 3; $j++) {
		if(plugin::check_hasitem($client, $meats1[$j])) {
			quest::collectitems($meats1[$j], 1);	
		}
	}
}
Lua
Code:
function event_enter_zone(e)
	local meats1 = {1001, 1002, 1003}; -- temp using cloth items to test with
	for j, name in ipairs(meats1) do
		if(e.self:HasItem(name) == true) then
			eq.collect_items(name, true);
		end			
  	end
end
The reason I ask is that if Lua is much more efficient I will try to focus on lua, but there seems to be more things I can do with perl, but most likely is my experience with lua, or lack of.

Also, are those two methods the best way to iterate through the lists?
Reply With Quote