since when i press the key it doesnt stop when the cord is like 100,5
edit: i read your edit but uhmm isnt it possible to set a integer to a string?
edit2: or is there something you can think of that sets me in the middle of a block?
I didn't mean that, converting the integer to a string is what the % signs do, but the original ZPOS variable is an integer, so it will never get .5 at all.
ive got it working now
the macro is on numpad 1 button
$${
ECHO(/region addmember mytown $$[name])
Set(@#timer,$$[Time])
DO($$[Time])
WAIT(1)
Dec(@#timer)
LOOP
ECHO(/region removemember mytown $$[name])
}$$
but now ... is it possible that if the macro is running and i press numpad 1 again that is does something like LOG("$$[name] has %timer% seconds left")
maybe it becomes clear if i tell you that i need this to rent out my farm
Unfortunately you can't put it on the same key because it will still prompt you for the parameters, but you can put a kind of "status check" for your timer on another key, you just need to modify your original script to store the player name in a shared variable.
How do I use PICKEDUPITEM and JOINEDPLAYER, etc...?
I can't seem to get them to work.
They are available like normal global variables, but only within the events which supply them, so for example JOINEDPLAYER is available inside the onPlayerJoined event.
They are available like normal global variables, but only within the events which supply them, so for example JOINEDPLAYER is available inside the onPlayerJoined event.
I mean how do I use them in context? Like what to I put before them to call them?
I mean how do I use them in context? Like what to I put before them to call them?
Well it depends what you want to do with them really. Like any variable you can use them in conditionals or as part of a string or as a subject for MATCH, the only difference is that they're only available inside the event handler because they are specific to the event. If you want to use them elsewhere you can assign the value to another shared variable using SET, for example to store the last joined player you could put the following inside an onPlayerJoined handler:
$${SET(@&lastjoinedplayer,%JOINEDPLAYER%);}$$
You could then use that elsewhere in other macros. For most simple things it's generally neater to put your script in the handler itself, but again it really just depends on what you want to do.
I'm trying to do KEYDOWN( ) for left mouse. I've tried
-100
MOUSE1
BUTTON0
BUTTON1
and none of them work. I'd rather not do a while loop with KEY(attack)
Thanks in advance.
All of the valid arguments for the KEY, KEYDOWN, KEYUP and TOGGLEKEY are listed in the readme.txt so that's the best place to check.
It's important to realise that these functions don't actually send keyboard commands (you can inject raw keyboard events using the PRESS and TYPE commands instead), they actually activate the underlying binding directly. Key bindings in minecraft are a single entity but they are used by the Minecraft code in two different ways, depending on the function.
Some binds are "stateful" and the code only checks if the key is pressed or not pressed at any given time, these are the movement keys for the most part. Other binds are "momentary" and only care for key events (eg. they check for the action of a key being depressed or released) and this is the chat, menu, etc. Some binds are kind of a hybrid and make both checks (they need the eventand the state), the USE and ATTACK binds fall into this last category.
This isn't my nomination, this is just how the Minecraft code is written and works internally, I suspect the different handling is for legacy reasons. To activate ATTACK or USE it is necessary to send the momentary event for every tick that you wish the bind to be active, this is achieved using a loop:
$${DO;KEY(attack);LOOP;}$$
Currently there's no way to send raw mouse events in the mod, the injection code only deals with the keyboard buffer at the moment so you can't actually manipulate the mouse event buffer with script commands. If there's a call for it then I will add it in though, but bear in mind that the injection only works on a per-tick basis as well so you'd still need a loop to inject the required events.
To clarify, KEY, KEYDOWN, etc. do accept raw keycodes as arguments, but this still only activates the underlying binding and doesn't manipulate the buffers in any way. This is to support the activation of mod-added bindings which otherwise would be inaccessible (since I have no way of knowing the "friendly name" for the binding for mod keys, it's hard coded for the default minecraft onees).
- onPlayerEnterChunks: Fires when a player enters loaded chuncks. includes variables PLAYER, PLAYERX, PLAYERY, PLAYERZ, etc.
- List of players in loaded chunks (accessible in scripts) including there locations.
- onPlayerLeaveChuncks: opposite of the above.
- Any other ways to detect things about other players within loaded chuncks.
- Like a way to check there armor/items
- And maybe ways to detect there actions, what they are interacting with.
- Basically a way to grab any data the server gives on other players
- onPlayerEnterChunks: Fires when a player enters loaded chuncks. includes variables PLAYER, PLAYERX, PLAYERY, PLAYERZ, etc.
- List of players in loaded chunks (accessible in scripts) including there locations.
- onPlayerLeaveChuncks: opposite of the above.
- Any other ways to detect things about other players within loaded chuncks.
- Like a way to check there armor/items
- And maybe ways to detect there actions, what they are interacting with.
- Basically a way to grab any data the server gives on other players
Are you asking for an event when a player entity is spawned on the client? That's very definitely doable. Unfortunately the server replicates pretty much bugger-all about the players besides their name, location, armour and current inventory item (essentially the things required to see them). Things like what they are interacting with are only visible to you as the effects of their actions (eg. opening a chest, damaging another mob).
I've been playing with a thing for enchantments which is basically a type of iterator, so I'll see whether this setup works for loaded players as well.
I have /md chicken|/md baby set to CTRL+numberpad9
I want just /md bound to numberpad9 without CTRL, can I do this?
You can achieve this pretty simply by replacing the raw bind with a simple script function which will "choose" whether to send one command or another, so remove the CTRL modifier from your binding and replace it with the following:
$${IIF(~CTRL,"/md chicken|/md baby","/md")}$$
This essentially says, if CTRL is held down, send the commands "/md chicken|/md baby", if CTRL is not down send "/md" instead. You can replace the condition with anything you like and also change the commands to suit your needs.
You can achieve this pretty simply by replacing the raw bind with a simple script function which will "choose" whether to send one command or another, so remove the CTRL modifier from your binding and replace it with the following:
$${IIF(~CTRL,"/md chicken|/md baby","/md")}$$
This essentially says, if CTRL is held down, send the commands "/md chicken|/md baby", if CTRL is not down send "/md" instead. You can replace the condition with anything you like and also change the commands to suit your needs.
So I can replace this with my commands/sayings to make binds as in improved chat?
To make for instance "h" do /home, ctrl+h do /home 2, LSHIFT do /home 3 and ctrl+LSHIFT+h do /home 4?
Rollback Post to RevisionRollBack
I began minecraft ~July 7 2011 1.7.3 Beta
My username used to be Creative_Dalek but is now Dalek since 2/4/2015
So I can replace this with my commands/sayings to make binds as in improved chat?
To make for instance "h" do /home, ctrl+h do /home 2, LSHIFT do /home 3 and ctrl+LSHIFT+h do /home 4?
Well yes, just chain the IF clauses together to make as many combinations as you like. You can even use other keys as modifiers because the condition you enter is totally up to you. For example:
I have a question as well. I'm kinda tired of people asking stuff on my server (a bit harsh, but w/e :P) and I want to send the message "Google it!" whenever another player sends a message starting with the word "How". Is this possible?
I wanted to make a script which would run continually after pressing a key and if my health went below 5 and a half hearts it would wait until health was above 11, I just used WAIT(16) but I think a (DO; ... While statement with WAIT(1) and a LOOP) might do it, before performing the rest of the script.
I have that but it doesn't work, could you please help me and say what I've done wrong with it, I love this mod by the way ;D
Well there's a few mistakes in the above script so you can try fixing those and see how you get on:
Variables are case sensitive, globals are uppercase and user variables are lower case, so to compare the HEALTH global it needs to be upper case
Whilst it shouldn't stop anything working, the DO(1) doesn't really do anything since looping only once doesn't behave any differently to just having the code.
You have some stack corruption because the LOOP and ENDIF are mixed up, so this script will terminate with an uncollapsed stack error
Is it possible to use this to make items craft by pressing a key. Like if I want to craft a wooden stair, i just press G inside the crafting box and the things that is used to make it will pop up inside the crating box? If so could anyone help me with it?
I have a question as well. I'm kinda tired of people asking stuff on my server (a bit harsh, but w/e ) and I want to send the message "Google it!" whenever another player sends a message starting with the word "How". Is this possible?
Yes, but it depends on the chat format used by your server. In a nutshell, you can put a script into the onChat event handler which can examine the chat and respond appropriately, you just need to be aware that the chat message is the whole string received from the server and may contain the player name etc.
As a simple example, here's an inbound chat message (vanilla style) that we'd like to match:
<NewbiePlayer> How do I herp derp? I'm too derp to google it.
To match this we can match the word "how" when it immediately follows a close angle-bracket:
Obviously this will need to be adapted based on the format of messages in your server, but for the most part that's it. Just use IFMATCHES to check the chat for the phrase you want.
Obviously you can type all of the above into the onChat macro itself, or more often it's useful to put the script into a file for more convenient editing. If you put the above script into a file called "google.txt", then you can include it in the onChat handler by just typing $$<google.txt> as the macro, and the file will be included.
Thanks! This script is great, but would there be a way to make it instead of waiting for 16 seconds, waiting until HEALTH = 20 that would work far better.
Obviously this will need to be adapted based on the format of messages in your server, but for the most part that's it. Just use IFMATCHES to check the chat for the phrase you want.
Okay, I got it working on my vanilla test server, but the one I'm playing on uses towny chat and whatnot. Looks something like this:
Are you asking for an event when a player entity is spawned on the client? That's very definitely doable. Unfortunately the server replicates pretty much bugger-all about the players besides their name, location, armour and current inventory item (essentially the things required to see them). Things like what they are interacting with are only visible to you as the effects of their actions (eg. opening a chest, damaging another mob).
Exactly, a way to access any data about other player entities. It would also be nice if we could get that information in any script, not just events. GETENTITYDATA('nameOfPlayer', returnVar);
I was also thinking about a way to render shapes in the world. So we could for instance make colored circles pop up wherever we want them. Use them like way points, or markers of some kind.
So... i made a quick macro for on durability change.
$${IF(DURABILITY < 2);LOG("This item has only %DURABILITY% use left!");ELSEIF(DURABILITY < 11);LOG("This item only has %DURABILITY% uses left!");ENDIF;}$$
But I cant get it to work in a txt script for the life of me. Can anyone help?
Also, would it be possible to add something like "HELMET DURABILITY" and "BOOT DURABILTY"? OnArmourChange was great when armor taking damage reduced your armor level, but now it only changes when armor breaks, which is somewhat useless.
I didn't mean that, converting the integer to a string is what the % signs do, but the original ZPOS variable is an integer, so it will never get .5 at all.
Yes, will do.
You need a WAIT in there just before the DEC otherwise the timeout will be in ticks, which I doubt is what you want.
Like I said, it needs a WAIT in there before the DEC, if you want the timeout in seconds then use WAIT(1);
I can't seem to get them to work.
Unfortunately you can't put it on the same key because it will still prompt you for the parameters, but you can put a kind of "status check" for your timer on another key, you just need to modify your original script to store the player name in a shared variable.
Your original script, modified
Then on another key
Or alternatively, to calculate the minutes as well:
They are available like normal global variables, but only within the events which supply them, so for example JOINEDPLAYER is available inside the onPlayerJoined event.
I mean how do I use them in context? Like what to I put before them to call them?
I'm trying to do KEYDOWN( ) for left mouse. I've tried
-100
MOUSE1
BUTTON0
BUTTON1
and none of them work. I'd rather not do a while loop with KEY(attack)
Thanks in advance.
Well it depends what you want to do with them really. Like any variable you can use them in conditionals or as part of a string or as a subject for MATCH, the only difference is that they're only available inside the event handler because they are specific to the event. If you want to use them elsewhere you can assign the value to another shared variable using SET, for example to store the last joined player you could put the following inside an onPlayerJoined handler:
You could then use that elsewhere in other macros. For most simple things it's generally neater to put your script in the handler itself, but again it really just depends on what you want to do.
All of the valid arguments for the KEY, KEYDOWN, KEYUP and TOGGLEKEY are listed in the readme.txt so that's the best place to check.
It's important to realise that these functions don't actually send keyboard commands (you can inject raw keyboard events using the PRESS and TYPE commands instead), they actually activate the underlying binding directly. Key bindings in minecraft are a single entity but they are used by the Minecraft code in two different ways, depending on the function.
Some binds are "stateful" and the code only checks if the key is pressed or not pressed at any given time, these are the movement keys for the most part. Other binds are "momentary" and only care for key events (eg. they check for the action of a key being depressed or released) and this is the chat, menu, etc. Some binds are kind of a hybrid and make both checks (they need the event and the state), the USE and ATTACK binds fall into this last category.
This isn't my nomination, this is just how the Minecraft code is written and works internally, I suspect the different handling is for legacy reasons. To activate ATTACK or USE it is necessary to send the momentary event for every tick that you wish the bind to be active, this is achieved using a loop:
Currently there's no way to send raw mouse events in the mod, the injection code only deals with the keyboard buffer at the moment so you can't actually manipulate the mouse event buffer with script commands. If there's a call for it then I will add it in though, but bear in mind that the injection only works on a per-tick basis as well so you'd still need a loop to inject the required events.
To clarify, KEY, KEYDOWN, etc. do accept raw keycodes as arguments, but this still only activates the underlying binding and doesn't manipulate the buffers in any way. This is to support the activation of mod-added bindings which otherwise would be inaccessible (since I have no way of knowing the "friendly name" for the binding for mod keys, it's hard coded for the default minecraft onees).
Hope this makes sense.
- onPlayerEnterChunks: Fires when a player enters loaded chuncks. includes variables PLAYER, PLAYERX, PLAYERY, PLAYERZ, etc.
- List of players in loaded chunks (accessible in scripts) including there locations.
- onPlayerLeaveChuncks: opposite of the above.
- Any other ways to detect things about other players within loaded chuncks.
- Like a way to check there armor/items
- And maybe ways to detect there actions, what they are interacting with.
- Basically a way to grab any data the server gives on other players
Don't forget player name the most important
That would be just PLAYER
EDIT: that's already a variable, then PLAYERNAME
Bind this to the key:
Make sure that you remove the Control modifier in the macro's options.
Are you asking for an event when a player entity is spawned on the client? That's very definitely doable. Unfortunately the server replicates pretty much bugger-all about the players besides their name, location, armour and current inventory item (essentially the things required to see them). Things like what they are interacting with are only visible to you as the effects of their actions (eg. opening a chest, damaging another mob).
I've been playing with a thing for enchantments which is basically a type of iterator, so I'll see whether this setup works for loaded players as well.
You can achieve this pretty simply by replacing the raw bind with a simple script function which will "choose" whether to send one command or another, so remove the CTRL modifier from your binding and replace it with the following:
This essentially says, if CTRL is held down, send the commands "/md chicken|/md baby", if CTRL is not down send "/md" instead. You can replace the condition with anything you like and also change the commands to suit your needs.
So I can replace this with my commands/sayings to make binds as in improved chat?
To make for instance "h" do /home, ctrl+h do /home 2, LSHIFT do /home 3 and ctrl+LSHIFT+h do /home 4?
I began minecraft ~July 7 2011 1.7.3 Beta
My username used to be Creative_Dalek but is now Dalek since 2/4/2015
Well yes, just chain the IF clauses together to make as many combinations as you like. You can even use other keys as modifiers because the condition you enter is totally up to you. For example:
will do what you mentioned, or something like this will let you use the UP arrow key as a modifier:
Well there's a few mistakes in the above script so you can try fixing those and see how you get on:
Does that look more like it?
Not yet, this will be added in a future update.
Yes, but it depends on the chat format used by your server. In a nutshell, you can put a script into the onChat event handler which can examine the chat and respond appropriately, you just need to be aware that the chat message is the whole string received from the server and may contain the player name etc.
As a simple example, here's an inbound chat message (vanilla style) that we'd like to match:
To match this we can match the word "how" when it immediately follows a close angle-bracket:
onChat
Obviously this will need to be adapted based on the format of messages in your server, but for the most part that's it. Just use IFMATCHES to check the chat for the phrase you want.
Obviously you can type all of the above into the onChat macro itself, or more often it's useful to put the script into a file for more convenient editing. If you put the above script into a file called "google.txt", then you can include it in the onChat handler by just typing $$<google.txt> as the macro, and the file will be included.
Yes, replace the WAIT with
Okay, I got it working on my vanilla test server, but the one I'm playing on uses towny chat and whatnot. Looks something like this:
Any ideas?
Exactly, a way to access any data about other player entities. It would also be nice if we could get that information in any script, not just events. GETENTITYDATA('nameOfPlayer', returnVar);
I was also thinking about a way to render shapes in the world. So we could for instance make colored circles pop up wherever we want them. Use them like way points, or markers of some kind.
But I cant get it to work in a txt script for the life of me. Can anyone help?
Also, would it be possible to add something like "HELMET DURABILITY" and "BOOT DURABILTY"? OnArmourChange was great when armor taking damage reduced your armor level, but now it only changes when armor breaks, which is somewhat useless.