Macro Page/Book Change with Ashitacast

Talk about AshitaCast here. Need help with setting things up? Questions about how to do something? Post here.
Raelious
Posts: 5
Joined: Tue Mar 14, 2017 6:07 pm

Macro Page/Book Change with Ashitacast

Post by Raelious » Tue Mar 14, 2017 6:11 pm

I was wonder if it was possible to have Ashitacast swap your macro book/page when you change jobs for you. I had it on gearswap and was curious if it was possible to do with Ashitacast.

Code: Select all

-- Setup vars that are user-dependent.  Can override this function in a sidecar file.
function user_setup()
	-- Default macro set/book
	set_macro_page(1, 2)
end
This is how it was on my gearswap.
matix
Addon/Plugin Developer
Posts: 49
Joined: Sun May 15, 2016 10:46 pm

Re: Macro Page/Book Change with Ashitacast

Post by matix » Fri Mar 31, 2017 11:43 am

<command>/macro set 1</command>
<command>/macro book 2</command>

or make a script with both commands and

<command>/exec script</command>
keroro7788
Posts: 13
Joined: Tue May 02, 2017 11:36 am

Re: Macro Page/Book Change with Ashitacast

Post by keroro7788 » Fri May 05, 2017 12:43 am

I tried implementing this into my .xmls but no matter what I cannot get any commands to work.
Can I get some clarification please?
Thank you.
matix
Addon/Plugin Developer
Posts: 49
Joined: Sun May 15, 2016 10:46 pm

Re: Macro Page/Book Change with Ashitacast

Post by matix » Fri May 05, 2017 3:31 am

ive personally never used it for macro book commands, but i see no reason it wouldnt work, here is an example i use to trigger an init.txt upon loading of a profile:

Code: Select all

	<variables>
		<var name="init">0</var><!--dont touch-->	
	</variables

	<idlegear>
		<if advanced="$init=0">
			<setvar name="init" value="1" />
			<command>/exec run.txt</command>
			<command>/addon load bador_run</command>
		</if>	
                <!-- real idlegear stuff -->
        </idlegear>
drauku
Posts: 7
Joined: Thu Jul 20, 2017 10:19 am

Re: Macro Page/Book Change with Ashitacast

Post by drauku » Sat Sep 09, 2017 4:21 pm

matix wrote:
Fri May 05, 2017 3:31 am
ive personally never used it for macro book commands, but i see no reason it wouldnt work, here is an example i use to trigger an init.txt upon loading of a profile:

Code: Select all

	<variables>
		<var name="init">0</var><!--dont touch-->	
	</variables

	<init>
		<if advanced="$init=0">
			<setvar name="init" value="1" />
			<command>/exec run.txt</command>
			<command>/addon load bador_run</command>
		</if>	
                <!-- real idlegear stuff -->
        </init>
As matix indicated above, the ONLY place that this seems to work is inside <idlegear></idlegear>.

In addition to being able to change Macro Book per job, is there a way to pull %p_mainjob and %p_subjob, turn those into variables, and have it automatically switch to a book per each mainjob, and a specific pageset for each subjob? I experimented with this code, and it is rudimentary and works... but I would like to be able to pass variables (like the ones not being used below) into the <command> and <addtochat> functions if possible, so I can streamline the code... suggestions and pointers would be appreciated!
  1.     <variables>
  2.         <var name="init">0</var><!--variable used for initial, set-once settings -->
  3.         <if p_mainjob="PLD"><var name="macrobook">7</var></if>
  4.         <if p_subjob="WAR"><var name="macroset">1</var></if>
  5.         <if p_subjob="NIN"><var name="macroset">2</var></if>
  6.         <if p_subjob="DNC"><var name="macroset">3</var></if>
  7.     </variables>
  8.  
  9.     <init>
  10.         <if advanced="$init=0"> <!-- Initial settings when changing to this job -->
  11.             <setvar name="init" value="1" /> <!-- Increment "init" variable so this only executes once -->
  12.             <if p_mainjob="PLD"><command delay="500">/macro book 7</command> <!--Switch macro book-->
  13.                 <addtochat color="100">** MainJob is %p_mainjob. Macros set to Book 8. **</addtochat>
  14.             <if p_subjob="WAR"><command delay="500">/macro set 1</command> <!--Switch macro page-->
  15.                 <addtochat color="100">**  SubJob is %p_subjob. Macros set to Page 1. **</addtochat></if>
  16.             <if p_subjob="NIN"><command delay="500">/macro set 2</command> <!--Switch macro page-->
  17.                 <addtochat color="100">**  SubJob is %p_subjob. Macros set to Page 2. **</addtochat></if>
  18.             <if p_subjob="DNC"><command delay="500">/macro set 3</command> <!--Switch macro page-->
  19.                 <addtochat color="100">**  SubJob is %p_subjob. Macros set to Page 3. **</addtochat></if>
  20.             </if>
  21.         </if>
  22.     </init>
