INVENTORY SCRIPT

by Error014


HOW TO USE IT:

Just include <inventar.wdl> to your game and do the following:

1) OPEN inventar.wdl
2) Change the parameters and Actions as the comments tell you - after the line
"///////----///////" you are finished with changing ;)
3) Open or create a txt-file named "objekte.txt"
4) Now you have to define your objects. Every Object gets an ID. You define it via the
"chapterx"-command. Anyway, this is the structure:

chapterx    || x is the number and equal to the ID of the object. Only integers are allowed
Name	    || The name of the Object. Dont use spaces!
Description || Three lines with descriptions in it. 
Description
Description
Categorie   || May be between 1 and your value for num_categories (maximum 7)
May be sold?|| 1= the item cant be sold (Quest items)
Scaling value|| The viewentity becomes scaled at this factor
Goldworth   || Self-explaining, dont you think?
END         || You have to write that!

For example, this defines an object:

chapter1
Test_object
Its only for testing.
Only testing purpose
That were three descriptionlines :)
1
0
50
END

To use this inventory, you have to name the modell-files of your objects in a special way:
objxxx.mdl
xxx is the ID of the object.
The number MUST BE three digits, so you have to put in "0" for IDs smaller than 100

Example:
obj001.mdl
obj002.mdl
...
obj010.mdl
..
obj023.mdl
...
obj999.mdl



MERCHANTS

The script includes merchant-actions. The "handler"-action is only for testing purposes.

SKILLS FOR THE MERCHANT:
SKILL1 - Fairness value in %. 100% and he gave the player the amount of gold, the item is worth.
SKILL2 - Item to sold
SKILL3 - Number of the item he sold (negative value = endless)
SKILL4 - Item to sold
SKILL5 - Number of the item he sold (negative value = endless)
...
until SKILL19

FUNCTIONS
give_item(a,b);
Gives the player b items with the ID a

take_item(a,b);
Takes b items with the ID a from the player
Returns:
999 = Object not found in "objekte.txt"
-1  = Object mustnt be taken
> 0 = Player hastnt enough, the returnvalue is the remaining

item_avaible(a);
Returns:
The number of items with ID a the player owns


EXAMPLE ACTION: GET THAT ITEM!

You can use this action for an item.
The player will get it as soon as the distance between player and object
is smaller than 50quants:

ACTION take_me {
WHILE(1) {
WHILE(player==null) { wait(1); }
WHILE(vec_dist(player.x,my.x)<50) { give_item(INT(my.skill1),1); ent_remove(me); return; }
wait(1);
}
}

Insert the ID of the object in skill1. It must be an integer, so if the ID should be one,
use 1 as Skill1.

OBJECT FUNCTIONS

Yeah, you can use your objects!
After clicking the leftmouse button or hitting Enter, the function with the same name
than the object is executed (that's why you cant have spaces in the name)
There is a comment in inventar.wdl, which tells you the perfect point for object-functions,
because you can use take_object there.


Guess thats all...

Error014