Hey all, fairly new to this mod although I have some prior (albeit limited and very basic) coding experience. I've been doing a lot of testing around with the GETSLOTITEM command and I can't get this file to execute properly.
This code logs "Didn't Work." no matter what is in slot 35, which means something about my assumptions for the function GETSLOTITEM is incorrect. I'm trying to only play the sound when slot 35 contains cobblestone, which has an item ID of 4. GETSLOTITEM returns the id of the item found in said slot, so what am I missing here?
Hey all, fairly new to this mod although I have some prior (albeit limited and very basic) coding experience. I've been doing a lot of testing around with the GETSLOTITEM command and I can't get this file to execute properly.
This code logs "Didn't Work." no matter what is in slot 35, which means something about my assumptions for the function GETSLOTITEM is incorrect. I'm trying to only play the sound when slot 35 contains cobblestone, which has an item ID of 4. GETSLOTITEM returns the id of the item found in said slot, so what am I missing here?
1) Cobblestone does not have an item ID of 4, not since minecraft 1.7 (which was like 5 years ago now)
The id is now 'minecraft:cobblestone' or just 'cobblestone'
2) The lexer/parser in this mod is handmade and rather simplistic - it assumes you are giving it a simple sequence of commands, it doesn't build an AST.
So the command IF(GETSLOTITEM(35,&idvar) == cobblestone); is interpreted as a simple string comparison, which is never true
What you want instead is either
GETSLOTITEM(35,&idvar)
IF(&idvar == cobblestone)
or
&idvar = GETSLOTITEM(35); // new return-value syntax, available since
IF(&idvar == cobblestone)
addendum) A tip for any type of coding
When your program doesn't work, you need to forget / test ALL of your assumptions - the best way to do that is to work in small steps, implementing the simplest feature that gets you closer to the end goal.
For example, this is how i would build up the script
// Test Log first because having some visible output is always useful for debugging
Log(true) // works
// Test GetSlotItem
GetSlotItem(35,&id)
Log(&id) // Logs &id, how do i get the value?
GetSlotItem(35,&id)
Log(%&id%) // Logs cobblestone (oh, didn't expect that, okay, will keep it in mind)
// Test the IF statement
GetSlotItem(35,&id)
Log(%&id%)
IF(&id == cobblestone) // Seems to work so far, now let's try removing logs and simplifying
Log(true)
ELSE
Log(false)
ENDIF
// Test nesting
IF(GetSlotItem(35,&id) == cobblestone); // Only change was the indroduction of nesting - i guess nesting doesn't work, revert to previous
Log(true)
ELSE
Log(false)
ENDIF
Thank you so much for your help, you've gotten me much farther. My code now looks like this:
$${
&id = GETSLOTITEM(35);
LOG(%&id%); //This now logs "air" every single time, also no matter what I put in slot 35.
IF(&id == "cobblestone");
PLAYSOUND(custom.alert);
LOG("Worked.");
ELSE;
LOG("Didn't work.");
ENDIF;
}$$
Not surprisingly, when I change the IF statement to: IF(&id == "air"); the code executes properly and actually plays the sound.
I can't figure out why slot 35 is always returning air. Here's a screenshot demonstrating the problem:
No. The hotkey I've set doesn't execute the file if I press it while the inventory is open. Is there a way to let the code know to check the inventory regardless?
I'm just trying to make a basic "notification" script that works with a cobblestone generator. The idea is that it mines automatically, and when the inventory fills up entirely, it'll give me a noise which lets me know to empty it.
In my testing, slot 35 fills up last. Hotbar first, then top-down left-right in the inventory. If it can't check the inventory slots unless it's open, it can't mine at the same time, and therefore isn't automatic.
No. The hotkey I've set doesn't execute the file if I press it while the inventory is open. Is there a way to let the code know to check the inventory regardless?
I'm just trying to make a basic "notification" script that works with a cobblestone generator. The idea is that it mines automatically, and when the inventory fills up entirely, it'll give me a noise which lets me know to empty it.
In my testing, slot 35 fills up last. Hotbar first, then top-down left-right in the inventory. If it can't check the inventory slots unless it's open, it can't mine at the same time, and therefore isn't automatic.
When your inventory isn't open, it doesn't exist - there is no slot 35 then
Some options:
Periodically open and close the inventory to check
Mine until hotbar is full - shift click into inventory - repeat
Use a hopper or similar to eliminate the need to pick up items in the first place
I'm not sure how to word this, but maybe someone out there has some insite.
I'm having trouble with a menu type script. The server I play on has CBX or Crafbook Extra. Where you can place signs with various text to do certain tasks. such as Make a door(out of blocks not the door block), or bridge, etc... you can pick a material for some of these signs. HOWEVER, I'm trying to make a menu where I select the type of sign I want to create. then the script selects the correct sign to ask questions about, and asks "$$[[SET BLOCK ID,ALREADY SET]]" asking what material I want to use. I DONT want it to ask me for a material if I select a sign that doesn't require a material. such as a LIFT sign. However, from what I can gather, the limitations of macromod make it so that the $$i:d command is read BEFORE the rest of the script runs. Which means, if $$i:d is in the scritp, its going to get executed before the body of the script even runs. I tried having a second script execute but that didn't get me much farther, as it doesn't seem to execute the $$i:d command after the initial script has started. maybe theirs a way to do this with a conditional macro? idk. Or maybe i'm not doing the Exec(someotherfile.txt) correctly.
//RUNS LAST
//Maybe Check to see if we even have a sign in the inventory kinda important.
//some unused code is for future script expansion.
&question = "TYPE OF SIGN";
PROMPT(&signname,"$[[LIFT,DOOR,BRIDGE,TRANSMITTER,RECIEVER]]",%&question%,true); //Initial prompt to determine type of sign to use.
//DOOR SIGN ****************** ****************** ****************** ******************
//DOOR SIGN ****************** ****************** ****************** ******************
IF(%&signname%="DOOR");
&doormaterial = "DOOR Material, BLOCK ID?";
PROMPT(&material,"$[[SET BLOCK ID,ALREADY SET]]",%&doormaterialprompt%,true); //This sign uses materials, choose new block ID?
&doorwidthprompt = "Door Width? 1-11";
PROMPT(#doorwidth,"$[[1,2,3,4,5,6,7,8,9,10,11]]",%&doorwidthprompt%,true); //How wide will the door be?
&doorheightprompt = "Door Height? 1-30";
PROMPT(&doorheight,"$[[1,2,3,4,5,6,7,8,9,10,11,?]]",%&doorheightprompt%,true); //How Tall will the door be?
&dooroffsetprompt = "Door Vertical Offset? (-10)-10";
PROMPT(&dooroffset,"$[[1,2,3,4,5,6,7,8,9,10,?]]",%&dooroffsetprompt%,true); //Offset from Sign block?
IF((%&material% = "SET BLOCK ID"));
SPLIT(":",$i:d,&blockidmatrix[]); //Split Material ID into matrix.
SET(&blockid,%&blockidmatrix[0]%); //Set block ID var.
SET(#blockidcolor,%&blockidmatrix[1]%); //Set block ID COLOR var.
#signblockmaterial = ITEMID(%&blockidmatrix[0]%); //Set sign material var.
ENDIF;
IF(%&doorheight%="?");
&howwide = "How TALL should the door be?";
PROMPT(#doorheight,"$?",%&howwide%,true); //Prompt for How tall the door should be.
IF((%#doorheight% >= 1) && (%#doorheight% <= 30)); //Verify the height is within parameters.
ELSE;
LOG(ERROR out of parameters try again.);
STOP;
ENDIF;
ELSE;
SET(#doorheight,%&doorheight%); //set the door height var.
ENDIF;
IF(%&dooroffset%="?");
&howoffset = "Vertical OFFSET? (-10)-10";
PROMPT(#dooroffset,"$?",%&howoffset%,true); //Prompt for the doors offset from the sign block.
IF((%#dooroffset% >= -10) && (%#dooroffset% <= 10)); //Verify the offset is within parameters.
ELSE;
LOG(ERROR out of parameters try again.);
STOP;
ENDIF;
ELSE;
SET(#dooroffset,%&dooroffset%); //set dooroffset var.
ENDIF;
KEYDOWN(42); //must use shift to place on a chest or on another sign. which is why this command is here.
WAIT(5t); //wait inserted for lag issues.
//PLACESIGN(,[MCX208],%#signblockmaterial%:%#blockidcolor%,%#doorwidth%:%#doorheight%:%#dooroffset%); //place Craftbook Extra Door Sign.
//The following is used if using the menu and placesignmaterial.txt files.
PLACESIGN(,[MCX208],%@#signblockmaterial%:%@#blockidcolor%,%#doorwidth%:%#doorheight%:%#dooroffset%); //IF using the MENU, and material txt files.
KEYUP(42); //wait inserted for lag issues.
//DOOR SIGN ****************** ****************** ****************** ******************
//DOOR SIGN ****************** ****************** ****************** ******************
//BRIDGE SIGN ****************** ****************** ****************** ******************
//BRIDGE SIGN ****************** ****************** ****************** ******************
//I'm not going to comment the Bridge sign code as its very similear to the DOOR sign.
ELSEIF(%&signname%="BRIDGE");
&bridgematerial = "Bridge Material, BLOCK ID?";
#PROMPT(&bridgematerial,"$[[SET BLOCK ID,ALREADY SET]]",%&doormaterialprompt%,true);
&bridgewidthprompt = "Bridge Width? 1-11";
PROMPT(#bridgewidth,"$[[1,2,3,4,5,6,7,8,9,10,11]]",%&bridgewidthprompt%,true);
&bridgelengthprompt = "Bridge Length? 1-30";
PROMPT(&bridgelength,"$[[1,2,3,4,5,6,7,8,9,10,11,30,?]]",%&bridgelengthprompt%,true);
&bridgeoffsetprompt = "Bridge Vertical Offset? (-10)-10";
PROMPT(&bridgeoffset,"$[[-1,1,2,3,4,5,6,7,8,9,10,?]]",%&bridgeoffsetprompt%,true);
IF((%&material% = "SET BLOCK ID"));
SPLIT(":",$i:d,&blockidmatrix[]);
SET(&blockid,%&blockidmatrix[0]%);
SET(&blockidcolor,%&blockidmatrix[1]%);
#signblockmaterial = ITEMID(%&blockidmatrix[0]%);
ENDIF;
IF(%&bridgelength%="?");
&howlong = "How LONG should the bridge be?";
PROMPT(#bridgelength,"$?",%&howlong%,true);
IF((%#bridgelength% >= 1) && (%#bridgelength% <= 30));
ELSE;
LOG(ERROR out of parameters try again.);
STOP;
ENDIF;
ELSE;
SET(#bridgelength,%&bridgelength%);
ENDIF;
IF(%&bridgeoffset%="?");
&howoffset = "Vertical OFFSET? (-10)-10";
PROMPT(#bridgeoffset,"$?",%&howoffset%,true);
IF((%#bridgeoffset% >= -10) && (%#bridgeoffset% <= 10));
ELSE;
LOG(ERROR out of parameters try again.);
STOP;
ENDIF;
ELSE;
SET(#bridgeoffset,%&bridgeoffset%);
ENDIF;
PLACESIGN(,[MCX207],%#signblockmaterial%:%&blockidcolor%,%#bridgewidth%:%#bridgelength%:%#bridgeoffset%); //Bridge
//BRIDGE SIGN ****************** ****************** ****************** ******************
//BRIDGE SIGN ****************** ****************** ****************** ******************
//LIFT SIGN ****************** ****************** ****************** ******************
//LIFT SIGN ****************** ****************** ****************** ******************
ELSEIF(%&signname%="LIFT");
&liftcurrentfloorprompt = "Current floor name, 0-15Char";
PROMPT(&liftcurrentfloor,"$?",%&liftcurrentfloorprompt%,true); // Current floor name, this will show up in chat when you use a lift to this floor.
&liftdirectionprompt = "up or down when right clicking the sign?";
PROMPT(&liftdirection,"$[[Lift,Lift Up,Lift Down]]",%&liftdirectionprompt%,true); //Lift Sign Text, what do you want the lift to do.
&liftanytext1 = "Any text, eg.where the lift goes to, 0-15Char";
PROMPT(&liftanytext1,"$?",%&liftanytext1%,true); //Line 3 any text
&liftanytext2 = "Any text,can be any text wanted on the sign, 0-15Char";
PROMPT(&liftanytext2,"$?",%&liftanytext2%,true); //Line 4 any text
IFMATCHES(%&liftcurrentfloor%,"^.{0,15}$",); //Line 1, Filter to be sure entered text is within sign parameters.
//LOG(MATCH!!!);
ELSE;
LOG(ERROR out of parameters try again.);
STOP;
ENDIF;
IFMATCHES(%&liftanytext1%,"^.{0,15}$",); //Line 3, Filter to be sure entered text is within sign parameters.
//LOG(MATCH!!!);
ELSE;
LOG(ERROR out of parameters try again.);
STOP;
ENDIF;
IFMATCHES(%&liftanytext2%,"^.{0,15}$",); //Line 4, Filter to be sure entered text is within sign parameters.
//LOG(MATCH!!!);
ELSE;
LOG(ERROR out of parameters try again.);
STOP;
ENDIF;
PLACESIGN(%&liftcurrentfloor%,[%&liftdirection%],%&liftanytext1%,%&liftanytext2%); //place Craftbook Extra Lift Sign.
//LIFT UP SIGN ****************** ****************** ****************** ******************
//LIFT UP SIGN ****************** ****************** ****************** ******************
ELSE;
LOG(I do Nothing);
ENDIF;
STOP
For example, If i run a main MENU script to ask if the block ID is already set or not. and depending on which answer it gives, executes a second script. that either runs the main scritp "placesign3" OR if i Want to enter a new material, runs a script that sets the material in a Global var. "placesignmaterial". But this doenst work the way i expect. If i run the placesignmaterial.txt file first. it asks for the material. if it is executed by another script. it fails to ask me for the material.
placesignMENU.txt
//RUNS first
//MENU script. Asks if the block id has been set or not.
//ASKS what material u want using i:d, then sets the material var.
SPLIT(":",$$i:d,&blockidmatrix[]); //splits i:d into a matrix so i can seperate the ID.
//THE PROBLEM is that if this script is executed from ANOTHER scrtip. $i:d doesnt ask for the material.
SET(@&blockid,%&blockidmatrix[0]%); //unnessasary right now.
SET(@#blockidcolor,%&blockidmatrix[1]%); //sets block ID color.
@#signblockmaterial = ITEMID(%&blockidmatrix[0]%); //sets block material var.
First of all - props for the good analysis
You are correct that these "preprocessor directives" (iirc) are evaluated before the script is run, with no understanding of the surrounding context
There is an exception though - i'm not sure how it works, but the PROMPT command can be used to collect values during runtime
In addition to what Mart said, I generally recommend to only use prompt in scripts because the highlighted problem is exactly the use case for it and not using normal parameter strings will result in the code being easier to read and prevents issues. Using parameter strings is better to only be used in direct commands (without script)
MART, thank you! you genius you lol. I re-worked my script and its working wonderfully now. going to post it here so all can use and see.
V8.3.2 -fixed bridge; fixed material not asking correctly.
//Maybe Check to see if we even have a sign in the inventory kinda important.
//some unused code is for future script expansion.
&question = "TYPE OF SIGN";
PROMPT(&signname,"$$[[LIFT,DOOR,BRIDGE,TRANSMITTER/RECIEVER]]",%&question%,true); //Initial prompt to determine type of sign to use.
IF(%&doormaterial%="SET BLOCK ID");
&question = "TYPE OF MATERIAL";
PROMPT(&blockid,"$$i:d",%&question%,true); //Initial prompt to determine type of material to use.
SPLIT(":",%&blockid%,&blockidmatrix[]); //splits i:d into a matrix so i can seperate the ID.
//SET(&blockid,%&blockidmatrix[0]%); //unnessasary right now.
SET(#blockidcolor,%&blockidmatrix[1]%); //sets block ID color.
#signblockmaterial = ITEMID(%&blockidmatrix[0]%); //sets block material var.
ENDIF;
&doorwidthprompt = "Door Width? 1-11";
PROMPT(#doorwidth,"$$[[1,2,3,4,5,6,7,8,9,10,11]]",%&doorwidthprompt%,true); //How wide will the door be?
&doorheightprompt = "Door Height? 1-30";
PROMPT(&doorheight,"$$[[1,2,3,4,5,6,7,8,9,10,11,?]]",%&doorheightprompt%,true); //How Tall will the door be?
&dooroffsetprompt = "Door Vertical Offset? (-10)-10";
PROMPT(&dooroffset,"$$[[1,2,3,4,5,6,7,8,9,10,?]]",%&dooroffsetprompt%,true); //Offset from Sign block?
IF(%&doorheight%="?");
&howwide = "How TALL should the door be?";
PROMPT(#doorheight,"$$?",%&howwide%,true); //Prompt for How tall the door should be.
IF((%#doorheight% >= 1) && (%#doorheight% <= 30)); //Verify the height is within parameters.
ELSE;
LOG(ERROR out of parameters try again.);
STOP;
ENDIF;
ELSE;
SET(#doorheight,%&doorheight%); //set the door height var.
ENDIF;
IF(%&dooroffset%="?");
&howoffset = "Vertical OFFSET? (-10)-10";
PROMPT(#dooroffset,"$$?",%&howoffset%,true); //Prompt for the doors offset from the sign block.
IF((%#dooroffset% >= -10) && (%#dooroffset% <= 10)); //Verify the offset is within parameters.
ELSE;
LOG(ERROR out of parameters try again.);
STOP;
ENDIF;
ELSE;
SET(#dooroffset,%&dooroffset%); //set dooroffset var.
ENDIF;
KEYDOWN(42); //must use shift to place on a chest or on another sign. which is why this command is here.
WAIT(5t); //wait inserted for lag issues.
PLACESIGN(,[MCX208],%#signblockmaterial%:%#blockidcolor%,%#doorwidth%:%#doorheight%:%#dooroffset%); //IF using the MENU, and material txt files.
KEYUP(42); //wait inserted for lag issues.
//DOOR SIGN ****************** ****************** ****************** ******************
//DOOR SIGN ****************** ****************** ****************** ******************
//BRIDGE SIGN ****************** ****************** ****************** ******************
//BRIDGE SIGN ****************** ****************** ****************** ******************
//I'm not going to comment the Bridge sign code as its very similear to the DOOR sign.
ELSEIF(%&signname%="BRIDGE");
IF(%&bridgematerial%="SET BLOCK ID");
&question = "TYPE OF MATERIAL";
PROMPT(&blockid,"$$i:d",%&question%,true); //Initial prompt to determine type of material to use.
SPLIT(":",%&blockid%,&blockidmatrix[]); //splits i:d into a matrix so i can seperate the ID.
SET(&blockid,%&blockidmatrix[0]%); //unnessasary right now.
SET(#blockidcolor,%&blockidmatrix[1]%); //sets block ID color.
#signblockmaterial = ITEMID(%&blockidmatrix[0]%); //sets block material var.
ENDIF;
KEYDOWN(42); //must use shift to place on a chest or on another sign. which is why this command is here.
WAIT(5t); //wait inserted for lag issues.
PLACESIGN(,[MCX207],%#signblockmaterial%:%#blockidcolor%,%#bridgewidth%:%#bridgelength%:%#bridgeoffset%); //Bridge
KEYUP(42); //wait inserted for lag issues.
&liftcurrentfloorprompt = "Current floor name, 0-15Char";
PROMPT(&liftcurrentfloor,"$$?",%&liftcurrentfloorprompt%,true); // Current floor name, this will show up in chat when you use a lift to this floor.
&liftdirectionprompt = "up or down when right clicking the sign?";
PROMPT(&liftdirection,"$$[[Lift,Lift Up,Lift Down]]",%&liftdirectionprompt%,true); //Lift Sign Text, what do you want the lift to do.
&liftanytext1 = "Any text, eg.where the lift goes to, 0-15Char";
PROMPT(&liftanytext1,"$$?",%&liftanytext1%,true); //Line 3 any text
&liftanytext2 = "Any text,can be any text wanted on the sign, 0-15Char";
PROMPT(&liftanytext2,"$$?",%&liftanytext2%,true); //Line 4 any text
IFMATCHES(%&liftcurrentfloor%,"^.{0,15}$",); //Line 1, Filter to be sure entered text is within sign parameters.
//LOG(MATCH!!!);
ELSE;
LOG(ERROR out of parameters try again.);
STOP;
ENDIF;
IFMATCHES(%&liftanytext1%,"^.{0,15}$",); //Line 3, Filter to be sure entered text is within sign parameters.
//LOG(MATCH!!!);
ELSE;
LOG(ERROR out of parameters try again.);
STOP;
ENDIF;
IFMATCHES(%&liftanytext2%,"^.{0,15}$",); //Line 4, Filter to be sure entered text is within sign parameters.
//LOG(MATCH!!!);
ELSE;
LOG(ERROR out of parameters try again.);
STOP;
ENDIF;
KEYDOWN(42); //must use shift to place on a chest or on another sign. which is why this command is here.
WAIT(5t); //wait inserted for lag issues.
PLACESIGN(%&liftcurrentfloor%,[%&liftdirection%],%&liftanytext1%,%&liftanytext2%); //place Craftbook Extra Lift Sign.
KEYUP(42); //wait inserted for lag issues.
//LIFT SIGN ****************** ****************** ****************** ******************
//LIFT SIGN ****************** ****************** ****************** ******************
&transmitorrecieveprompt = "Transmit or Recieve sign?";
PROMPT(&transmitorrecieve,"$$[[Transmitter,Reciever]]",%&transmitorrecieveprompt%,true);
&transmitterbandprompt = "Transmitter/Reciever BAND ID?";
PROMPT(&transmitterbandset,"$$[[SET BAND,ALREADY SET,Previous BANDS BELOW,%&transmitterband0%,%&transmitterband1%,%&transmitterband2%,%&transmitterband3%]]",%&transmitterbandprompt%,true);
IF(%&transmitorrecieve%="Transmitter"); //Line 2, Filter to be sure entered text is within sign parameters.
SET(&transmittertype,"MC1110");
ELSEIF(%&transmitorrecieve%="Reciever");
SET(&transmittertype,"MC0111");
ELSE;
LOG(ERROR out of parameters try again.);
STOP;
ENDIF;
IF(%&transmitterbandset%="SET BAND");
&bandprompt = "Band Name for Transmitter Linking, 0-15Char";
PROMPT(&transmitterband,"$$?",%&bandprompt%,true);
IFMATCHES(%&transmitterband%,"\$",); //Line 3, Filter to be sure entered text is within sign parameters.
LOG(Using $ BREAKS the script.);
UNSET(&transmitterband);
SET(&transmitterband,%&transmitterband0%);
ENDIF;
IFMATCHES(%&transmitterband%,"^.{0,15}$",);//Line 3, Filter to be sure entered text is within sign parameters.
ELSE;
LOG(ERROR out of parameters try again.);
STOP;
ENDIF;
IFMATCHES(%&transmitteranytext4%,"^.{0,15}$",);//Line 4, Filter to be sure entered text is within sign parameters.
ELSE;
LOG(ERROR out of parameters try again.);
STOP;
ENDIF;
KEYDOWN(42);
WAIT(5t); //wait inserted for lag issues.
PLACESIGN(,[%&transmittertype%],%&transmitterband%,%&transmitteranytext4%); //place Craftbook Extra Tramsmitter Sign.
KEYUP(42);
//TRANSMITTER SIGN ****************** ****************** ****************** ******************
//TRANSMITTER SIGN ****************** ****************** ****************** ******************
Hey, i hope someone can help me with my macro. I tried for days now, but it doesn't work.
First i will tell you what i want to achieve.
So i want a macro that will start sprinting forward and start mining cobble until the inventory is full. After that, the account should drop the cobblestone out of the inventory and repeat running/mining and dropping without pressing the macro key again it should work afk.
Here is what i got so far. I got 3 scripts that contain:
Now i bind it to a key with:
$${$$<run.txt>}$$ $${$$<attack.txt>}$$ $${wait(50ms)}$$ $${$$<attack.txt>}$$
Like this it will run and start attacking. I have attack doubled because after i open the inventory with the drop.txt the account need to press the attack button again. I got no solution for the drop.txt that it triggers when the inventory is full. And overall this is a really bad solution i think.
I hope you can help me to get a working script because im to bad to get it right
Hey, i hope someone can help me with my macro. I tried for days now, but it doesn't work.
First i will tell you what i want to achieve.
So i want a macro that will start sprinting forward and start mining cobble until the inventory is full. After that, the account should drop the cobblestone out of the inventory and repeat running/mining and dropping without pressing the macro key again it should work afk.
Here is what i got so far. I got 3 scripts that contain:
Now i bind it to a key with:
$${$$<run.txt>}$$ $${$$<attack.txt>}$$ $${wait(50ms)}$$ $${$$<attack.txt>}$$
Like this it will run and start attacking. I have attack doubled because after i open the inventory with the drop.txt the account need to press the attack button again. I got no solution for the drop.txt that it triggers when the inventory is full. And overall this is a really bad solution i think.
I hope you can help me to get a working script because im to bad to get it right
It might be easier to start with the entire script in one file, because that's how the mod eventually runs the code - just like it was copy pasted together
Figure out a basic high level overview, because you can only do one thing at a time
I'm guessing it should go something like
Once you have the high level idea of what you want to make, start making and testing it in individual pieces
For example, try to just get it to run first
Then to run and mine
Then in a separate script try to figure out how to detect if the inventory is full
Then combine them
Then in a separate script try to figure out how to drop all the items in your inv
Is there any way to make a script to look in the direction of a coordinate and walk to that position then do the same for a chain of different coordinates using GETID and CALCYAWTO? If anyone could make me a script that does this and tell me how to input custom x and z values I'd be eternally grateful.
Is there any way to make a script to look in the direction of a coordinate and walk to that position then do the same for a chain of different coordinates using GETID and CALCYAWTO? If anyone could make me a script that does this and tell me how to input custom x and z values I'd be eternally grateful.
Well the core of it is just Look(pitch,yaw) and Keydown(forward)
But depending on how smart you want it to be it can be anything from easy to practically impossible
Consider for example the following potential obstacles
Difficult
Hostile players
Mobs
Fatal drops (holes in the ground - ravines)
Unavoidable drops (steep mountain side)
Unavoidable pillaring (steep mountain side again)
Doors
Unavoidable mining (coordinates accidentally happen to be inside a mountain or w\e)
Potentially doable:
Turns (A house is in the way, have to go around it)
Doable:
Jumps: (The terrain gradually changes height, have to jump up 1 block ledges)
So it all depends on the context of what you want this for
Well the core of it is just Look(pitch,yaw) and Keydown(forward)
But depending on how smart you want it to be it can be anything from easy to practically impossible
Consider for example the following potential obstacles
Difficult
Hostile players
Mobs
Fatal drops (holes in the ground - ravines)
Unavoidable drops (steep mountain side)
Unavoidable pillaring (steep mountain side again)
Doors
Unavoidable mining (coordinates accidentally happen to be inside a mountain or w\e)
Potentially doable:
Turns (A house is in the way, have to go around it)
Doable:
Jumps: (The terrain gradually changes height, have to jump up 1 block ledges)
So it all depends on the context of what you want this for
I want it to walk to a specific inputted coordinate, then walk to a chain of different specific coordinates. Ideally also able to jump over singular blocks. That's it.
I want it to walk to a specific inputted coordinate, then walk to a chain of different specific coordinates. Ideally also able to jump over singular blocks. That's it.
Turns out i already had something like that - had to tweak it a bit but this should get you started
(The entire thing goes in a file, it looks like markdown with code snippets (well, it is), but it works just fine for the mod too because it ignores all the lines it doesn't understand)
# Waypoint walker script
## Configuration
```mkb
&logtarget = "Debug"
#threshold = 0
use_y = false
```
## Waypoints
```mkb
UnSet(#walkx[])
UnSet(#walky[])
UnSet(#walkz[])
#walkx[] = 10
#walky[] = 4
#walkz[] = 10
#walkx[] = 10
#walky[] = 6
#walkz[] = 0
```
Note: The following global variables are exposed (you can use these in a GUI for example)
The current waypoint we're walking towards: `@#walker_target_x` `@#walker_target_y` `@#walker_target_z`
The distance to that waypoint: `@#walker_distance`
## Code
```mkb
TOGGLE;
IF;LogTo("%&logtarget%","Stopped");Keyup(jump);Keyup(forward);STOP;ENDIF;
#size = ArraySize(#walkx[])
#size = #size - 1
FOR(#i = 0 to %#size%)
logTo("%&logtarget%","%#i%")
#x = #walkx[%#i%]
#y = #walky[%#i%]
#z = #walkz[%#i%]
keydown(forward)
DO()
// ---------------- CALCULATE DIRECTION TO LOOK IN ----------------
// Get direction and distance on the horizontal plane
calcyawto(%#x%,%#z%,#yaw,#dist);
inc(#yaw,180); // coordinate transformation
// Get direction and distance on a vertical plane
// Get position relative to head
#deltay = #y - YPOS + 2; //+2 for player correction
#deltaz = #dist
//// NOV16: I suspect this doesn't actually add precision
// *100 for increased precision
#deltay = #deltay * 100
#deltaz = #deltaz * 100
IF(!use_y) #deltay = 0
// Offset from current position
#vx = XPOS+#deltay
#vz = ZPOS+#deltaz
// Get pitch
CalcYawTo(%#vx%,%#vz%,#pitch,#dist_3d)
// Look in direction
IF(use_y)
look(%#yaw%,%#pitch%)
ELSE
look(%#yaw%,+0)
ENDIF
// Jump if suspect blocks in the way
#sig_x = 1;
#sig_z = 1;
IF(YAW < 180); #sig_x = -1; ENDIF
IF((90 < YAW) && (YAW < 270)); #sig_z = -1; ENDIF
&block_1 = GETIDREL(%#sig_x%,0,0)
&block_2 = GETIDREL(%#sig_x%,0,%#sig_z%)
&block_3 = GETIDREL(0,0,%#sig_z%)
IFMATCHES("%&block_1%,%&block_2%,%&block_3%","air,air,air");
Keyup(jump)
ELSE;
Keydown(jump);
ENDIF;
// expose global variables
@#walker_yaw = %#yaw%
@#walker_pitch = %#pitch%
@#walker_target_x = %#x%
@#walker_target_y = %#y%
@#walker_target_z = %#z%
IF(use_y)
@#walker_distance = %#dist_3d%
ELSE
@#walker_distance = %#dist%
ENDIF
// ---------------- CHECK IF TARGET REACHED ----------------
While((#threshold < #dist_3d) && (use_y || (#threshold < #dist)));
Keyup(forward)
NEXT;
```
Turns out i already had something like that - had to tweak it a bit but this should get you started
(The entire thing goes in a file, it looks like markdown with code snippets (well, it is), but it works just fine for the mod too because it ignores all the lines it doesn't understand)
# Waypoint walker script
## Configuration
```mkb
&logtarget = "Debug"
#threshold = 0
use_y = false
```
## Waypoints
```mkb
UnSet(#walkx[])
UnSet(#walky[])
UnSet(#walkz[])
#walkx[] = 10
#walky[] = 4
#walkz[] = 10
#walkx[] = 10
#walky[] = 6
#walkz[] = 0
```
Note: The following global variables are exposed (you can use these in a GUI for example)
The current waypoint we're walking towards: `@#walker_target_x` `@#walker_target_y` `@#walker_target_z`
The distance to that waypoint: `@#walker_distance`
## Code
```mkb
TOGGLE;
IF;LogTo("%&logtarget%","Stopped");Keyup(jump);Keyup(forward);STOP;ENDIF;
#size = ArraySize(#walkx[])
#size = #size - 1
FOR(#i = 0 to %#size%)
logTo("%&logtarget%","%#i%")
#x = #walkx[%#i%]
#y = #walky[%#i%]
#z = #walkz[%#i%]
keydown(forward)
DO()
// ---------------- CALCULATE DIRECTION TO LOOK IN ----------------
// Get direction and distance on the horizontal plane
calcyawto(%#x%,%#z%,#yaw,#dist);
inc(#yaw,180); // coordinate transformation
// Get direction and distance on a vertical plane
// Get position relative to head
#deltay = #y - YPOS + 2; //+2 for player correction
#deltaz = #dist
//// NOV16: I suspect this doesn't actually add precision
// *100 for increased precision
#deltay = #deltay * 100
#deltaz = #deltaz * 100
IF(!use_y) #deltay = 0
// Offset from current position
#vx = XPOS+#deltay
#vz = ZPOS+#deltaz
// Get pitch
CalcYawTo(%#vx%,%#vz%,#pitch,#dist_3d)
// Look in direction
IF(use_y)
look(%#yaw%,%#pitch%)
ELSE
look(%#yaw%,+0)
ENDIF
// Jump if suspect blocks in the way
#sig_x = 1;
#sig_z = 1;
IF(YAW < 180); #sig_x = -1; ENDIF
IF((90 < YAW) && (YAW < 270)); #sig_z = -1; ENDIF
&block_1 = GETIDREL(%#sig_x%,0,0)
&block_2 = GETIDREL(%#sig_x%,0,%#sig_z%)
&block_3 = GETIDREL(0,0,%#sig_z%)
IFMATCHES("%&block_1%,%&block_2%,%&block_3%","air,air,air");
Keyup(jump)
ELSE;
Keydown(jump);
ENDIF;
// expose global variables
@#walker_yaw = %#yaw%
@#walker_pitch = %#pitch%
@#walker_target_x = %#x%
@#walker_target_y = %#y%
@#walker_target_z = %#z%
IF(use_y)
@#walker_distance = %#dist_3d%
ELSE
@#walker_distance = %#dist%
ENDIF
// ---------------- CHECK IF TARGET REACHED ----------------
While((#threshold < #dist_3d) && (use_y || (#threshold < #dist)));
Keyup(forward)
NEXT;
```
Alright, I've tried it out and I have a question. How do you input several coordinates to travel to after one another? For example, first coordinate 1, then 2, then 3 etc. Also, let me specify what I want the script to do more specifically so you have a better idea of what I'm trying to do; I want to set up a loop for the character, where it walks from coordinate to coordinate, eventually returning to the start position and then repeating the loop. At every coordinate inputted, the character will left click once, wait 5 seconds and continue toward the next coordinate and repeating the action. The code might look something like this (very simplified and unprofessional):
1. Go to coordinate 1
2. Left click
3. Wait 5 sec
4. Go to coordinate 2
5. Left click
6. Wait 5 sec
7. Go to coordinate 3
8. Left click
9. Wait 5 sec
10. Repeat
In practice, more coordinates would be needed, forming a kind of circle, but I believe this demonstrates my idea adequately. This is probably what your script does with a couple more steps added, but I think I might need an explanation of how to work it and input the variables as I'm not exactly experienced in coding... Sorry if this is too much to ask. I do think I could make something workable after hours of trial and error, but I figured it's probably easier and less time consuming if you just explain how it works.
Again, thanks so much for responding and giving me a script almost immediately. I am as stated previously, eternally grateful.
Alright, I've tried it out and I have a question. How do you input several coordinates to travel to after one another? For example, first coordinate 1, then 2, then 3 etc. Also, let me specify what I want the script to do more specifically so you have a better idea of what I'm trying to do; I want to set up a loop for the character, where it walks from coordinate to coordinate, eventually returning to the start position and then repeating the loop. At every coordinate inputted, the character will left click once, wait 5 seconds and continue toward the next coordinate and repeating the action. The code might look something like this (very simplified and unprofessional):
1. Go to coordinate 1
2. Left click
3. Wait 5 sec
4. Go to coordinate 2
5. Left click
6. Wait 5 sec
7. Go to coordinate 3
8. Left click
9. Wait 5 sec
10. Repeat
In practice, more coordinates would be needed, forming a kind of circle, but I believe this demonstrates my idea adequately. This is probably what your script does with a couple more steps added, but I think I might need an explanation of how to work it and input the variables as I'm not exactly experienced in coding... Sorry if this is too much to ask. I do think I could make something workable after hours of trial and error, but I figured it's probably easier and less time consuming if you just explain how it works.
Again, thanks so much for responding and giving me a script almost immediately. I am as stated previously, eternally grateful.
This example already has two coordinates right at the start there, 10,10 and 10,0
Let me remove the extra stuff and leave only the script and commends, hopefully it'll make more sense then
edit: A lot of the complexity comes from the fact that i tried to combine 2d and 3d logic
Do you want height to matter? or only the x and z?
Hey all, fairly new to this mod although I have some prior (albeit limited and very basic) coding experience. I've been doing a lot of testing around with the GETSLOTITEM command and I can't get this file to execute properly.
This code logs "Didn't Work." no matter what is in slot 35, which means something about my assumptions for the function GETSLOTITEM is incorrect. I'm trying to only play the sound when slot 35 contains cobblestone, which has an item ID of 4. GETSLOTITEM returns the id of the item found in said slot, so what am I missing here?
1) Cobblestone does not have an item ID of 4, not since minecraft 1.7 (which was like 5 years ago now)
The id is now 'minecraft:cobblestone' or just 'cobblestone'
2) The lexer/parser in this mod is handmade and rather simplistic - it assumes you are giving it a simple sequence of commands, it doesn't build an AST.
So the command IF(GETSLOTITEM(35,&idvar) == cobblestone); is interpreted as a simple string comparison, which is never true
What you want instead is either
GETSLOTITEM(35,&idvar)
IF(&idvar == cobblestone)
or
&idvar = GETSLOTITEM(35); // new return-value syntax, available since
IF(&idvar == cobblestone)
addendum) A tip for any type of coding
When your program doesn't work, you need to forget / test ALL of your assumptions - the best way to do that is to work in small steps, implementing the simplest feature that gets you closer to the end goal.
For example, this is how i would build up the script
// Test Log first because having some visible output is always useful for debugging
Log(true) // works
// Test GetSlotItem
GetSlotItem(35,&id)
Log(&id) // Logs &id, how do i get the value?
GetSlotItem(35,&id)
Log(%&id%) // Logs cobblestone (oh, didn't expect that, okay, will keep it in mind)
// Test the IF statement
GetSlotItem(35,&id)
Log(%&id%)
IF(&id == cobblestone) // Seems to work so far, now let's try removing logs and simplifying
Log(true)
ELSE
Log(false)
ENDIF
// Test nesting
IF(GetSlotItem(35,&id) == cobblestone); // Only change was the indroduction of nesting - i guess nesting doesn't work, revert to previous
Log(true)
ELSE
Log(false)
ENDIF
'Cause tomorrow spring is here
Thank you so much for your help, you've gotten me much farther. My code now looks like this:
Not surprisingly, when I change the IF statement to: IF(&id == "air"); the code executes properly and actually plays the sound.
I can't figure out why slot 35 is always returning air. Here's a screenshot demonstrating the problem:
Are you running the script when your inventory is actually open?
'Cause tomorrow spring is here
No. The hotkey I've set doesn't execute the file if I press it while the inventory is open. Is there a way to let the code know to check the inventory regardless?
I'm just trying to make a basic "notification" script that works with a cobblestone generator. The idea is that it mines automatically, and when the inventory fills up entirely, it'll give me a noise which lets me know to empty it.
In my testing, slot 35 fills up last. Hotbar first, then top-down left-right in the inventory. If it can't check the inventory slots unless it's open, it can't mine at the same time, and therefore isn't automatic.
When your inventory isn't open, it doesn't exist - there is no slot 35 then
Some options:
Periodically open and close the inventory to check
Mine until hotbar is full - shift click into inventory - repeat
Use a hopper or similar to eliminate the need to pick up items in the first place
'Cause tomorrow spring is here
I'm not sure how to word this, but maybe someone out there has some insite.
I'm having trouble with a menu type script. The server I play on has CBX or Crafbook Extra. Where you can place signs with various text to do certain tasks. such as Make a door(out of blocks not the door block), or bridge, etc... you can pick a material for some of these signs. HOWEVER, I'm trying to make a menu where I select the type of sign I want to create. then the script selects the correct sign to ask questions about, and asks "$$[[SET BLOCK ID,ALREADY SET]]" asking what material I want to use. I DONT want it to ask me for a material if I select a sign that doesn't require a material. such as a LIFT sign. However, from what I can gather, the limitations of macromod make it so that the $$i:d command is read BEFORE the rest of the script runs. Which means, if $$i:d is in the scritp, its going to get executed before the body of the script even runs. I tried having a second script execute but that didn't get me much farther, as it doesn't seem to execute the $$i:d command after the initial script has started. maybe theirs a way to do this with a conditional macro? idk. Or maybe i'm not doing the Exec(someotherfile.txt) correctly.
Links to the CBX sign wiki
CBX DOOR https://cbx.fandom.com/wiki/MCX208
CBX BRIDGE https://cbx.fandom.com/wiki/MCX207
Attaching some code to review.
placesign3.txt //Sign Menu Script.
For example, If i run a main MENU script to ask if the block ID is already set or not. and depending on which answer it gives, executes a second script. that either runs the main scritp "placesign3" OR if i Want to enter a new material, runs a script that sets the material in a Global var. "placesignmaterial". But this doenst work the way i expect. If i run the placesignmaterial.txt file first. it asks for the material. if it is executed by another script. it fails to ask me for the material.
placesignMENU.txt
//RUNS first
//MENU script. Asks if the block id has been set or not.
&doormaterial = "DOOR Material, BLOCK ID?";
PROMPT(&doormaterial,"$$[[SET BLOCK ID,ALREADY SET]]",%&doormaterialprompt%,true);
IF((%&doormaterial% = "SET BLOCK ID"));
EXEC(placesignmaterial.txt);
STOP;
ELSEIF((%&doormaterial% = "ALREADY SET"));
EXEC(placesign3.txt);
ENDIF;
STOP;
placesignmaterial.txt
//RUNS second
//ASKS what material u want using i:d, then sets the material var.
SPLIT(":",$$i:d,&blockidmatrix[]); //splits i:d into a matrix so i can seperate the ID.
//THE PROBLEM is that if this script is executed from ANOTHER scrtip. $i:d doesnt ask for the material.
SET(@&blockid,%&blockidmatrix[0]%); //unnessasary right now.
SET(@#blockidcolor,%&blockidmatrix[1]%); //sets block ID color.
@#signblockmaterial = ITEMID(%&blockidmatrix[0]%); //sets block material var.
LOG(IDname:COLOR=%@&blockid%:%@#blockidcolor% - ID#:%@#signblockmaterial%);
EXEC(placesign3.txt); //Execute main script placesign3
STOP
I hope this makes sense. any help would be appreciated. or Ideas on how to go about solving my problem a different way.
First of all - props for the good analysis
You are correct that these "preprocessor directives" (iirc) are evaluated before the script is run, with no understanding of the surrounding context
There is an exception though - i'm not sure how it works, but the PROMPT command can be used to collect values during runtime
Signature: PROMPT(<&target>,<paramstring>,[prompt],[override],[default])
'Cause tomorrow spring is here
In addition to what Mart said, I generally recommend to only use prompt in scripts because the highlighted problem is exactly the use case for it and not using normal parameter strings will result in the code being easier to read and prevents issues. Using parameter strings is better to only be used in direct commands (without script)
MART, thank you! you genius you lol. I re-worked my script and its working wonderfully now. going to post it here so all can use and see.
V8.3.2 -fixed bridge; fixed material not asking correctly.
//Maybe Check to see if we even have a sign in the inventory kinda important.
//some unused code is for future script expansion.
&question = "TYPE OF SIGN";
PROMPT(&signname,"$$[[LIFT,DOOR,BRIDGE,TRANSMITTER/RECIEVER]]",%&question%,true); //Initial prompt to determine type of sign to use.
//DOOR SIGN ****************** ****************** ****************** ******************
//DOOR SIGN ****************** ****************** ****************** ******************
IF(%&signname%="DOOR");
&doormaterialprompt = "DOOR Material, BLOCK ID?";
PROMPT(&doormaterial,"$$[[SET BLOCK ID,ALREADY SET]]",%&doormaterialprompt%,true); //This sign uses materials, choose new block ID?
IF(%&doormaterial%="SET BLOCK ID");
&question = "TYPE OF MATERIAL";
PROMPT(&blockid,"$$i:d",%&question%,true); //Initial prompt to determine type of material to use.
SPLIT(":",%&blockid%,&blockidmatrix[]); //splits i:d into a matrix so i can seperate the ID.
//SET(&blockid,%&blockidmatrix[0]%); //unnessasary right now.
SET(#blockidcolor,%&blockidmatrix[1]%); //sets block ID color.
#signblockmaterial = ITEMID(%&blockidmatrix[0]%); //sets block material var.
ENDIF;
&doorwidthprompt = "Door Width? 1-11";
PROMPT(#doorwidth,"$$[[1,2,3,4,5,6,7,8,9,10,11]]",%&doorwidthprompt%,true); //How wide will the door be?
&doorheightprompt = "Door Height? 1-30";
PROMPT(&doorheight,"$$[[1,2,3,4,5,6,7,8,9,10,11,?]]",%&doorheightprompt%,true); //How Tall will the door be?
&dooroffsetprompt = "Door Vertical Offset? (-10)-10";
PROMPT(&dooroffset,"$$[[1,2,3,4,5,6,7,8,9,10,?]]",%&dooroffsetprompt%,true); //Offset from Sign block?
IF(%&doorheight%="?");
&howwide = "How TALL should the door be?";
PROMPT(#doorheight,"$$?",%&howwide%,true); //Prompt for How tall the door should be.
IF((%#doorheight% >= 1) && (%#doorheight% <= 30)); //Verify the height is within parameters.
ELSE;
LOG(ERROR out of parameters try again.);
STOP;
ENDIF;
ELSE;
SET(#doorheight,%&doorheight%); //set the door height var.
ENDIF;
IF(%&dooroffset%="?");
&howoffset = "Vertical OFFSET? (-10)-10";
PROMPT(#dooroffset,"$$?",%&howoffset%,true); //Prompt for the doors offset from the sign block.
IF((%#dooroffset% >= -10) && (%#dooroffset% <= 10)); //Verify the offset is within parameters.
ELSE;
LOG(ERROR out of parameters try again.);
STOP;
ENDIF;
ELSE;
SET(#dooroffset,%&dooroffset%); //set dooroffset var.
ENDIF;
KEYDOWN(42); //must use shift to place on a chest or on another sign. which is why this command is here.
WAIT(5t); //wait inserted for lag issues.
PLACESIGN(,[MCX208],%#signblockmaterial%:%#blockidcolor%,%#doorwidth%:%#doorheight%:%#dooroffset%); //IF using the MENU, and material txt files.
KEYUP(42); //wait inserted for lag issues.
//DOOR SIGN ****************** ****************** ****************** ******************
//DOOR SIGN ****************** ****************** ****************** ******************
//BRIDGE SIGN ****************** ****************** ****************** ******************
//BRIDGE SIGN ****************** ****************** ****************** ******************
//I'm not going to comment the Bridge sign code as its very similear to the DOOR sign.
ELSEIF(%&signname%="BRIDGE");
&bridgematerial = "Bridge Material, BLOCK ID?";
PROMPT(&bridgematerial,"$$[[SET BLOCK ID,ALREADY SET]]",%&doormaterialprompt%,true);
IF(%&bridgematerial%="SET BLOCK ID");
&question = "TYPE OF MATERIAL";
PROMPT(&blockid,"$$i:d",%&question%,true); //Initial prompt to determine type of material to use.
SPLIT(":",%&blockid%,&blockidmatrix[]); //splits i:d into a matrix so i can seperate the ID.
SET(&blockid,%&blockidmatrix[0]%); //unnessasary right now.
SET(#blockidcolor,%&blockidmatrix[1]%); //sets block ID color.
#signblockmaterial = ITEMID(%&blockidmatrix[0]%); //sets block material var.
ENDIF;
&bridgewidthprompt = "Bridge Width? 1-11";
PROMPT(#bridgewidth,"$$[[1,2,3,4,5,6,7,8,9,10,11]]",%&bridgewidthprompt%,true);
&bridgelengthprompt = "Bridge Length? 1-30";
PROMPT(&bridgelength,"$$[[1,2,3,4,5,6,7,8,9,10,11,30,?]]",%&bridgelengthprompt%,true);
&bridgeoffsetprompt = "Bridge Vertical Offset? (-10)-10";
PROMPT(&bridgeoffset,"$$[[-1,1,2,3,4,5,6,7,8,9,10,?]]",%&bridgeoffsetprompt%,true);
IF(%&bridgelength%="?");
&howlong = "How LONG should the bridge be?";
PROMPT(#bridgelength,"$$?",%&howlong%,true);
IF((%#bridgelength% >= 1) && (%#bridgelength% <= 30));
ELSE;
LOG(ERROR out of parameters try again.);
STOP;
ENDIF;
ELSE;
SET(#bridgelength,%&bridgelength%);
ENDIF;
IF(%&bridgeoffset%="?");
&howoffset = "Vertical OFFSET? (-10)-10";
PROMPT(#bridgeoffset,"$$?",%&howoffset%,true);
IF((%#bridgeoffset% >= -10) && (%#bridgeoffset% <= 10));
ELSE;
LOG(ERROR out of parameters try again.);
STOP;
ENDIF;
ELSE;
SET(#bridgeoffset,%&bridgeoffset%);
ENDIF;
KEYDOWN(42); //must use shift to place on a chest or on another sign. which is why this command is here.
WAIT(5t); //wait inserted for lag issues.
PLACESIGN(,[MCX207],%#signblockmaterial%:%#blockidcolor%,%#bridgewidth%:%#bridgelength%:%#bridgeoffset%); //Bridge
KEYUP(42); //wait inserted for lag issues.
//BRIDGE SIGN ****************** ****************** ****************** ******************
//BRIDGE SIGN ****************** ****************** ****************** ******************
//LIFT SIGN ****************** ****************** ****************** ******************
//LIFT SIGN ****************** ****************** ****************** ******************
ELSEIF(%&signname%="LIFT");
&liftcurrentfloorprompt = "Current floor name, 0-15Char";
PROMPT(&liftcurrentfloor,"$$?",%&liftcurrentfloorprompt%,true); // Current floor name, this will show up in chat when you use a lift to this floor.
&liftdirectionprompt = "up or down when right clicking the sign?";
PROMPT(&liftdirection,"$$[[Lift,Lift Up,Lift Down]]",%&liftdirectionprompt%,true); //Lift Sign Text, what do you want the lift to do.
&liftanytext1 = "Any text, eg.where the lift goes to, 0-15Char";
PROMPT(&liftanytext1,"$$?",%&liftanytext1%,true); //Line 3 any text
&liftanytext2 = "Any text,can be any text wanted on the sign, 0-15Char";
PROMPT(&liftanytext2,"$$?",%&liftanytext2%,true); //Line 4 any text
IFMATCHES(%&liftcurrentfloor%,"^.{0,15}$",); //Line 1, Filter to be sure entered text is within sign parameters.
//LOG(MATCH!!!);
ELSE;
LOG(ERROR out of parameters try again.);
STOP;
ENDIF;
IFMATCHES(%&liftanytext1%,"^.{0,15}$",); //Line 3, Filter to be sure entered text is within sign parameters.
//LOG(MATCH!!!);
ELSE;
LOG(ERROR out of parameters try again.);
STOP;
ENDIF;
IFMATCHES(%&liftanytext2%,"^.{0,15}$",); //Line 4, Filter to be sure entered text is within sign parameters.
//LOG(MATCH!!!);
ELSE;
LOG(ERROR out of parameters try again.);
STOP;
ENDIF;
KEYDOWN(42); //must use shift to place on a chest or on another sign. which is why this command is here.
WAIT(5t); //wait inserted for lag issues.
PLACESIGN(%&liftcurrentfloor%,[%&liftdirection%],%&liftanytext1%,%&liftanytext2%); //place Craftbook Extra Lift Sign.
KEYUP(42); //wait inserted for lag issues.
//LIFT SIGN ****************** ****************** ****************** ******************
//LIFT SIGN ****************** ****************** ****************** ******************
//TRANSMITTER SIGN ****************** ****************** ****************** ******************
//TRANSMITTER SIGN ****************** ****************** ****************** ******************
ELSEIF(%&signname%="TRANSMITTER/RECIEVER");
&transmitorrecieveprompt = "Transmit or Recieve sign?";
PROMPT(&transmitorrecieve,"$$[[Transmitter,Reciever]]",%&transmitorrecieveprompt%,true);
&transmitterbandprompt = "Transmitter/Reciever BAND ID?";
PROMPT(&transmitterbandset,"$$[[SET BAND,ALREADY SET,Previous BANDS BELOW,%&transmitterband0%,%&transmitterband1%,%&transmitterband2%,%&transmitterband3%]]",%&transmitterbandprompt%,true);
IF(%&transmitorrecieve%="Transmitter"); //Line 2, Filter to be sure entered text is within sign parameters.
SET(&transmittertype,"MC1110");
ELSEIF(%&transmitorrecieve%="Reciever");
SET(&transmittertype,"MC0111");
ELSE;
LOG(ERROR out of parameters try again.);
STOP;
ENDIF;
IF(%&transmitterbandset%="SET BAND");
&bandprompt = "Band Name for Transmitter Linking, 0-15Char";
PROMPT(&transmitterband,"$$?",%&bandprompt%,true);
IFMATCHES(%&transmitterband%,"\$",); //Line 3, Filter to be sure entered text is within sign parameters.
LOG(Using $ BREAKS the script.);
UNSET(&transmitterband);
SET(&transmitterband,%&transmitterband0%);
ENDIF;
&transmitterbandarray[4]="%&transmitterbandarray[3]%";
&transmitterbandarray[3]="%&transmitterbandarray[2]%";
&transmitterbandarray[2]="%&transmitterbandarray[1]%";
&transmitterbandarray[1]="%&transmitterbandarray[0]%";
&transmitterbandarray[0]="%&transmitterband%";
SET(&transmitterband0,%&transmitterbandarray[0]%);
SET(&transmitterband1,%&transmitterbandarray[1]%);
SET(&transmitterband2,%&transmitterbandarray[2]%);
SET(&transmitterband3,%&transmitterbandarray[3]%);
SET(&transmitterband4,%&transmitterbandarray[4]%);
ELSEIF(%&transmitterbandset%="ALREADY SET");
ELSEIF(%&transmitterbandset%=%&transmitterband0%);
&transmitterband=%&transmitterband0%;
ELSEIF(%&transmitterbandset%=%&transmitterband1%);
&transmitterband=%&transmitterband1%;
ELSEIF(%&transmitterbandset%=%&transmitterband2%);
&transmitterband=%&transmitterband2%;
ELSEIF(%&transmitterbandset%=%&transmitterband3%);
&transmitterband=%&transmitterband3%;
ELSE;
LOG(NO MATCH!! ERROR out of parameters try again.);
STOP;
ENDIF;
IFMATCHES(%&transmitterband%,"^.{0,15}$",);//Line 3, Filter to be sure entered text is within sign parameters.
ELSE;
LOG(ERROR out of parameters try again.);
STOP;
ENDIF;
IFMATCHES(%&transmitteranytext4%,"^.{0,15}$",);//Line 4, Filter to be sure entered text is within sign parameters.
ELSE;
LOG(ERROR out of parameters try again.);
STOP;
ENDIF;
KEYDOWN(42);
WAIT(5t); //wait inserted for lag issues.
PLACESIGN(,[%&transmittertype%],%&transmitterband%,%&transmitteranytext4%); //place Craftbook Extra Tramsmitter Sign.
KEYUP(42);
//TRANSMITTER SIGN ****************** ****************** ****************** ******************
//TRANSMITTER SIGN ****************** ****************** ****************** ******************
ELSE;
LOG(I do Nothing Bruah);
ENDIF;
STOP
Hey, i hope someone can help me with my macro. I tried for days now, but it doesn't work.
First i will tell you what i want to achieve.
So i want a macro that will start sprinting forward and start mining cobble until the inventory is full. After that, the account should drop the cobblestone out of the inventory and repeat running/mining and dropping without pressing the macro key again it should work afk.
Here is what i got so far. I got 3 scripts that contain:
run.txt
$${keydown(sprint);keydown(forward);}$$
attack.txt
$${TOGGLE(autoclick);DO;KEY(attack);WHILE(autoclick)}$$
drop.txt
$${GUI(inventory);FOR(#s,9,35);GETSLOTITEM(%#s%,#i);IF(#i=Cobblestone);SLOTCLICK(%#s%);SLOTCLICK(-999);ENDIF;NEXT;GUI}$$
Now i bind it to a key with:
$${$$<run.txt>}$$ $${$$<attack.txt>}$$ $${wait(50ms)}$$ $${$$<attack.txt>}$$
Like this it will run and start attacking. I have attack doubled because after i open the inventory with the drop.txt the account need to press the attack button again. I got no solution for the drop.txt that it triggers when the inventory is full. And overall this is a really bad solution i think.
I hope you can help me to get a working script because im to bad to get it right
It might be easier to start with the entire script in one file, because that's how the mod eventually runs the code - just like it was copy pasted together
Figure out a basic high level overview, because you can only do one thing at a time
I'm guessing it should go something like
Once you have the high level idea of what you want to make, start making and testing it in individual pieces
For example, try to just get it to run first
Then to run and mine
Then in a separate script try to figure out how to detect if the inventory is full
Then combine them
Then in a separate script try to figure out how to drop all the items in your inv
Then combine them
'Cause tomorrow spring is here
Is there any way to make a script to look in the direction of a coordinate and walk to that position then do the same for a chain of different coordinates using GETID and CALCYAWTO? If anyone could make me a script that does this and tell me how to input custom x and z values I'd be eternally grateful.
Well the core of it is just Look(pitch,yaw) and Keydown(forward)
But depending on how smart you want it to be it can be anything from easy to practically impossible
Consider for example the following potential obstacles
Difficult
Hostile players
Mobs
Fatal drops (holes in the ground - ravines)
Unavoidable drops (steep mountain side)
Unavoidable pillaring (steep mountain side again)
Doors
Unavoidable mining (coordinates accidentally happen to be inside a mountain or w\e)
Potentially doable:
Turns (A house is in the way, have to go around it)
Doable:
Jumps: (The terrain gradually changes height, have to jump up 1 block ledges)
So it all depends on the context of what you want this for
'Cause tomorrow spring is here
I want it to walk to a specific inputted coordinate, then walk to a chain of different specific coordinates. Ideally also able to jump over singular blocks. That's it.
Turns out i already had something like that - had to tweak it a bit but this should get you started
(The entire thing goes in a file, it looks like markdown with code snippets (well, it is), but it works just fine for the mod too because it ignores all the lines it doesn't understand)
'Cause tomorrow spring is here
Sorry about the late response, I was at a baptism today.
You're a god, thank you so much! I'll try the script and get back to you afterwards in case I encounter any problems.
Alright, I've tried it out and I have a question. How do you input several coordinates to travel to after one another? For example, first coordinate 1, then 2, then 3 etc. Also, let me specify what I want the script to do more specifically so you have a better idea of what I'm trying to do; I want to set up a loop for the character, where it walks from coordinate to coordinate, eventually returning to the start position and then repeating the loop. At every coordinate inputted, the character will left click once, wait 5 seconds and continue toward the next coordinate and repeating the action. The code might look something like this (very simplified and unprofessional):
1. Go to coordinate 1
2. Left click
3. Wait 5 sec
4. Go to coordinate 2
5. Left click
6. Wait 5 sec
7. Go to coordinate 3
8. Left click
9. Wait 5 sec
10. Repeat
In practice, more coordinates would be needed, forming a kind of circle, but I believe this demonstrates my idea adequately. This is probably what your script does with a couple more steps added, but I think I might need an explanation of how to work it and input the variables as I'm not exactly experienced in coding... Sorry if this is too much to ask. I do think I could make something workable after hours of trial and error, but I figured it's probably easier and less time consuming if you just explain how it works.
Again, thanks so much for responding and giving me a script almost immediately. I am as stated previously, eternally grateful.
This example already has two coordinates right at the start there, 10,10 and 10,0
Let me remove the extra stuff and leave only the script and commends, hopefully it'll make more sense then
edit: A lot of the complexity comes from the fact that i tried to combine 2d and 3d logic
Do you want height to matter? or only the x and z?
'Cause tomorrow spring is here
Height shouldn't matter except for the single block jumps, so just x and z is probably fine.