Quote:
Originally Posted by osomeloso
How to know the item identified id what you have in the inventory. The id number change with the new stats yes?
|
Hello,
I noticed your question on the forum regarding item identification functions, and I'd like to provide you with a detailed explanation and usage guide for the code. This information should be helpful, especially for beginners.
Code:
function generate_random_items( _code, _preset, _count )
for i = 1, _count do
local item_handle = insert_item( _code, 1 )
identify_item( item_handle, _preset )
end
end
Firstly, let's discuss the
generate_random_items function. This function is responsible for spawning random items with a specified code and identifying them using a preset ID. To use this function, you need to replace the
_code parameter with the desired item code and the
_preset parameter with the exact ID used for identification (which can be found in mixresources). Additionally, you should specify the number of items to be generated using the
_count parameter.
Code:
function identify_process( item_id , amount , preset_id, used_item )
local handle_list = get_item_handle_list(item_id) ---handle list of selected item to identify
local full_item_count = table.getn(handle_list)
local amount2 = amount
for i = 1, full_item_count do
if find_item(used_item) >= 1 and amount2 >= 1 then
if identify_item(handle_list[i],preset_id) == 1 then
delete_item(get_item_handle(used_item),1)
message(sconv("@90019369",'@%itemname%@',"@"..get_item_name_id(item_id)))
amount2 = amount2 - 1
end
else
message("No items for identifying left!")
break
end
end
end
Now, let's focus on the
identify_process function. This function is used to identify all items in your inventory with a specific ID, provided that they haven't been identified already. The function takes four parameters:
item_id,
amount,
preset_id, and
used_item. The
item_id parameter should be set to the ID of the items you want to identify. The
amount parameter is used to indicate the maximum number of items you want to identify. The
preset_id parameter represents the ID used for identification, which can be found in mixresources. Lastly, the
used_item parameter denotes the resource item that will be consumed during the identification process.
Once you have set up the parameters for
identify_process, the function will retrieve a list of item handles from your inventory that match the specified
item_id. It will then iterate through this list and check if there are enough
used_item resources and remaining identification
amount to proceed. If the conditions are met, it will identify the item with the given
preset_id, consume one instance of the
used_item, and display a success message. The process will continue until all the items have been identified or there are no more
used_item resources or remaining identification
amount. In case there are no more items left for identification or insufficient
used_item resources, an appropriate message will be displayed.
I hope this explanation clarifies the functionality and usage of the item identification functions. If you have any further questions, feel free to ask.
Best regards,
YoSiem