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

Dopan

Veteran
Veteran
Joined
Mar 27, 2020
Messages
498
Reaction score
226
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

Star citizen just announced they will develop a roadmap for their planned roadmap...
And i thought i needed order on my project... :kaoswt2:
Big City Greens had it right:
"Always back up your brain game, that's what I like to say!"
I think I've created a monster.
...and I love it. <3
Today represents my one year anniversary of throwing out the tile map. :LZSexcite: One year ago my game looked like...


And now for those that don't know, it looks like..


What a year, what a year indeed. RIP Tile Map, nobody misses you. :LZSwink:
There is now a demo released for [Beyond the Mirror]! Check the team recruitment thread to learn more!

Forum statistics

Threads
105,705
Messages
1,015,758
Members
137,385
Latest member
AntagonizedSun
Top