Jump to content
kal

Ruby/RGSS3 questions that don't deserve their own thread

Recommended Posts

I am sorry, I did not explain my problem clearly.

I know, that the system sounds can be changed in the database, but what I actually

wanted to know (but did accidently forget in the last post) is, whether it is possible

to access and change the system sounds inside an event via a script call.

 

Unbenannt.png

 

Unbenanyhnt.png

 

You can change the battle BGM and battle end ME but no common SE's.

So what I want to know is whether there is a way to change these systen sounds,

as it appears that inside the sound module, the soundfiles are somehow linked to variables, which I do not understand how to change.

Share this post


Link to post
Share on other sites

Editing the variable probably won't be a good solution as the changes wouldn't be saved. You might be better off editing the code to change which file is referred to based on $game_switches or $game_variables

Share this post


Link to post
Share on other sites

variables is a bad word to use here, because the system sounds have nothing to do with $game_variables, so it's misleading. It's just an array, and the elements are linked to the Sounds section of the System tab in the database.

 

This is what you need to do, in a script call:

$data_system.sounds[1].name = "Buzzer1"

 

This will change the sound that's attached to the OK button. The change will stick until the $data files are reloaded or you change it again (which, I believe, is only on initial load). The change will NOT be saved to the player file, so if you want it to persist between gaming sessions, you will need to set something up to store the values and retrieve them, and reset each time the game is loaded.

Edited by shaz

Share this post


Link to post
Share on other sites

Hi everyone!

 

There are somethings I'd like to use in a Condition Branch: Script, but don't know how to.

 

How do I use like: An Actor X's mp is higher than 30, or defense is different than 1?

I know it has something to do with the >= and != symbols, I just don't know how to access an actor's params.

 

Thanks in advance!

Share this post


Link to post
Share on other sites

To check if an actor's MP is greater than 30, do this:

$game_actors[1].mp >= 30

 

Check the Game_Actor script for a list of other things you can request about an actor.

Share this post


Link to post
Share on other sites

Hey,

 

i just want to display a simple image i tried with something like this

 

   logo = Game_Picture.new(1)
   logo.show("logo", 0, 30, 30, 100, 100, 255, 1)

 

It doesnt work..

whats the correct workflow to get a picture display on screen?

Share this post


Link to post
Share on other sites

I'm getting a Syntax Error on the script I'm currenty making, but I don't know what to do about it.

Error is "unexpected keyword_end

end"

 

It refers to the "end" of "each" in the following method:

  def make_currency_handlers
t = 0
$game_party.gold("").c.each do |c|
  @currency_cmd_window.add_command(c[:name],
                      ("regendo_cur_handle_"+t).to_sym)
  @currency_cmd_window.set_handler(("regendo_cur_handle_"+t).to_sym,
                      method(:change_currency))
  t++
end # <== this line is said to be unexpected.
@currency_cmd_window.set_handler(:cancel, method(:close_currency_window))
 end

 

I already checked the entire script for missing "end"s, but everything that needs an end, be it a class, method, module or even an if clause, has it at the right place.

To anyone wondering, I'm using this to create a number of handlers in a command window, based on the user-specific entries of c array (entries are hashs providing information about the different currencies, like what the max amount of money in that currency is).

Then, I'm using a modified version of call_handler (do not worry about compability, for it is only changed in this sub-class of Window_Command) to give the method (change_currency) an parameter (t).

 

  def call_handler(symbol)
/regendo_cur_handle_(?<id>\d+)/ =~ symbol
if id
  @handler[symbol].call(id) if handle?(symbol)
else
  @handler[symbol].call if handle?(symbol)
end
 end

 

Share this post


Link to post
Share on other sites

@Regendo, I don't think you can do t++ in Ruby. Try changing it to t += 1 instead.

 

 

Hey,

 

i just want to display a simple image i tried with something like this

 

logo = Game_Picture.new(1)
logo.show("logo", 0, 30, 30, 100, 100, 255, 1)

 

It doesnt work..

whats the correct workflow to get a picture display on screen?

 

This is what I think your example would look like, following the Interpreter's logic:

