Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Still trying to learn script...

I've got a few questions about using script:

1) How do I access/check which items/weapons/etc. are equipped?

2) How do I create an "if" statement saying 'if switch is true, self.contents.draw_text(0, 0, 100, 32, "This is an example")'

I've come up with errors doing this somehow...

3) How can I check where the player is standing/ which direction the player is facing?

4) How can I check whether or not the player has a weapon (or some item) in his/her inventory?

Thanks in advance for the help!  No need to go too in depth with the answers, I'll understand if you just post an example (like $game_party.gold) because I'm really just looking for how to reference the information.  Thanks!
 
I think i can answer some of you questions.

2)
Code:
 if $game_switches[1] == true
   self.contents.draw_text(0, 0, 100, 32, "This is an example")
 else
   self.contents.draw_text(0, 0, 100, 32, "This is another example")
end

4)
Code:
#for items
if $game_party.item_number(Item_ID) > 0
#for armor
if $game_party.armor_number(Item_ID) > 0
#for weapons
if $game_party.weapon_number(Item_ID) > 0

and replace "Item_ID" with the number in the database.

I think that will work :tongue2:
 

khmp

Sponsor

1) How do I access/check which items/weapons/etc. are equipped? (The player is really just $game_party.actors.first)
Code:
$game_party.actors[id].weapon_id
$game_party.actors[id].armor1_id
$game_party.actors[id].armor2_id
$game_party.actors[id].armor3_id
$game_party.actors[id].armor4_id

Or:
Code:
$game_party.item_number(item_id)
$game_party.weapon_number(weapon_id)
$game_party.armor_number(armor_id)

I also think that is the RGSS FAQ...

3) How can I check where the player is standing/ which direction the player is facing?

You can save the player's x, y, and current direction by using the event command control variables.

Or through script:
Code:
$game_player.x
$game_player.y
$game_player.direction

Good luck with it AbyssalLord! :thumb:
 
If I may add.....

Particularly anything you know you can do with an event. Since all event commands start with the Interpreter class,
take a look at how 'Interpreter' does it.  'Interpreter 2' lists all of the event commands, and indexes them with a number.
(command_101 is the Show Text method, etc...) Then look through the other Interpreter scripts for that method.
There a bit mixed up, but you'll figure it out as you dig through them.

Be Well
 
Hmm...I still can't figure out how to check if an accessory is equipped.  Could someone explain how to do this:

if accessory [id] is equipped to player [id]
self.contents.draw_text(0, 0, ......)
else
do_something_else

Thanks for the help!


EDIT: Oops, sorry about the double post.
 
To check if the leader in the party has a bronze sword equipped you do like this
Code:
if $game_party.actors[0].weapon_id ==  1
  self.contents.draw_text(0, 0, ......)
else
  do_something_else
end

and the same goes for armor:
Code:
$game_party.actors[id].armor1_id == Number in database
$game_party.actors[id].armor2_id == Number in database
$game_party.actors[id].armor3_id == Number in database
$game_party.actors[id].armor4_id == Number in database

Hope that helps :smile:
 

khmp

Sponsor

AbyssalLord":dfy9bvt1 said:
Thanks, I'll give that a shot.  By the way, in the fill_rect method, is there a way to add a gradient?  Thanks!

In RGSS2 there is a method for it. In RGSS its like Soviet Russia and you have to do it yourself. Take a look at Cogwheels Menus. I think that's the script anyway. In that script he makes use of gradient effects. Its seems to me that its a lot of fill_rect calls based on Color math.
 
I don't mean to actually hijack this thread or anything, but I do believe that this question does fit this thread to some extent.  How do you add in variables?  The variables I have in mind are more like an extra equipment slot for a character, extra damage and protection values for weapons and armor respectively, and adding in battle variables that you would want both player characters and enemies to use (for convenience sake, we'll say strength, which is already in).
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top