VXAce [SOLVED] Script Call for using an (existing in inventory) item?

Hello!
What is the script call for using an item from inventory?
i was looking on Script Call Collection but i didn't find any.. (i maybe missed it somewhere.)
I guess it depends on how you want to make reference to it.
Game_Battler.use_item(item)
So that could be @actor.use_item(item) and you would have to set the item to the database object not the id.
It doesen't work
1.png

I don't want to use it inside battle or anything like that so i don't know if that helps..
Ruby:
$game_actors[1234].use_item($data_items[2222])
[42, 666, 1337].each {|i| $data_items[2222].repeats.times { $game_actors[i].item_apply($game_actors[1234], $data_items[2222]) } }
SceneManager.goto(Scene_Gameover) if $game_party.all_dead?

Replace all actor #1234 with the one that is used as reference who's actually using the item.
Replace all item #2222 with the item that is being used.
Replace the list of "42, 666, 1337" with all actor-IDs that will be affected by it.

If this to you looks like something you really don't want to have inside an event calling script-snippets:
Congrats, that's correct.

~炬燵あ
If this to you looks like something you really don't want to have inside an event calling script-snippets:
Congrats, that's correct.
Why? is it wrong or is it cause issues?

Ruby:
$game_actors[1234].use_item($data_items[2222])
[42, 666, 1337].each {|i| $data_items[2222].repeats.times { $game_actors[i].item_apply($game_actors[1234], $data_items[2222]) } }
SceneManager.goto(Scene_Gameover) if $game_party.all_dead?
Replace all actor #1234 with the one that is used as reference who's actually using the item.
Replace all item #2222 with the item that is being used.
Replace the list of "42, 666, 1337" with all actor-IDs that will be affected by it.
It doesn't work..

1.png

2.png
I don't know about the content, but the error you have might be because the line in the script is too long, so you end one line with $game_actors a start the next with [1] and these are not read/interpreted as belonging together. I think when you end the line with " \" (i.e. space-backslash), it should connect them, but it has to be put somewhere where there's a logical break, so not between $game_actors and [1]. For example, I used it when I had multiple conditions between the 'and'/'or' symbols (&&, ||). I can't honestly tell you where to put it in your example (I am very much a beginner in these things, just have someone that helps). Maybe someone else will know, or you can try to put it in various places and see :LZSgrin:
because the line is too long.
Ruby:
$game_actors[1].use_item($data_items[23])
[1, 2, 3].each { |i| $data_items[23].repeats.times 
{ $game_actors[i].item_apply($game_actors[1], $data_items[23]) } }
SceneManager.goto(Scene_Gameover) if $game_party.all_dead?

Also I believe they are not to be put all together.
The first part is all you should need.
$game_actors[1].use_item($data_items[23])
because the line is too long.
put the { $game_actors onwards on the next line so that [1], data_items... is not by itself
Ruby:
$game_actors[1234].use_item($data_items[2222])
[42, 666, 1337].each {|i| $data_items[2222].repeats.times {
    $game_actors[i].item_apply($game_actors[1234], $data_items[2222]) } }
SceneManager.goto(Scene_Gameover) if $game_party.all_dead?

So the backslash is not necessary for it to work?
So the backslash is not necessary for it to work?
Never seen that (no memory of it). it could work, it would have to be tested. I'm not a coding expert.
Normally when lines are too long it can break easily at conjunctions "if i && j" you can break after the &&
This only line worked:
$game_actors[1].use_item($data_items[23])

Thank you Roninaror2 and everyone!! 🙂

Original thread: https://forums.rpgmakerweb.com/threads/solved-script-call-for-using-an-existing-in-inventory-item.149426/