Basic Lua Knowledge

izanami
Posts: 7
Joined: Thu Feb 16, 2017 9:23 am
Has thanked: 1 time

Re: Basic Lua Knowledge

Post by izanami » Fri Mar 31, 2017 5:27 pm

Ty it is working great^^

agonic
VIP
Posts: 159
Joined: Tue Jan 10, 2017 6:39 pm
Has thanked: 34 times
Been thanked: 112 times

Re: Basic Lua Knowledge

Post by agonic » Fri Mar 31, 2017 5:28 pm

izanami wrote:
Fri Mar 31, 2017 5:27 pm
Ty it is working great^^
Yw :)

izanami
Posts: 7
Joined: Thu Feb 16, 2017 9:23 am
Has thanked: 1 time

Re: Basic Lua Knowledge

Post by izanami » Fri Mar 31, 2017 5:35 pm

Another question XD
There is a mode to extract also wherehouse inventory, pet inventory?

agonic
VIP
Posts: 159
Joined: Tue Jan 10, 2017 6:39 pm
Has thanked: 34 times
Been thanked: 112 times

Re: Basic Lua Knowledge

Post by agonic » Fri Mar 31, 2017 5:41 pm

izanami wrote:
Fri Mar 31, 2017 5:35 pm
Another question XD
There is a mode to extract also wherehouse inventory, pet inventory?
Hard question for me... I guess if dll has their offsets, it may show them.. but not current yet

izanami
Posts: 7
Joined: Thu Feb 16, 2017 9:23 am
Has thanked: 1 time

Re: Basic Lua Knowledge

Post by izanami » Fri Mar 31, 2017 6:06 pm

It's ok, thanks for your help, i'm not too expert with lua language, i know a bit better c# :D :D XD

User avatar
Diavolakos
Posts: 114
Joined: Thu Apr 20, 2017 5:05 am
Has thanked: 31 times
Been thanked: 13 times

Re: Basic Lua Knowledge

Post by Diavolakos » Sun Jun 11, 2017 6:58 am

locatelli wrote:
Tue Mar 21, 2017 10:13 pm
I'm looking for a really deep lua guide, where I can learn all the returns calls and other advanced commands like string search and so on, if anyone can find a decent one - didn't find one yet sadly - feel free to write me
I have programmed in many scripts in other games, like even in L2Walker and the powerful ZRanger (used in L@ again).

I kinda find AS scripting very hard to understand or follow, it is like it has less structure than other scripts. I also specialized in C and C++ in the university, so I am pretty familiar with it and my final project was simulation (which is one of the tough things to do in programming, like AI)

I can understand most existing scripts (understand their functionality and what do I need to change to make a different thing) and I have done a few myself, but I just find it very abstract, like the example below:

Code: Select all

function OnLoad()
    for Item in ListIterator( InventoryList:GetList() ) do
        Write(""..Item:GetName().."  "..Item:GetAmount())
    end
end
It looks familiar, like a C++ (simple basic example below)

Code: Select all

for (i=0;i<10;i++)
{
    if(inventory[i]=="Potion")
        { use this or that
        }
}
I hope you understand, this has structure and has pointers and lists, and you set your variables as single ones, or table of contents.

I do not find these here, and there are other things like the double dots "..item:getname()" and what does "Item" stand for, is it a variable set by AS itself, do we have a pointer (like my example, "i"). I kinda find this pretty hard to follow, even for a IT graduate like me.
Last edited by Diavolakos on Thu Jun 15, 2017 11:56 am, edited 1 time in total.
I play on NA Server Siel

User avatar
nucular
Site Admin
Posts: 260
Joined: Sat Jan 07, 2017 9:08 pm
Has thanked: 27 times
Been thanked: 388 times

Re: Basic Lua Knowledge

Post by nucular » Sun Jun 11, 2017 2:48 pm

Look inside the main folder of AionScript for a file named AionScript.pdf

Item is instanced object of the Model Inventory.
For possible functions of the model look inside AionScript.pdf
If you are a graduated programmer read the manual dude really....
It tells you exactly InventoryList:GetList() returns an List of inventory objects.

You will find all things in there.

For your other question look inside Aionscript.lua what the function GetList actually does.

User avatar
Diavolakos
Posts: 114
Joined: Thu Apr 20, 2017 5:05 am
Has thanked: 31 times
Been thanked: 13 times

Re: Basic Lua Knowledge

Post by Diavolakos » Tue Jun 13, 2017 2:03 pm

Yes I read the pdf but it simply has the names of functions and the names of preset variables. It doesn't say exactly how they are used.

I am a computer programmer but I do not know all languages, I specialized in C/C++

But you said that
InventoryList:GetList() returns an List of inventory objects
returns into where, and how do I find the object I need, don't I need this to be some sort of an array that has all 90 slots so I can look into a specific inventory[ i ] slot where "i" is a pointer I use to change the cell?
Last edited by Diavolakos on Thu Jun 15, 2017 11:56 am, edited 1 time in total.
I play on NA Server Siel

User avatar
nucular
Site Admin
Posts: 260
Joined: Sat Jan 07, 2017 9:08 pm
Has thanked: 27 times
Been thanked: 388 times

Re: Basic Lua Knowledge

Post by nucular » Tue Jun 13, 2017 3:41 pm

Nope, the C equivalent are linked lists, so you can't access it directly by defining the an key.
https://en.wikipedia.org/wiki/Linked_list
https://en.wikipedia.org/wiki/Doubly_linked_list

Code: Select all

for Item in ListIterator( InventoryList:GetList() ) do ....
would also work

Code: Select all

InvList = InventoryList:GetList();
for Item in ListIterator( InvList ) do ....
or

Code: Select all

InvList = InventoryList:GetList();
MyInventory = ListIterator( InvList );
for SingleItem in MyInventory do ....
returns into where, and how do I find the object I need, don't I need this to be some sort of an array that has all 90 slots so I can look into a specific inventory slot where "i" is a pointer I use to change the cell?
Just see how linked lists work.
You always have to iterate over all entries and you do exactly the same here.

User avatar
Diavolakos
Posts: 114
Joined: Thu Apr 20, 2017 5:05 am
Has thanked: 31 times
Been thanked: 13 times

Re: Basic Lua Knowledge

Post by Diavolakos » Thu Jun 15, 2017 11:58 am

nucular wrote:
Tue Jun 13, 2017 3:41 pm
Nope, the C equivalent are linked lists, so you can't access it directly by defining the an key.
https://en.wikipedia.org/wiki/Linked_list
https://en.wikipedia.org/wiki/Doubly_linked_list

Code: Select all

for Item in ListIterator( InventoryList:GetList() ) do ....
would also work

Code: Select all

InvList = InventoryList:GetList();
for Item in ListIterator( InvList ) do ....
or

Code: Select all

InvList = InventoryList:GetList();
MyInventory = ListIterator( InvList );
for SingleItem in MyInventory do ....
returns into where, and how do I find the object I need, don't I need this to be some sort of an array that has all 90 slots so I can look into a specific inventory slot where "i" is a pointer I use to change the cell?
Just see how linked lists work.
You always have to iterate over all entries and you do exactly the same here.
Oh yes I am well aware of linked lists, floating in non serial way so you have to go through each cell from start so as to find the next one. Thanks for the input.

I know I will never be good in lua since I kinda find it a little less structured than C/C++ that I am so used. But this clears things up.
I play on NA Server Siel

Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests