Scripting: Items
by October
<< All Articles
|
Print
Note: BEFORE READING THIS ARTICLE, YOU SHOULD READ INTERMEDIATE SCRIPTING BY SOLOSTRIKE.
Items - They're great, and you can do many things with them. Like item restrictions for example. And they look awesome in an inventory, can tell you how and where to use them, number of times items it can be used and item effects.
But how do we manipulate items? How do we really make use of them?
It's all in one word: Scripting. In Intermediate Scripting, you learned that the two main ways of uniquely scripting exploitation were through using the two system variables: $ITEMSTATE and $ITEMUSED.
Item State
The purpose of Item State is to take items in and out of inventory at will, or whenever the author chooses it to happen. Using items without scripting means you can only pick up items on a certain page, and once you have dropped them they are lost forever. Unfortunately, unlike the usual picking-up-items routine, you don't get to click on a little picture of your item to pick them up, instead clicking on links to put them in, but you can work your own way around that.
The $ITEMSTATE variable can only be set to 0 or 1.
- 0 means that the item is not in your inventory.
- 1 means that the item is in your inventory.
Use $ITEMSTATE just like any other normal variable. But remember, you must include the item's ID at the end of the variable name. For example: $ITEMSTATE4 would mean the Item State for the item with an ID of four. And remember to put the $ in front, instead of %, because after all this is a system variable. Also, you can put this system variable in both page scripts and link scripts, but they cannot be changed in the link scripts (i.e. $ITEMSTATE := 1 will not work in a link script, but IF $ITEMSTATE = 1 THEN will work).
An Item State script:
IF $ITEMSTATE2 = 0 THEN
$DEST := @P77
ELSE
$DEST := @P81
$DEST := @P77
ELSE
$DEST := @P81
Explaining this script in parts:
IF $ITEMSTATE2 = 0 THEN
This means that if $ITEMSTATE2 is equal to 0 (not in your inventory) then
$DEST := @P77
The destination of the link is set to page 77.
ELSE
If $ITEMSTATE2 isn't 0.
$DEST := @P81
Then the destination of the link is set to page 81.
And the simple way of putting items in your inventory:This means that if $ITEMSTATE2 is equal to 0 (not in your inventory) then
$DEST := @P77
The destination of the link is set to page 77.
ELSE
If $ITEMSTATE2 isn't 0.
$DEST := @P81
Then the destination of the link is set to page 81.
$ITEMSTATE2 = 1
And in theory:%ITEMSTATE2 = 1
This sets the item with the ID of 2 to one, meaning it is in your inventory.
An ideal scenario for this would be a school locker. You could have all your school books in your locker, and all the links, and when you click on the item "Humanities Textbook" it would appear in your inventory. And when you wanted to put books in your locker you could put them back in by clicking on a link as well.
Remember, if you're picking up items along the way (for example, you don't have the Humanities Textbook in the first place) and you don't want it to show up in your locker before you can get it, then make a variable called HUMTXTUSE (Humanities Textbook Uses). Once you have the book, this variable can be set to 1, which means you have the book, but just not in your inventory at the time. Then when you go to the locker page make a variable restriction so that it only shows up if you had the Humanities Textbook in the first place.
Item Used
Item Used is used to determine how many times the player has used an item. This is good for storygames that have items with only a certain amount of uses. Without scripting, you could only make it so that an item could be used a certain amount of times and then you couldn't use it again for the whole storygame. With scripting, you can change how many times an item has been used around.
The $ITEMUSED variable can be set to however many uses you want it to be.
-If it was set to six, the computer would think that the item had been used six times.
-If it was set to zero, the computer would think the item had never been used before.
Like Item State, Item Used should be prefixed with a $ and suffixed with the Item ID.
An Item Used script:
$ITEMUSED4 := 0
An explanation:$ITEMUSED4 := 0
This sets the Item with the ID of 4 to 0 uses.
That script is for resetting the number of times an item is used. This next one is different:This sets the Item with the ID of 4 to 0 uses.
IF $ITEMUSED4 = 3 THEN
BEGIN
$DEST := @P81
END
And now to explain it:BEGIN
$DEST := @P81
END
IF $ITEMUSED4 = 3 THEN
If the item has been used three times, then
BEGIN
[Starts the chain of events]
$DEST := @P81
The destination will be set to page 81.
A good scenario for this would be having a weapon (for example, a gun) that has a limited amount of uses, let's say about 15 uses (15 ammo). Every time you use the gun (fire a shot), it goes up by one. If it reaches 15, you can't shoot anymore (in order to stop it from shooting at fifteen, go to the Item's page by clicking on the item link at the top of your storygames' page and change its maximum number of uses). Later on you may be given an option to reload your gun. Use the first $ITEMUSED script I showed you to reset the uses to zero. This tricks the computer into thinking the gun has never been used, therefore giving it 15 ammo.If the item has been used three times, then
BEGIN
[Starts the chain of events]
$DEST := @P81
The destination will be set to page 81.
Some Scenarios
A list of some scenarios that use these system variables.
- The school locker: Like I showed you, you can use the $ITEMSTATE variable to take books in and out of your locker.
- Weapon Usage: Again, like I showed you, using a weapon (for example gun) that has only a certain amount of ammo.
- Equipping weapons: Like the title says, equipping and unequipping weapons.
- Item Usage: For example: a health potion. Maybe you only have five health potions..
- Item Storage: Used to store items in a bank account. You might only be able to carry around ten items at a time, and the others will have to be stored in a safety vault?
There are endless possibilities for using these two variables to make your storygames easier to make and more fun for the reader. If you have any other questions, make sure to contact either solostrike, alexp, October (myself) or any other person you think may know how to use these variables.
Otherwise, just have fun and remember not to get bogged in your own confusion :P