unzzi
New Member
Posts: 5
|
Post by unzzi on Nov 16, 2005 20:24:13 GMT -5
I'm really new to lua and I tried helping myself checking lua docs and all but couldn't find out how to get this done. What I'm trying to do is read chat and make script recognize certain things from there.
For example:
<person> starts casting <spell name> on <mob name>.
I figured how to read chat from looking at ChatLine.lua which came with Lunar but I have no idea how to go around to check for certain words or word combinations from there.
Any help would be appreciated.
|
|
petar113507
Full Member
Damn Straight. I Am the king of waffelagia.
Posts: 166
|
Post by petar113507 on Nov 16, 2005 22:46:33 GMT -5
I actually just learned this myself from SDphantom... >.>
I wont go into much coding-buisness because I dont have too much time on my hands right now..
Anymoose, you store the most recent chatline into a variable. You split the string,
string.sub(<string>,<start>,<length>)
So then think that you stored the most recent chatline into a string. Call that string 'Castspell'
so then you could set up an IF statement that would display something. There is a much more precise way, but this is just script reginition. Plus there is a variable in your spellcasting name. So you could orginise it perhaps to how you will cast spells, if you cast it into a macro...
Recentline=<The most recent chatline> SpellString=string.sub(Recentline, *7 , 15) ArgumentString=Casting Water on
*Add The number of characters in persons name
IF Spellstring = ArgumentString
--~ Do something with this here, your Reginition or something.
end
|
|
sdphantom
Full Member
Savior and Destroyer
Posts: 230
|
Post by sdphantom on Nov 17, 2005 1:37:49 GMT -5
For example: <person> starts casting <spell name> on <mob name>. I figured how to read chat from looking at ChatLine.lua which came with Lunar but I have no idea how to go around to check for certain words or word combinations from there. Lua has a pattern recognition function, I'm still looking more into it as for what it returns and how to use it as a pattern check. Try string.find(<chatLine>," starts casting %w+ on ") I'm not really sure yet if the value returned would be a table or a number, if there happens to be a match. I'm suspecting a table since it supposedly returns multiple results. From the Lua 5.0 documentation:
|
|
unzzi
New Member
Posts: 5
|
Post by unzzi on Nov 17, 2005 22:52:23 GMT -5
Thanks all! I played around with string.find a bit before asking here but it caused FFXI to crash over and over again. Now I tried again and no problems at all. To be honest I can't even recognize what I did differently this time
|
|
sdphantom
Full Member
Savior and Destroyer
Posts: 230
|
Post by sdphantom on Nov 18, 2005 22:24:03 GMT -5
Thanks all! I played around with string.find a bit before asking here but it caused FFXI to crash over and over again. Now I tried again and no problems at all. To be honest I can't even recognize what I did differently this time It isn't exactly the statement that is causing the crash, let's just say the Alpha release isn't perfectly stable. .. I do realize that is grossly understated. <.<
|
|
|
Post by TinyTerror on Nov 18, 2005 22:49:53 GMT -5
Things will be better in 0.2.
I hope.
|
|
|
Post by TinyTerror on Nov 18, 2005 23:08:09 GMT -5
The problem is that I am unable to reproduce 90% of the problems that people are having. On top of that, I'm the only person working on the project. I simply dont have the time to test Lunar enough. You guys help, but its not the same as having someone that has access to the source code backing me up.
|
|
sdphantom
Full Member
Savior and Destroyer
Posts: 230
|
Post by sdphantom on Nov 19, 2005 4:55:40 GMT -5
Things will be better in 0.2. I hope. Ya, well, once all the memory leaks are fixed, that should end the random crashes. Heh, keyword "should". You guys help, but its not the same as having someone that has access to the source code backing me up. I would offer to help with the source code, but I know C, not C++.. yet. I know C is a starting point, but looking at C++ gives me a headache. Another is how am I supposed to offer and expect to be given access to such code when I haven't even proven trust? I guess the best I can do at this time is help by giving another programmer's insight into how computer systems work in hope of sparking ideas on how to fix a problem.
|
|
|
Post by TinyTerror on Nov 19, 2005 13:22:51 GMT -5
Memory leaks aren't really whats causing the crashes. The crashes occur when one thread does something to another thread that really pisses it off. Since Lunar is full of threads, this happens fairly often. There are going to be some major internal changes comming in 0.2. Lunar 0.1 was really just me learning about how lua works inside, so errors were made. Im going to try for a higher level of isolation in 0.2, which should help with the stability. If I get my way, 0.2 will feel totally different than 0.1 in many ways. I'm excited to get started working on it.
|
|
sdphantom
Full Member
Savior and Destroyer
Posts: 230
|
Post by sdphantom on Nov 26, 2005 11:32:54 GMT -5
Memory leaks aren't really whats causing the crashes. The crashes occur when one thread does something to another thread that really pisses it off. Ya.. that could do it too. I just haven't had much experience in threaded environments before. -.-; I've simulated multiple threads using a single one before just minimize focus on any one section and use extreme caution to make sure code is not rerun when it's not supposed to.
|
|
|
Post by X-Drop on Dec 5, 2005 21:18:35 GMT -5
I am new to scripting and I just started playing with Lunar over the weekend..... and wow! I love this stuff!
Anyway, I have been writing scripts nonstop for 5 days now. One major script, my Fishbot script, and countless minor scripts just to test out Lunar. So my Fishbot script is awsome! And it just keeps growing in size, because I just keep adding features and altering the presentation.
I got to a point where after defining so many tables, I was concerned my POL crashes where caused by memory leaks. However, I read up on Lua's ability to clean up those memory leaks automatically (to a point i suppose).
But just to be sure I wrote a script to view the memory being used and the garbage threshold (which I believe is the amount of memory ready for garbage collection).
Let this script run and watch Lua automatically set the memory leaks back to 'nil'. Well, this is what I think I'm seeing. What do you guys think?
Test={}
--================================================================================================ MemTest=Graphics.text_CreateObject() --creates MEMORY DISPLAY Graphics.text_SetPosition(500,300,MemTest) Graphics.text_SetColor(255,255,255,255,MemTest) Graphics.text_SetFont("Arial",12,MemTest) Graphics.text_SetVisibility(1,MemTest) --================================================================================================
for i=1,1000000,1 do Test[i]=1 --================================================================================================ a,b=gcinfo() --MEMORY DISPLAY INFO Output=string.format("Memory Test\r\n\nSize of Table = %i\r\nMemory Used = %skb\r\nGarbage Threshold= %skb\r\n",i,a,b) Graphics.text_SetText(Output,MemTest) --================================================================================================ end
|
|