|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Quests::Q&A This is the quest support section |
|
|
|
11-09-2013, 07:40 PM
|
Hill Giant
|
|
Join Date: Sep 2008
Location: So. California
Posts: 219
|
|
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?
|
|
|
|
11-09-2013, 09:05 PM
|
Discordant
|
|
Join Date: Jan 2005
Posts: 488
|
|
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.
__________________
----------
Demon Overlord of Alakamin
skype @ davoodinator
|
11-09-2013, 09:08 PM
|
Discordant
|
|
Join Date: Jan 2005
Posts: 488
|
|
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)
__________________
----------
Demon Overlord of Alakamin
skype @ davoodinator
Last edited by Davood; 11-09-2013 at 09:09 PM..
Reason: more details added
|
11-10-2013, 12:08 PM
|
|
Developer
|
|
Join Date: Apr 2012
Location: North Carolina
Posts: 2,815
|
|
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
__________________
Uleat of Bertoxxulous
Compilin' Dirty
|
11-10-2013, 01:27 PM
|
Hill Giant
|
|
Join Date: Sep 2008
Location: So. California
Posts: 219
|
|
Thanks both of you for the feedback...
|
11-10-2013, 05:30 PM
|
|
The PEQ Dude
|
|
Join Date: Apr 2003
Location: -
Posts: 1,988
|
|
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.
|
11-10-2013, 08:18 PM
|
Administrator
|
|
Join Date: Sep 2006
Posts: 1,348
|
|
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.
|
11-11-2013, 01:44 AM
|
Discordant
|
|
Join Date: Jan 2005
Posts: 488
|
|
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.
__________________
----------
Demon Overlord of Alakamin
skype @ davoodinator
|
11-11-2013, 01:55 AM
|
|
The PEQ Dude
|
|
Join Date: Apr 2003
Location: -
Posts: 1,988
|
|
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.
|
11-11-2013, 02:01 AM
|
Demi-God
|
|
Join Date: Apr 2008
Location: MA
Posts: 1,164
|
|
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
|
11-11-2013, 02:04 AM
|
Administrator
|
|
Join Date: Sep 2006
Posts: 1,348
|
|
Lua and Perl even can interact via timers and signals.
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -4. The time now is 11:06 AM.
|
|
|
|
|
|
|
|
|
|
|
|
|