// Script: inventors
function add_item(_nameItem, _num, _maxNum, _sprite) constructor {
nameItem = _nameItem;
num = _num;
maxNum = _maxNum;
sprite = _sprite;
}
// OB_SlimeCore: create
nameItem = "SlimeCore";
num = 1;
maxNum = 16;
sprite = SlimeCore;
// Parents: Создание инвенторя
global.ArraySize = 6;
global.invent = array_create(global.ArraySize, false);
for (i = 0; i < global.ArraySize; i++) {
global.invent[i] = false;
instance_create_depth(32 * i, 0, 0, OB_Celf_Inf).cell = i;
}
// OB_Celf_Inf: draw event
draw_self();
draw_text_color(x, y, string(cell), c_red, c_red, c_red, c_red, 1);
if (is_struct(global.invent[cell])) {
draw_sprite(global.invent[cell].sprite, -1, x, y);
draw_text_color(x + 16, y + 16, string(global.invent[cell].num), c_red, c_red, c_red, c_red, 1);
}
// OB_Item: событие для подбора предмета левой кнопкой мыши
for (i = 0; i < global.ArraySize; i++) {
if (!is_struct(global.invent[i])) {
global.invent[i] = new add_item(nameItem, num, maxNum, sprite);
instance_destroy();
exit;
} else {
if (global.invent[i].nameItem == nameItem && global.invent[i].num < global.invent[i].maxNum) {
global.invent[i].num++;
instance_destroy();
exit;
}
}
}