Help with learning ashita functions

Discuss the development of Lua addons for Ashita v3 here.
Post Reply
pantafernando
Posts: 17
Joined: Mon Nov 06, 2017 6:12 am

Help with learning ashita functions

Post by pantafernando » Sat Dec 15, 2018 4:22 am

Hi

Slowly ive been trying to learn how to create my own addon.

Currently what im kinda lost is to understand the ashita fucntion. Instead of asking one by one what every function needs/do i would like to ask if there is some place i can "see" it's structure (like what args, what it actually do, etc).

Another thing im having problem is to work with packets. While i can check most information in libs i dont know the requirement to build a packet. If i could get some trivial example how to sent a packet to do any action i think it would be great.

Sorry for so many questions and thanks in advance
Yunamahoutsukai
Posts: 33
Joined: Tue Oct 24, 2017 11:28 am

Re: Help with learning ashita functions

Post by Yunamahoutsukai » Sat Dec 15, 2018 4:44 am

Try the documentation here: https://docs.ashitaxi.com/dev/addons/
The page on the ADK is currently missing, use the ADK headers under Ashita/plugins to see what functionality it provides.

Packet building is an advanced topic you really should leave to people that understand them. But if you insist on using them the best place to see info about them is the windower addon packets library.
User avatar
atom0s
Site Admin
Posts: 416
Joined: Sat May 14, 2016 5:13 pm

Re: Help with learning ashita functions

Post by atom0s » Sat Dec 15, 2018 9:33 pm

You can find the docs here: https://docs.ashitaxi.com/

As Yuna mentioned there are some things missing still. I haven't had time to finish things up yet. However, you can check the old wiki's for the other info that is missing. v2 and v3's wikis are still online here:

v3: https://wiki.ashitaxi.com/
v2: http://wiki.ashitaxi.com/oldwiki/

You can also join our Discord to chat with us directly. We're friendly, we don't bite :P
https://discord.gg/Ashita
Lead Ashita Developer

Want to donate to say thanks?
https://www.paypal.me/atom0s
pantafernando
Posts: 17
Joined: Mon Nov 06, 2017 6:12 am

Re: Help with learning ashita functions

Post by pantafernando » Sun Dec 23, 2018 8:45 am

Hi.

Thanks for the responses. During this week i learned a lot about developing an addon and i got close to my goal.

But few questions appeared so i would appreciate any help with them:

1. I plan on adding a currency check on my addon, thats something that will prevent buying something if i cant afford. Mainly accolades. So i would like to ask how do i access the info about my current accolades?

2. I would like to implement some "waits" in my addon. How can i make it so it will wait some amount of time before processing the next command?

3. I made a short addon that interact with npc using packets. But i noticed this packet is mainly used with npc. So i would like to ask how do i implement a check that will prevent sending the interact packet if i by mistake target a playable character?

4. Is there any program to see and track packets (incoming and outcoming) in ashita?

Thanks in advance
User avatar
atom0s
Site Admin
Posts: 416
Joined: Sat May 14, 2016 5:13 pm

Re: Help with learning ashita functions

Post by atom0s » Sun Dec 23, 2018 11:21 pm

1. Information like currency other than Gil is something you would have to track with packets. That information is not stored in the client all the time and only updates/populates when the client requests it at certain points such as opening the currency menus.

2. Addons are ran in Lua, which is not thread safe. So you would need to utilize either the coroutines of Lua, the timers lib included with Ashita, or creating a state-machine like setup that walks through a set of states to complete a task.

3. You can tell an entity type by the 'EntityType' and 'SpawnFlags' values of the entity structure return for that entity.

4. Yes, there is a packet monitoring plugin called Packeteer which you can find on our Discord here:
https://discord.gg/Ashita
Lead Ashita Developer

Want to donate to say thanks?
https://www.paypal.me/atom0s
pantafernando
Posts: 17
Joined: Mon Nov 06, 2017 6:12 am

Re: Help with learning ashita functions

Post by pantafernando » Tue Dec 25, 2018 11:47 pm

Hi.

Thanks for all the input I ticked off most of those items, maybe just need to check better the timer.lib functions. I used a function with coroutine. While it indeed delay the program it freezes the game what i didnt feel confortable with. Do the timers.lib functions also freezes the game while running the wait loop to end?

About my addon that will buy my items from NPC using packets, i managed to implement all checks i considered relevant and its all almost done but something is missing with the function to buy the item itself (the server isnt processing my purchase order). What ive been doing is:

1. Targeting the NPC, checking all variables then opening the menu with a packet 0x01A. The menu opens.

2. Then i send a sequence of 5 packets (4 0x05B and 1 0x016 in the end):

Code: Select all

if busy then
local packet = struct.pack('bbbbIhhhbbhh', 0x5B, 0x0A, 0x00, 0x00, 0x85, 0x01, 0x10, 0x01, 0x0A, 0x00, 0x00, 0x00, 0x85, 0x01, 0x01, 0x00, 0x00, 0x01, 0x1D, 0x14):totable();
AddOutgoingPacket(0x5B, packet);
				
packet = struct.pack('bbbbIhhhbbhh', 0x5B, 0x0A, 0x00, 0x00, 0x85, 0x01, 0x10, 0x01, 0x83, 0x01, 0x00, 0x00, 0x85, 0x01, 0x01, 0x00, 0x00, 0x01, 0x1D, 0x14):totable();
AddOutgoingPacket(0x5B, packet);
				
packet = struct.pack('bbbbIhhhbbhh', 0x5B, 0x0A, 0x00, 0x00, 0x85, 0x01, 0x10, 0x01, 0x84, 0x01, 0x69, 0x00, 0x85, 0x01, 0x01, 0x00, 0x00, 0x01, 0x1D, 0x14):totable();
AddOutgoingPacket(0x5B, packet);
				
packet = struct.pack('bbbbIhhhbbhh', 0x5B, 0x0A, 0x00, 0x00, 0x85, 0x01, 0x10, 0x01, 0x00, 0x00, 0x00, 0x40, 0x85, 0x01, 0x00, 0x00, 0x00, 0x01, 0x1D, 0x14):totable();
AddOutgoingPacket(0x5B, packet);
			
packet = struct.pack('bbbbhh', 0x016, 0x04, 0x00, 0x00, GetPlayerEntity().TargetIndex, 0x00, 0x00):totable();
AddOutgoingPacket(0x016, packet);
				
busy = false;
end
Im quite sure the content of packets itself are correct (after checking the outgoings packet plus others similar addons). Its really a not flexible packet that ask to one NPC ( accolades kid mithra in adoulin) the same item (prize powder) and same quantity (840) just as a protype.

So, im wondering if there is something im missing when sending packets to server. I think my game is sending those 5 packets without any wait command in between maybe server isnt recognizing it? Another thing i wondered after reading others forums is that opening the Menu (that happen with outgoing packet 0x01A) prevent others packets to be sent. If thats the case how do i send the packet to open menu but dont actually open menu?

Sorry for that many questions. Any input is appreciate.

Thanks in advance
Post Reply