Key state macro is easier
Key Down: $${Set(keydown);$$<yourscript.txt>}$$
Key hold:
Key Up: $${UnSet(keydown)}$$
now you can use the boolean variable keydown to check if it's down
and yes, this still works for any key without rewriting it
You didn't tell us what the server is..., otherwise i'd gladly come on and check it out
Edit: figured it out.., oops..., on the server now and apparently i made two very obvious mistakes
I must be doing something wrong, it's not working for me....
Hey, so I tried the script, and I can run it without being inside the villager gui, but if I try to activate it while inside the villager trade gui, nothing happens.
I noticed this because I added echo()'s to be able to see what the variables are as I run it, as it wasn't working.
:
Also, when I ran it, it said the same number for slot, -1, regardless of where I put wheat in my inventory.
Any ideas on how I could make this work? How can I run scripts while in the villager gui?
Is there any possibility of a text interface connected to the standard GUI? I would really love to be able to logto text areas that I can always see.
Ninja Edit: I have a second question.
I have this code:
If(@great)
@#force=@#force+1
else
set(@great)
log(&aEnemy has been struck with great force!)
do
set(@greathit,TRUE)
set(@#forceb,@#force)
wait(30t)
if(@#force=%@#forceb%)
set(@greathit,FALSE)
endif
while(@greathit)
log(&2Great force exerted %#force% times!)
stop()
endif
In the chat filter whenever it reads a line from a plugin reading "**STRUCK WITH GREAT FORCE**", it runs EXEC(GreatForce.txt, GF) and filters the message. I can't get the final output to log when it finishes. My main goal is trying to count all the times it says the phrase and having it spit out the end result. How do I fix this or do I have to scrap it and redo it?
Secondary question: The EXEC code tends to create multiple strips of code. Whenever I try stop(), it stops all scripts and the main one. How fix?
Hey, so I tried the script, and I can run it without being inside the villager gui, but if I try to activate it while inside the villager trade gui, nothing happens.
I noticed this because I added echo()'s to be able to see what the variables are as I run it, as it wasn't working.
:
Also, when I ran it, it said the same number for slot, -1, regardless of where I put wheat in my inventory.
Any ideas on how I could make this work? How can I run scripts while in the villager gui?
You can hold down Macro Override and then press the key inside the Trade GUI.
I must be doing something wrong, it's not working for me....
Link Removed
Link Removed
Same for you, don't use exec
When you use exec you're creating a new task.., but a new task doesn't have a %CHAT% variable...
just like a macro on a random key doesn't have a %CHAT% variable
Instead, use a file include $$<file.txt>
I'm not sure where in the script you meant for me to add a Do(). I added it to the line right above the first Do() and then I added it above "//configuration", but neither seemed to stop the error. If either of those places were what you meant, then it did not work. Like I said, it is confusing for me as someone who has very little scripting experience. The ordering and placement of scripts and trying to figure out the function of said scripts is quite foreign to me.
I'll check it again..., it's a shame mcforums kills the indentation, the code really isn't that bad if you can read it as it's meant to be read
EDIT: i was wrong about the do, it was already there but i didn't realise
I can't see anything wrong with the script, and i just tested it in singleplayer; works perfectly
Are you sure you copied it all? here's the script i used
Shrib.com/Isotope22
It logs debug information to a chatarea with the control name "temp", if you're still having problems..., you could see what that says
as for the farm, i used this design so that i wouldn't have to tweak any timings; i recommend it to you as well if you want to automate it
there's water under the "walls"
Oh, that one block on the left at the end of the melons shouldn't be there..., i was testing how the script reacts to interruptions (when it's expecting melons but there aren't any), and it stopped itself fine
Thanks alot! It works pretty well!
I have another question though - Can you use GetSlot(); to find empty slots? How?
Yeah, I think an empty slot has an id of 0. If it's not zero, it might be -1 or some other negative number, but there should be a way to find that. If anything, you could make an array of non-empty slots and compare them to an array of all slots, and then just deduce which ones are empty.
Yeah, I think an empty slot has an id of 0. If it's not zero, it might be -1 or some other negative number, but there should be a way to find that. If anything, you could make an array of non-empty slots and compare them to an array of all slots, and then just deduce which ones are empty.
Just adding to this, if it's not 0 or -1, it could be -999 like the "driop item" slot
GetSlotItem(slot,#id);Log(%#id%) on an empty slot should also work to figure it out
Thanks Mart, adding the indentations seemed to fix the error. I will have to rework the farm layout, because my farm is set up like this:
D= dirt w/ melon stem /// M= melon block
MDDMMDDMMDDMMDDMMD
Yeah, that's the layout i normally use as well, but unless you want to very finely tune the delays you'll want to change your farm instead
or there is one third possibility..., but it would require jumping
orange is melon, green is stem; blue is space and black is a block
.....
So what you would do there is that every black block is one block higher than the rest, so it stops you in the right place like the design i showed..., but it also blocks the ends of melon patches
so what you would do there, is once you detect that the row of melons is over, you jump on top of that block, then turn and walk
This might be easier to adapt your farm to, if you didn't already rebuild that
let me know, i can rewrite the code to work like that (or you can try it yourself for practice, if you feel up to it)
Hey, I had a quick question for a script. I wanted to make a "safe" item remover.
I was trying to make it so upon pressing my "O" key, it would LOG to you "Are you sure you want to clean up nearby items" and then if the key was pressed again within 2 to 3 seconds it would execute a few commands.
What I have so far:
LOG(&4Are you sure you want to clean up items?);
IF(KEY_O);
ECHO(/remove item 30)
I know I'm missing the ENDIF, I'm just wondering how I can make it wait a few seconds before it terminates itself so it can check for the key being pressed again.
If that's not possible, chat input would be good, too, such as "Type 'yes' to initiate" and type yes to make it run the commands.
As well, I'm not too sure how to make it execute multiple commands at once inside the script...
Hey, I had a quick question for a script. I wanted to make a "safe" item remover.
I was trying to make it so upon pressing my "O" key, it would LOG to you "Are you sure you want to clean up nearby items" and then if the key was pressed again within 2 to 3 seconds it would execute a few commands.
IF(trigger);Log(&4Cleaning items);ECHO(/remove item 30);ENDIF
Set(trigger)
LOG(&4Are you sure you want to clean up items?);
Wait(2)
Log(&4Not cleaning items)
But i recommend using something else, such as IF($[confirm[yes,no]] = "yes")
double clicking is easy to accidentally do...,
another way would be to require HOLDING it down
Key state macro:
KeyDown: $${Set(abort);Log("&4Charging item cleanup");Wait(3);Unset(abort);Log(&4Item cleanup ready)}$$
KeyUp: $${IF(!abort);ECHO(/remove item 30);Log(&4Items cleaned);ELSE;Log(&4Item cleanup cancelled);ENDIF}$$
But i recommend using something else, such as IF($[confirm[yes,no]] = "yes")
double clicking is easy to accidentally do...,
another way would be to require HOLDING it down
Key state macro:
KeyDown: $${Set(abort);Log("&4Charging item cleanup");Wait(3);Unset(abort);Log(&4Item cleanup ready)}$$
KeyUp: $${IF(!abort);ECHO(/remove item 30);Log(&4Items cleaned);ELSE;Log(&4Item cleanup cancelled);ENDIF}$$
Oh, that makes sense. So for the confirmation of yes or no, I would implement it right after the LOG and delete the first line?
The chat one wouldn't actually send my confirmation through chat, right?
Yeah, that's the layout i normally use as well, but unless you want to very finely tune the delays you'll want to change your farm instead
or there is one third possibility..., but it would require jumping
orange is melon, green is stem; blue is space and black is a block
.....
So what you would do there is that every black block is one block higher than the rest, so it stops you in the right place like the design i showed..., but it also blocks the ends of melon patches
so what you would do there, is once you detect that the row of melons is over, you jump on top of that block, then turn and walk
This might be easier to adapt your farm to, if you didn't already rebuild that
let me know, i can rewrite the code to work like that (or you can try it yourself for practice, if you feel up to it)
I can build a new level to the farm with this setup if you want to rewrite the script. I'm not sure which would work better, but I'd be willing to find out.
Hello there, I've been trying to get a script going to readout the number of players that are currently online. However I came close but it isn't working right.
This is what I tried, it sets a counter to 0 then for each online player increases the counter by 1 and then reads the number on the counter back to me. The log("stage #") are there to help me diagnose it. The middle "ForEach(players);log("stage 2");INC(#TEST, 1)" section fires the right number of times but the counter just doesn't increase and always reads out 0. It is also slow to work out stuff (I play on a busy server) so I wonder if there is a simpler solution. Any ideas on getting this working?
Remove the NEXT, you can't end a loop you haven't started
also your variables MUST be lowercase; uppercase variables are environmental variables, not user defined
i also removed the unnecessary parameters from Inc and quotation marks, because it looks better to me
Thx it worked, also how would I do a statement that would make me disconect if it could not find something in my hot bar.
I must be doing something wrong, it's not working for me....
Link Removed
Link Removed
I noticed this because I added echo()'s to be able to see what the variables are as I run it, as it wasn't working.
:
Also, when I ran it, it said the same number for slot, -1, regardless of where I put wheat in my inventory.
Any ideas on how I could make this work? How can I run scripts while in the villager gui?
Cause It's still in the mods folder, but it's not working
Don't use EXEC use $$<file.txt>
You can hold down Macro Override and then press the key inside the Trade GUI.
Macro/Keybind mod Wiki
Same for you, don't use exec
When you use exec you're creating a new task.., but a new task doesn't have a %CHAT% variable...
just like a macro on a random key doesn't have a %CHAT% variable
Instead, use a file include $$<file.txt>
I'll check it again..., it's a shame mcforums kills the indentation, the code really isn't that bad if you can read it as it's meant to be read
EDIT: i was wrong about the do, it was already there but i didn't realise
I can't see anything wrong with the script, and i just tested it in singleplayer; works perfectly
Are you sure you copied it all? here's the script i used
Shrib.com/Isotope22
It logs debug information to a chatarea with the control name "temp", if you're still having problems..., you could see what that says
as for the farm, i used this design so that i wouldn't have to tweak any timings; i recommend it to you as well if you want to automate it
there's water under the "walls"
'Cause tomorrow spring is here
Thanks alot! It works pretty well!
I have another question though - Can you use GetSlot(); to find empty slots? How?
Yeah, I think an empty slot has an id of 0. If it's not zero, it might be -1 or some other negative number, but there should be a way to find that. If anything, you could make an array of non-empty slots and compare them to an array of all slots, and then just deduce which ones are empty.
Just adding to this, if it's not 0 or -1, it could be -999 like the "driop item" slot
GetSlotItem(slot,#id);Log(%#id%) on an empty slot should also work to figure it out
'Cause tomorrow spring is here
D= dirt w/ melon stem /// M= melon block
MDDMMDDMMDDMMDDMMD
Yeah, that's the layout i normally use as well, but unless you want to very finely tune the delays you'll want to change your farm instead
or there is one third possibility..., but it would require jumping
orange is melon, green is stem; blue is space and black is a block
.....
So what you would do there is that every black block is one block higher than the rest, so it stops you in the right place like the design i showed..., but it also blocks the ends of melon patches
so what you would do there, is once you detect that the row of melons is over, you jump on top of that block, then turn and walk
This might be easier to adapt your farm to, if you didn't already rebuild that
let me know, i can rewrite the code to work like that (or you can try it yourself for practice, if you feel up to it)
'Cause tomorrow spring is here
I was trying to make it so upon pressing my "O" key, it would LOG to you "Are you sure you want to clean up nearby items" and then if the key was pressed again within 2 to 3 seconds it would execute a few commands.
What I have so far:
I know I'm missing the ENDIF, I'm just wondering how I can make it wait a few seconds before it terminates itself so it can check for the key being pressed again.
If that's not possible, chat input would be good, too, such as "Type 'yes' to initiate" and type yes to make it run the commands.
As well, I'm not too sure how to make it execute multiple commands at once inside the script...
But i recommend using something else, such as IF($[confirm[yes,no]] = "yes")
double clicking is easy to accidentally do...,
another way would be to require HOLDING it down
Key state macro:
KeyDown: $${Set(abort);Log("&4Charging item cleanup");Wait(3);Unset(abort);Log(&4Item cleanup ready)}$$
KeyUp: $${IF(!abort);ECHO(/remove item 30);Log(&4Items cleaned);ELSE;Log(&4Item cleanup cancelled);ENDIF}$$
'Cause tomorrow spring is here
Oh, that makes sense. So for the confirmation of yes or no, I would implement it right after the LOG and delete the first line?
The chat one wouldn't actually send my confirmation through chat, right?
I can build a new level to the farm with this setup if you want to rewrite the script. I'm not sure which would work better, but I'd be willing to find out.
I'm going to assume the server you play on has chat prefixes and colored names, so:
Bind that to "onPlayerJoined" in the event macro menu.
Just delete everything and have
IF($[confirm[yes,no]] = "yes");Echo(/remove item 30);ENDIF
and ofc., parameters are not sent to chat unless you Echo() them
'Cause tomorrow spring is here
$${
set(#TEST, 0);
log("stage 1");
NEXT;
ForEach(players);
log("stage 2");
INC(#TEST, 1);
NEXT;
LOG("stage 3");
LOG(%#TEST%)
}$$
Remove the NEXT, you can't end a loop you haven't started
also your variables MUST be lowercase; uppercase variables are environmental variables, not user defined
i also removed the unnecessary parameters from Inc and quotation marks, because it looks better to me
$${
set(#test,0);
log(stage 1);
ForEach(players);
log(stage 2);
INC(#test);
NEXT;
LOG(stage 3);
LOG(%#test%)
}$$
'Cause tomorrow spring is here