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,799
Reaction score
615
First Language
English
Primarily Uses
RMVXA
Have you tried SceneManager.call(Scene_Item)
 

Dopan

Veteran
Veteran
Joined
Mar 27, 2020
Messages
674
Reaction score
347
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
685
Reaction score
448
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 Profile Posts

How you feel about font and dialogue box changing for every main character while the minor cast and regular npc get their own styles? Too much?
Just found an obviously custom effect (i.e. edited by me) in my resources>sounds folder called "rip jaw off". Dear Lord what is wrong with me as a person that at some point I needed a sound *specifically* for THAT??
(...rhetorical question.)
so like with the whole 'familiarity breeds contempt thingy', how are you supposed to tell if your title screen/battle music gets really tedious after a few dozen plays or if you're just personally hella sick of it?
YAY!!! My third help Guide STEAM integration in MV (High performance) has been posted!

Both the polls for the 3rd Original Character Contest ended with 5th place ties! So let's break those ties. Vote now for your favorite of the ones tied!


Forum statistics

Threads
107,520
Messages
1,030,226
Members
139,644
Latest member
five88uytin1
Top