06-28-2009, 07:41 AM
Here is some more information to help everyone make their own scripts on Injection. Some of this is taken from a few different guides I found when googling for information on Injection and some of it is based on my own trial and error while using Injection. Most of what I found was in Russian but I was able to recognize little bits of what I found since I've done some programming in the past. So to help everyone out I added my own explanations to try and explain what the different parts are. I hope this helps everyone out! Let me know if you have questions on any of this and I'll do my best to help you.
[SIZE="4"]Comments[/SIZE]
Throughout your scripts it's very helpful to leave yourself comments on why you're doing something since you might want to improve on a macro weeks after you first made it and you might not be able to figure out what you were doing. There are two symbols you can use when you want to make a comment. They are # and ;. Everything on the line after these symbols will be a comment and won't affect your script.
[SIZE="4"]Read-Only Properties:[/SIZE]
This is a list of your character's properties you can use in combination with other commands. I find these are most helpful when crafting. For example you would make a lightning scroll if your mana is above 50, say guards if your hits are less then 100, make a greater heal potion if you have more then 10 ginseng on you, etc.
[INDENT]UO.Life - Hit points
UO.Mana - Mana points
UO.Stamina - Stamina
UO.STR - Strength
UO.INT - Intelligence
UO.DEX - Dexterity
UO.Weight - Weight
UO.Armor - Armor
UO.Gold - Your total amount of money
UO.BM - Amount of Bloodmoss in your pack
UO.BP - Amount of Black Pearl in your pack
UO.GA - Amount of Garlic in your pack
UO.GS - Amount of Ginseng in your pack
UO.MR - Amount of Mandrake Root in your pack
UO.NS - Amount of Nightshade in your pack
UO.SA - Amount of Sulfurous Ash in your pack
UO.SS - Amount of Spider's Silk in your pack
UO.B - Amount of Bandaids in your pack
UO.AR - Amount of Arrows in your pack
UO.BT - Amount of bolts in your pack[/INDENT]
[SIZE="4"]Some Simple Commands:[/SIZE]
These are some very simple commands that I've used in the macro's I've made so far and that you can't do much without. I'll add more to this list as I get more comfortable using other commands.
[INDENT]wait (##) - this command will have your script wait ## milliseconds before continuing (1000 milliseconds is 1 second).
uo.print("text goes here") - this command will show a message in the bottom-left corner of the UO game window.
uo.say("text goes here") - this command will show a message above your character's head like when you write something and press enter ingame.
uo.cast('spell name here') - this command will give you a cursor and wait for you to select a target. When you select a target it will cast the spell you put between quotes. Make sure you write the spell exactly as is (including capital letters and spaces) or it won't work.
uo.exec("cast 'spell name here' self") - This will cast a spell on yourself instead of giving you a target and waiting for you to target yourself.
uo.exec("waittargetlast")
uo.exec("cast 'spell name here' last")
-When using these two commands together you will automatically cast a spell on your last target instead of giving you a target and waiting for you to target someone.
-uo.useskill('skill name here') - this will use whatever skill you put between quotes.Make sure you write the skill name exactly as is (including capital letters and spaces) or it won't work.[/INDENT]
Here is an example of something you can do with some of these commands. You can use either the uo.say command or the uo.print command for this. The only difference is where you will see the messages.
If you want to make a script to say guards for you make sure to use uo.say and not uo.print or else you won't call them!!
[SIZE="4"]Comparison Operators:[/SIZE]
When writing your own scripts you will most likely run into different scenarios where you want to do something based on a condition. For example you want to stop crafting items when you reach a certain weight, or you want to check if you have enough resources before you make an item. There are 3 different parts you need when making a comparison. Here is the syntax you need to use when checking a condition:
property comparison value
Here's an example of how you use this:
uo.life < 50
Here is a list of all the different comparisons you can do (they can be used on much much more then just hits).
< - hits are less then 50
> - hits are greater then 50
<= - hits are less then or equal to 50
>= - hits are greater then or equal to 50
== - hits are equal to 50
<> - hits are not equal to 50
[SIZE="4"]Boolean Logic Operators:[/SIZE]
If you want to check for more then one condition before performing an action you can use any of the following:
&& - AND - both conditions must be true to perform an action
|| - OR - one of the conditions must be true to perform an action
NOT - the condition must be false to perform an action
Here is the syntax you need to use:
property1 condition1 value1 && property1 condition2 value2
Here's an example of how you use this:
uo.life > 1 && uo.life < 100
[SIZE="4"]Decisions and Loops:[/SIZE]
Here are some different commands you can use when scripting. Most of what you do will probably include one of these commands, or maybe even a combination of these commands.
If...Then...Endif
There are a lot of different ways you can use this statement. I'll explain the different ways you can use this statement one at a time and each example will get a little more complicated.
Part 1: The first way you can use this statement is to check for one condition, and if this condition is true your script will perform a specific set of actions it ordinarily won't do. If this condition is not true, your script will continue without performing these actions. Here is the syntax you need to use:
if property<value then
...
endif
Here is an example of how you use this:
This script will print a message in the bottom-left corner of the UO game window saying what's between the quotes if you have less then 100 life.
If you want to meet more then one condition before having your script perform a certain set of actions you can use the boolean expressions I mentioned above. Here is the syntax you need to use if this is the case:
if property>value1 && property<value2 then
...
endif
Here is an example of how you use this:
This script will show a message in the bottom-left corner of the UO game window saying what's in the quotes only if the two conditions are true. If only one condition is true or neither condition is true it won't show anything.
Part 2: The next way you can use this statement will check for one condition and perform one set of actions if this condition is true and a different set of actions if this condition is not true before continuing with the rest of your script. Here is the syntax you need to use:
if property<value then
...
else
...
endif
Here is an example of how you use this:
This script will print a message in the bottom-left corner of the UO game window saying what's between the quotes depending how much life you have. As with Part 1, you can combine this with boolean expressions.
Part 3: The next way you can use this statement is to check for multiple specific conditions and perform a different set of instructions for each condition before continuing with the rest of your script. Here is the syntax you need to use:
if property<value1 then
...
endif
if property<value2 then
...
endif
Here is an example of how you use this:
This script will print a message in the bottom-left corner of the UO game window saying what's between the quotes depending how much life you have. You should notice we didn't assign a condition for when you have 100 life, so if you have 100 life nothing will be shown. Once again you can combine this with boolean expressions.
Part 4: The final way you can use this statement is to check for multiple specific conditions and perform a specific set of actions for each one, and perform another set of actions if none of these conditions are met. Here is the syntax you need to use:
if property<value1 then
...
end if
if property<value2 then
...
else
...
endif
Here is an example of how you use this:
This is a very good technique for troubleshooting since you might encounter a condition you didn't expect the first time you wrote your script and now you can give yourself some kind of warning.
[SIZE="4"]Comments[/SIZE]
Throughout your scripts it's very helpful to leave yourself comments on why you're doing something since you might want to improve on a macro weeks after you first made it and you might not be able to figure out what you were doing. There are two symbols you can use when you want to make a comment. They are # and ;. Everything on the line after these symbols will be a comment and won't affect your script.
[SIZE="4"]Read-Only Properties:[/SIZE]
This is a list of your character's properties you can use in combination with other commands. I find these are most helpful when crafting. For example you would make a lightning scroll if your mana is above 50, say guards if your hits are less then 100, make a greater heal potion if you have more then 10 ginseng on you, etc.
[INDENT]UO.Life - Hit points
UO.Mana - Mana points
UO.Stamina - Stamina
UO.STR - Strength
UO.INT - Intelligence
UO.DEX - Dexterity
UO.Weight - Weight
UO.Armor - Armor
UO.Gold - Your total amount of money
UO.BM - Amount of Bloodmoss in your pack
UO.BP - Amount of Black Pearl in your pack
UO.GA - Amount of Garlic in your pack
UO.GS - Amount of Ginseng in your pack
UO.MR - Amount of Mandrake Root in your pack
UO.NS - Amount of Nightshade in your pack
UO.SA - Amount of Sulfurous Ash in your pack
UO.SS - Amount of Spider's Silk in your pack
UO.B - Amount of Bandaids in your pack
UO.AR - Amount of Arrows in your pack
UO.BT - Amount of bolts in your pack[/INDENT]
[SIZE="4"]Some Simple Commands:[/SIZE]
These are some very simple commands that I've used in the macro's I've made so far and that you can't do much without. I'll add more to this list as I get more comfortable using other commands.
[INDENT]wait (##) - this command will have your script wait ## milliseconds before continuing (1000 milliseconds is 1 second).
uo.print("text goes here") - this command will show a message in the bottom-left corner of the UO game window.
uo.say("text goes here") - this command will show a message above your character's head like when you write something and press enter ingame.
uo.cast('spell name here') - this command will give you a cursor and wait for you to select a target. When you select a target it will cast the spell you put between quotes. Make sure you write the spell exactly as is (including capital letters and spaces) or it won't work.
uo.exec("cast 'spell name here' self") - This will cast a spell on yourself instead of giving you a target and waiting for you to target yourself.
uo.exec("waittargetlast")
uo.exec("cast 'spell name here' last")
-When using these two commands together you will automatically cast a spell on your last target instead of giving you a target and waiting for you to target someone.
-uo.useskill('skill name here') - this will use whatever skill you put between quotes.Make sure you write the skill name exactly as is (including capital letters and spaces) or it won't work.[/INDENT]
Here is an example of something you can do with some of these commands. You can use either the uo.say command or the uo.print command for this. The only difference is where you will see the messages.
PHP Code:
sub Hello()
uo.say("Hello")
wait (1000)
uo.say("How are you?")
end sub
If you want to make a script to say guards for you make sure to use uo.say and not uo.print or else you won't call them!!
[SIZE="4"]Comparison Operators:[/SIZE]
When writing your own scripts you will most likely run into different scenarios where you want to do something based on a condition. For example you want to stop crafting items when you reach a certain weight, or you want to check if you have enough resources before you make an item. There are 3 different parts you need when making a comparison. Here is the syntax you need to use when checking a condition:
property comparison value
Here's an example of how you use this:
uo.life < 50
Here is a list of all the different comparisons you can do (they can be used on much much more then just hits).
< - hits are less then 50
> - hits are greater then 50
<= - hits are less then or equal to 50
>= - hits are greater then or equal to 50
== - hits are equal to 50
<> - hits are not equal to 50
[SIZE="4"]Boolean Logic Operators:[/SIZE]
If you want to check for more then one condition before performing an action you can use any of the following:
&& - AND - both conditions must be true to perform an action
|| - OR - one of the conditions must be true to perform an action
NOT - the condition must be false to perform an action
Here is the syntax you need to use:
property1 condition1 value1 && property1 condition2 value2
Here's an example of how you use this:
uo.life > 1 && uo.life < 100
[SIZE="4"]Decisions and Loops:[/SIZE]
Here are some different commands you can use when scripting. Most of what you do will probably include one of these commands, or maybe even a combination of these commands.
If...Then...Endif
There are a lot of different ways you can use this statement. I'll explain the different ways you can use this statement one at a time and each example will get a little more complicated.
Part 1: The first way you can use this statement is to check for one condition, and if this condition is true your script will perform a specific set of actions it ordinarily won't do. If this condition is not true, your script will continue without performing these actions. Here is the syntax you need to use:
if property<value then
...
endif
Here is an example of how you use this:
PHP Code:
if uo.life<100 then
uo.say("Guards!")
endif
This script will print a message in the bottom-left corner of the UO game window saying what's between the quotes if you have less then 100 life.
If you want to meet more then one condition before having your script perform a certain set of actions you can use the boolean expressions I mentioned above. Here is the syntax you need to use if this is the case:
if property>value1 && property<value2 then
...
endif
Here is an example of how you use this:
PHP Code:
if uo.life>1 && uo.life<100 then
uo.say("You are injured and need to heal!")
endif
This script will show a message in the bottom-left corner of the UO game window saying what's in the quotes only if the two conditions are true. If only one condition is true or neither condition is true it won't show anything.
Part 2: The next way you can use this statement will check for one condition and perform one set of actions if this condition is true and a different set of actions if this condition is not true before continuing with the rest of your script. Here is the syntax you need to use:
if property<value then
...
else
...
endif
Here is an example of how you use this:
PHP Code:
if uo.life<100 then
uo.say("You are wounded!")
else
uo.say("You are not wounded.")
endif
This script will print a message in the bottom-left corner of the UO game window saying what's between the quotes depending how much life you have. As with Part 1, you can combine this with boolean expressions.
Part 3: The next way you can use this statement is to check for multiple specific conditions and perform a different set of instructions for each condition before continuing with the rest of your script. Here is the syntax you need to use:
if property<value1 then
...
endif
if property<value2 then
...
endif
Here is an example of how you use this:
PHP Code:
if uo.life<10 then
uo.say("You are severely wounded!")
endif
if uo.life<100 then
uo.say("You are wounded!")
endif
This script will print a message in the bottom-left corner of the UO game window saying what's between the quotes depending how much life you have. You should notice we didn't assign a condition for when you have 100 life, so if you have 100 life nothing will be shown. Once again you can combine this with boolean expressions.
Part 4: The final way you can use this statement is to check for multiple specific conditions and perform a specific set of actions for each one, and perform another set of actions if none of these conditions are met. Here is the syntax you need to use:
if property<value1 then
...
end if
if property<value2 then
...
else
...
endif
Here is an example of how you use this:
PHP Code:
if uo.life<10 then
uo.say("You are severely wounded!")
endif
if uo.life>10 && uo.life<100 then
uo.say("You are wounded!")
endif
if uo.life==100 then
uo.say("You are not wounded")
else
uo.say("You're superhuman! You have more then 100 life!")
endif
This is a very good technique for troubleshooting since you might encounter a condition you didn't expect the first time you wrote your script and now you can give yourself some kind of warning.