With the above code, I have to select my intended subjob prior to the mainjob in order for it to properly set the Page #. How would I call the "job_change" event (below) in order to have it work even were I to change subjobs without changing my mainjob, or manually reloading the profile (eg /ac load)?
  1. ashita.register_event('job_change', function(mjob, mjoblvl, sjob, sjoblvl)
  2. end);
Thank you in advance for any help anyone can give!

EDIT: I changed the <section> this codeblock is inserted due to the newly added <init> section. Thanks to @matix for mentioning this:
matix wrote:
Wed May 02, 2018 12:39 am
ashitacast now has in an actual init section where you can run things on load now

Code: Select all

<init>
     <command>/exec mnk.txt</command>
</init>
Last edited by drauku on Thu Jun 14, 2018 11:08 pm, edited 1 time in total.
User avatar
atom0s
Site Admin
Posts: 376
Joined: Sat May 14, 2016 5:13 pm

Re: Macro Page/Book Change with Ashitacast

Post by atom0s » Sat Sep 09, 2017 6:47 pm

Ashita does not have a job_change event by default. You have to add your own events to do things like that or use the old events library from Ashita v2.
You would have to port it up to Ashita v3.
Lead Ashita Developer

Want to donate to say thanks?
https://www.paypal.me/atom0s
drauku
Posts: 7
Joined: Thu Jul 20, 2017 10:19 am

Re: Macro Page/Book Change with Ashitacast

Post by drauku » Sun Sep 10, 2017 9:32 am

atom0s wrote:
Sat Sep 09, 2017 6:47 pm
Ashita does not have a job_change event by default. You have to add your own events to do things like that or use the old events library from Ashita v2.
You would have to port it up to Ashita v3.
Thanks atom0s, that is something I have no idea how to do, so I'll keep coding this stuff to happen with the ashitacast profile load trigger.
On a related note, how does Ashitacast then know to load the proper profile as soon as you change jobs? Was the job_change event registered in the ashitacast.dll somehow?
User avatar
atom0s
Site Admin
Posts: 376
Joined: Sat May 14, 2016 5:13 pm

Re: Macro Page/Book Change with Ashitacast

Post by atom0s » Sun Sep 10, 2017 11:36 pm

Ashita is not limited like Windower, our plugin SDK (known as the Ashita Development Kit or ADK) is fully open to all to use and packet access is fully available and has been from the start of the project. Developers are free to handle packet based information themselves, which in this case AshitaCast does.
Lead Ashita Developer

Want to donate to say thanks?
https://www.paypal.me/atom0s
drauku
Posts: 7
Joined: Thu Jul 20, 2017 10:19 am

Re: Macro Page/Book Change with Ashitacast

Post by drauku » Mon Sep 11, 2017 11:21 am

Thanks for the clarification! I'll see if learning how to use ADK is within my abilities.
Awesome work on Ashita, btw. Thanks for the time and effort you've put into this project.
Lordos
Posts: 7
Joined: Fri Oct 27, 2017 4:31 pm

Re: Macro Page/Book Change with Ashitacast

Post by Lordos » Thu Nov 02, 2017 12:47 pm

Where do i add the init???
Post Reply