logo = Game_Picture.new(1)
$game_map.screen.pictures[1].show("logo", 0, 30, 30, 100, 100, 255, 1)

 

(edited to change screen to $game_map.screen)

Edited by shaz

Share this post


Link to post
Share on other sites

Hendrik W, sorry - use $game_map.screen instead of screen.

 

But if it's in a battle where you want to do this, then use $game_troop.screen instead.

Edited by shaz

Share this post


Link to post
Share on other sites

I just tried it, and it worked, but the image was translucent. The last parameter you provided is blend mode - you had a 1 there, which means Add, so it's going to change the appearance. Change it to a 0.

 

So here's my example. The first line shows the Show Picture command straight out of event commands. The second line is the script call to show the same picture in a different location.

 

 

post-616-0-14128200-1331930460_thumb.png

Share this post


Link to post
Share on other sites

I've given you what you requested - "a way to display a simple image". If you want something very specific, then you need to be more specific in your request.

 

The title screen IS a picture. What is special about THIS picture that you need to show it differently, and not just AS the title screen? If you're doing this from the script in that case, the line will be the same, it's just where you put it that will be different. I can't tell you where to put it because I don't understand why you want to show a picture when your title screen IS a picture.

Edited by shaz

Share this post


Link to post
Share on other sites

Okay than what i want to do:

I want to customize the scene_title class because i want to create a own startmenu.

I surely could just change the normal titlescreen, but i would need that later for the own menu aswell.

 

Thats where i am so far:

 def create_background
   @sprite = Sprite.new
   whitescreen = Bitmap.new(640,480);
   whitescreen.fill_rect(0,0,640,480,Color.new(255,255,255))
   @sprite.bitmap = whitescreen

   $game_map.screen
   $game_map.screen.pictures[1].show("logo", 0, 100, 100, 100, 100, 255, 0)

   #show(name, origin, x, y, zoom_x, zoom_y, opacity, blend_type)
   #center_sprite(@sprite)
 end

 

The background got white. The picture wont show.

Share this post


Link to post
Share on other sites

okay, now we're cooking :)

 

Here's what I did to show the title1, title2 AND my own image:


 def create_background
   @sprite1 = Sprite.new
   @sprite1.bitmap = Cache.title1($data_system.title1_name)
   @sprite2 = Sprite.new
   @sprite2.bitmap = Cache.title2($data_system.title2_name)
   center_sprite(@sprite1)
   center_sprite(@sprite2)

   @sprite3 = Sprite.new
   @sprite3.bitmap = Cache.title2("Binx")
   center_sprite(@sprite3)
 end

 

It requires your image to be in the Graphics/Titles2 folder. If you don't want it centered, just play with the @sprite3.x and @sprite3.y values.

 

Also make sure you dispose the @sprite3.bitmap and @sprite3 itself in your dispose_background function.

Share this post


Link to post
Share on other sites

Hey guys. I was wondering how do I make a script that refers to the Enemy's note box in the database?

 

I was making this script for my project where the music/background would change depending on what's written in the notes of the Enemy.

It's based on activating a switch, which will change the battle music / background. I have everything done, but I can't actually get the switch to activate via script.

The purpose of this script was to modify special side-quest battles without eventing it.

 

I've defined "snow_bgm" in my script as a switch turning on, and I put "snow_bgm" in my enemy note box, but it doesn't seem to trigger the switch.

 

I'm not that educated in scripting, I just make small scripts for my project.. so I'm sorry if I'm using the wrong method to achieve something like this.

 

I just need some help and I wasn't sure if I should've made a new thread or something, since I thought this was just a syntax thing..

Edited by snow

Share this post


Link to post
Share on other sites

Oh yes! This solved my problem!

 

May you know how to create a simple menu?

 

Thats how far i could get now:

  loop do
  Graphics.update
  Input.update
  if(Input.left?)
    @index -= 1
  if(Input.right?)
    @index += 1

  if(@index >= count)
    @index = 0
  if(@index <= 0)
    @index = count-1

  update_points
   end

Share this post


Link to post
Share on other sites

Hey guys. I was wondering how do I make a script that refers to the Enemy's note box in the database?

 

I was making this script for my project where the music/background would change depending on what's written in the notes of the Enemy.

