change pickupitems flag

All about the macro plugin can be found in this forum. This forum is intended for the macro plugin only.

Moderator: Moderators

Message
Author
randomguy
Human
Human
Posts: 24
Joined: 02 Jan 2014, 09:10
Noob?: No

change pickupitems flag

#1 Post by randomguy »

Hello guys, need some serious help here. My goal is to stop picking up items once I have a certain amount of them in my inventory. I searched for a simple solution to this but have not found anything. As I was looking through the openkore macro wiki I saw that there was a macro to change mon_control so i thought hey maybe I could change the pickupitems.txt the same way....but yeah no....can someone take a look at this and tell me am i on the right track or what needs to be done

Code: Select all

automacro itemempty {
   inventory "Apple" < 3
   exclusive 1
   run-once 1
   set setting Glove
   set flag 1
   call item
}

automacro itemfull {
   inventory "Apple" > 29
   exclusive 1
   run-once 1
   set setting Glove
   set pickup 0
   call item
}

macro item {
	#Getting the value of the $setting item name Ex: $setting $exist1
	$exist1 = @eval (defined Misc::pickupitems("$setting")?Misc::pickupitems("$setting")->{pickup}:"None")
	log Old Values are $setting $exist1
	log Changing the values to $setting $pickup
	do eval Misc::pickupitems("$::Macro::Data::varStack{setting}")->{flag} = $flag
	log Writting pickupitems.txt with new values
	rewrite()  # see the sub-routine function below
	log Reloading pickupitems.txt
	do reload pickupitems
	$exist1 = @eval (defined Misc::pickupitems("$setting")?Misc::pickupitems("$setting")->{pickup}:"None")
	log New pickupitems.txt Setting: $setting $exist1
	log Macro done
    #if $teleport = 0 ; means the Higher automacro HP is currently triggered <-this part was from the original macro
    #if $teleport = 2 ; means the Lower automacro HP is currently triggered <-this part was from the original macro
        if ($pickup = 1) goto releaseitemempty
        :releaseitemempty
             release itemempty
             stop
        :releaseitemfull
             release itemfull
             stop
}

sub rewrite {
  my $item = Misc::pickupitems("$::Macro::Data::varStack{setting}");
  my @lines = ();
  if (open(FILE, "<:utf8", Settings::getControlFilename("pickupitems.txt"))) {
     while (<FILE>) {
        s/\x{FEFF}//g; chomp;
        if (/^#/ || /^\n/ || /^\r/) {
           push @lines,$_;
           next
        }
        /^(\d+|([a-zA-Z' ]+)*) -?\d/;
        if ("$::Macro::Data::varStack{setting}" eq $1 && defined $item) {
           $_ = $1; s/\s+$//;
           push @lines,$_ . " $item->{pickup}"
        }
        else {push @lines,$_}
     }
     close FILE
  }
  open(FILE, ">:utf8", Settings::getControlFilename("pickupitems.txt"));
  print FILE join "\n", @lines;
  close FILE;
}

Dark Airnel
Been there done that!
Been there done that!
Posts: 133
Joined: 09 Oct 2009, 01:43
Noob?: No

Re: change pickupitems flag

#2 Post by Dark Airnel »

If you will consider using another plugin to do this task for you then you can download the xconf plugin and then use it in conjunction with the doCommand:

Code: Select all

doCommand pconf Apple 0 {
inInventory Apple >0 100
disabled 0
}

randomguy
Human
Human
Posts: 24
Joined: 02 Jan 2014, 09:10
Noob?: No

Re: change pickupitems flag

#3 Post by randomguy »

aww jesus thank you!! i didnt know something like that existed, im going to look into it right now

Post Reply