Script call to use item?

ImpossibleSnail

Veteran
Veteran
Joined
Jul 2, 2018
Messages
37
Reaction score
3
First Language
English
Primarily Uses
RMVXA
Heyo! I need to know if one of two things are possible:

I need to be able to let the player choose out of the item menu and, when done, IMMEDIATELY go back to the event they opened the menu from and not the "main menu" page. Skipping it, basically.

If that's not possible I have a more convoluted way to let the player choose an item they have (and store item ID in a variable) but no idea if there's a script call to "use" an item from that? I figure there should be something easy since I have the item ID but nothing comes up when I dig.

NOTE: this is not being used in a "key item" way. This is basically a way to force the player to use a consumable item from the inventory (like a potion) and the formulas/effects NEED to happen with it.

If any more details would help lemme know!
 

Roninator2

Gamer
Veteran
Joined
May 22, 2016
Messages
2,640
Reaction score
560
First Language
English
Primarily Uses
RMVXA
Have you tried SceneManager.call(Scene_Item)
 

Dopan

Veteran
Veteran
Joined
Mar 27, 2020
Messages
475
Reaction score
203
First Language
German
Primarily Uses
RMMV
did u try this (link to a similar topic)..
Sry im using only RPG MV but i found this topic by coincidence,perhaps it can solve your problem.
 

ImpossibleSnail

Veteran
Veteran
Joined
Jul 2, 2018
Messages
37
Reaction score
3
First Language
English
Primarily Uses
RMVXA
Have you tried SceneManager.call(Scene_Item)
The problem is this calls the scene but when you're done and escape out it goes back to the main menu. This gives the player access to things like "save" and "quit" and such that don't work for the event I'm planning.

So it's a start, but I need some way to just 'skip' the main menu afterwards.
 

ImpossibleSnail

Veteran
Veteran
Joined
Jul 2, 2018
Messages
37
Reaction score
3
First Language
English
Primarily Uses
RMVXA
did u try this (link to a similar topic)..
Sry im using only RPG MV but i found this topic by coincidence,perhaps it can solve your problem.
I thiiink this script totally overrides the whole menu? Like for the entire game (unless I'm misunderstanding what's being described there)? It's close but I do still need the menu function to stay as-is. I'm just making one specific event. Thanks for digging this up though~
 

ImpossibleSnail

Veteran
Veteran
Joined
Jul 2, 2018
Messages
37
Reaction score
3
First Language
English
Primarily Uses
RMVXA
It is not.
That's what happened when I tested it though? Cuz I found "SceneManager.call(Scene_Item)" pretty easy. But when you hit "esc" to be done it goes back to the main menu?

Unless I have a script going that's changed things. But even if that's the case the scripts I have are necessary, I'll need a new option.
 

ImpossibleSnail

Veteran
Veteran
Joined
Jul 2, 2018
Messages
37
Reaction score
3
First Language
English
Primarily Uses
RMVXA
Wait ya'll I just tried it again and yeah it does skip the main menu??? I swear that was the first thing I tried but who knows. I also fiddled with stuff between then and now too.

So the scenemanager thing works just fine. Out of curiosity does anyone know a script call to use an item (and all its effects) with the ID? I don't have a specific use in mind but it'd be nice to know.
 

A-Moonless-Night

WINTER IS COMING
Veteran
Joined
Mar 17, 2012
Messages
681
Reaction score
446
First Language
English
Primarily Uses
RMVXA
It depends on what stuff you specifically want to do and how closely you want to resemble what happens in the Item Scene.

Ruby:
# play the Use Item sound
  Sound.play_use_item

  # set the user to one of your actors
  user = $game_actors[1] # change the number to the ID of the actor you want to use
 
  # or if you want to copy what it does in the Item Scene
  user = $game_party.movable_members.max_by {|member| member.pha }
  # this takes the member with the highest PHA rate

  item = $data_items[1] # change the number to the ID of the item you want to use

  # this just checks whether the target should be an enemy, the whole party
  # or one specific actor
  if !item.for_friend?
    targets = []
  elsif item.for_all?
    targets = $game_party.members
  else
    targets = [$game_actors[2]] # change the number to the ID of the actor you want to use
  end

  # use the item and remove it from the inventory
  user.use_item(item)

  # apply the item's effects to the target
  targets.each do |target|
    item.repeats.times { target.item_apply(user, item) }
  end
Hope this helps.
 

ImpossibleSnail

Veteran
Veteran
Joined
Jul 2, 2018
Messages
37
Reaction score
3
First Language
English
Primarily Uses
RMVXA
It depends on what stuff you specifically want to do and how closely you want to resemble what happens in the Item Scene.

Ruby:
# play the Use Item sound
  Sound.play_use_item

  # set the user to one of your actors
  user = $game_actors[1] # change the number to the ID of the actor you want to use
 
  # or if you want to copy what it does in the Item Scene
  user = $game_party.movable_members.max_by {|member| member.pha }
  # this takes the member with the highest PHA rate

  item = $data_items[1] # change the number to the ID of the item you want to use

  # this just checks whether the target should be an enemy, the whole party
  # or one specific actor
  if !item.for_friend?
    targets = []
  elsif item.for_all?
    targets = $game_party.members
  else
    targets = [$game_actors[2]] # change the number to the ID of the actor you want to use
  end

  # use the item and remove it from the inventory
  user.use_item(item)

  # apply the item's effects to the target
  targets.each do |target|
    item.repeats.times { target.item_apply(user, item) }
  end
Hope this helps.
This is all VERY helpful thank you!!!
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

rux
Just 80% of my motivation on game making lmao, anyone got tips on how to not be unmotivated?
I've signed up for a job training program for people with Asperger's Syndrome. I went to a "test run" today so they could see how well I did with simple jobs, and I amazed them. Most new people do it in 30+ minutes, while I finished in a mere 15 minutes. Gives me time to work on a screenplay for Studio MDHR...
People,I have seen that Someone from China/Chile and London is doing a Vaccine Against COVID-19.
Doing anything that yield good result in the long run is like sowing seeds. With proper care, they will grow and bear fruits. I'm excited for tomorrow. :D

Forum statistics

Threads
105,454
Messages
1,013,831
Members
137,104
Latest member
sasakureman
Top