PDA

View Full Version : Which is a better script format?


rencro
11-09-2013, 07:40 PM
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

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

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?

Davood
11-09-2013, 09:05 PM
i haven't touched LUA yet - but from what i understand, LUA lets you do some server / game mechanics changes (memory and multithreading) that perl can't "Easily" touch, whereas you have to giveup the RDMS (relational database management system) in order to use LUA.

personally i am a db guy,. i like to have my database nicely structured, even if it is slower and "clunky" compared to LUA (as far as others have told me).

as a language, perl is "slow" compared to LUA so if you plan on having massive scripts (like the 300kb+ inneficient perl-hemoths on my server) and dont really mind re-learning data ideology and reverting back to "flat files" then LUA would be a better option.

Davood
11-09-2013, 09:08 PM
addendum:

if someone hand holds me and shows me how to use mysql with lua - i would consider switching teams.

also

you CAN do memory hacking and multi threading in perl

i have done it for web spidering (multi threading) it just isn't as "good" as LUA (from what i'm told, i have 0 experience)

Uleat
11-10-2013, 12:08 PM
Last I heard, perl will not be getting any makeovers, unless it's to fix an issue.

New features will only be added to lua.


If I am wrong, or if things have changed, please speak up :)

rencro
11-10-2013, 01:27 PM
Thanks both of you for the feedback...

cavedude
11-10-2013, 05:30 PM
Yes, Perl is officially deprecated in EQEmu. It will not be broken, but developers are not required to port new features to it.

Lua I feel for our needs is vastly superior for scripting. It's lighter and quicker, and KLS has already ported cool features to it that Perl does not have - like the ability to send custom packets.

Now, I am not dissing Perl. I use it for virtually all of my external scripting, minus the occasional bash script. It's my goto language for that. But let's be honest here, Perl is a tank.

For MySQL work, my opinion is that you are better off keeping that in the C++ server code. Its quicker, and far more secure. If you are familiar enough with the Perl syntax, picking up C++ at least in this case is a breeze.

KLS
11-10-2013, 08:18 PM
If you use luajit there are some nice easy to use FFI bindings for MySQL. There are some for regular lua too but they're harder to use since you have to compile them.

Davood
11-11-2013, 01:44 AM
I see. Thank you for the response.

Yeah, i'm quite comfortable with c++ so if i go with LUA i will redo my db calls and then access my data via the script.

OK final thread hijacking question!

I think this was answered, but to confirm:

Perl and LUA can work together ? or are they mututally exclusive.. i dont remember choosing something in cmake that indicated which was to be used?

this is still going to be a huge deterrent for me as i dont know how effectively i will be able to port my morbidly obese perl scripts into LUA without alot of complaining.

id rather just convert the mega beasts (still some functionality i want to add to them kekeke) and leave the rest in perl.

cavedude
11-11-2013, 01:55 AM
An entity (NPC, Item, Spell) can only have one script on it at a time. If two exist, it will use the Lua and ignore Perl. However, the server can use Perl and Lua at the same time - just make sure you say yes to both in cmake. The current PEQ quests for example are still mostly Perl with a growing number of Lua scripts being written. They all work fine.

demonstar55
11-11-2013, 02:01 AM
LUA and Perl can be enabled at the same time. I'm not sure if there will be problems if there is a Perl and lua script for the same NPC though.

LUA also has the benefit of being designed with our use case in mind (well embedding into C) so its much easier to maintain. I know there arent really any current Dev that really knows the Perl embedding very well, I know KLS has fixed things, but with great mental agony :P

KLS
11-11-2013, 02:04 AM
Lua and Perl even can interact via timers and signals.