It's based on activating a switch, which will change the battle music / background. I have everything done, but I can't actually get the switch to activate via script.

The purpose of this script was to modify special side-quest battles without eventing it.

 

I've defined "snow_bgm" in my script as a switch turning on, and I put "snow_bgm" in my enemy note box, but it doesn't seem to trigger the switch.

 

I'm not that educated in scripting, I just make small scripts for my project.. so I'm sorry if I'm using the wrong method to achieve something like this.

 

I just need some help and I wasn't sure if I should've made a new thread or something, since I thought this was just a syntax thing..

 

Could you post your script? It's easier to see what you did wrong that way.

Share this post


Link to post
Share on other sites

Could you post your script? It's easier to see what you did wrong that way.

 

Ok :P

Here is my script with the battle music thing.

 

This script works when I manually event the switch to turn on~

But I think I am using the wrong script to activate the switch and my syntax help file is in japanese -_-

 

I only included the first half of the script because it made the code really long. The second half is just turning the switch off when the party has won/lost/escaped, which I wouldn't have a problem with if I knew the right syntax for doing that xD

 

# â–  [snow]
# script call; play_snowbgm(true)
 #--------------------------------------------------------------------------
 # Before Battle Scene Begins
 #--------------------------------------------------------------------------
class Scene_Map < Scene_Base

def snow_bgm_play				 # BGM to play when special battle occurs
Audio.bgm_play("Audio/BGM/" + "Battle2", 100, 100)
end

SNOW_SWITCH = 2 # switch ID

 def pre_battle_scene			  
Graphics.update
Graphics.freeze
@spriteset.dispose_characters
BattleManager.save_bgm_and_bgs
  if $game_switches[sNOW_SWITCH]  # If switch is enabled
	snow_bgm_play
  elsif						  
	BattleManager.play_battle_bgm
	Sound.play_battle_start
end
 end

 def play_snowbgm(enabled = true)	# Enemy database note box
$game_switches[sNOW_SWITCH] = enabled
 end

end

Edited by snow

Share this post


Link to post
Share on other sites

Ok :P

Here is my script with the battle music thing.

 

Ok I think I know what you're missing. I don't think you are checking the enemy note tags correctly. Also, when is the play_snowbgm method called in your script? It looks like it's not called at all.

 

So when you put text in an enemy's note box, that text is saved along with various other information about that enemy and put into a RPG::Enemy object at the start of the game. Notice that this RPG::Enemy object is not the same as the Game_Enemy object. You can think of the RPG::Enemy object as the data object that keeps track of all the data associated with a particular enemy (for example the note box text) and the Game_Enemy as the game object that has the state (variables), methods etc.

 

So what you need to do is to check the note-box text for the enemies that you are about to fight, see if the text contains "snow_bgm" and call the play_snowbgm method if it does. Here's some code that does that:

 

   $game_troop.members.each do |game_enemy|
  id = game_enemy.enemy_id
  rpg_enemy = $data_enemies[id]
  note = rpg_enemy.note
  if note.include?("snow_bgm")
    play_snowbgm
    break
  end
   end

 

So basically this code iterates over all Game_Enemy objects in $game_troop, gets their associated RPG::Enemy object (each Game_Enemy instance has one RPG::Enemy instance), gets the note text and finally checks if the text includes "snow_bgm" and calles play_snowbgm if it does.

 

Put this code at the beginning of the pre_battle_scene method and I think that will work.

Share this post


Link to post
Share on other sites

Ok I think I know what you're missing. I don't think you are checking the enemy note tags correctly. Also, when is the play_snowbgm method called in your script? It looks like it's not called at all.

Oh, I didn't know about all this stuff. Hehe.

play_snowbgm was just in my enemy's notebox and I thought making a "def play_snowbgm" would make it work xP

 

Thank you so much for helping me and teaching :lol:

I'll go try it out on my other computer tonight.

 

 

Edit: It worked! It read my enemy notes and did what it was supposed to do.

Although, I changed the "if" branch to "unless" because of some minor problems with new stuff that I put in ^^

Thanks alot Kal. ^_^

Edited by snow

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

×