Jump to content
kal

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

Recommended Posts

Yo guys. I'm a new at ruby so please bare with me okay?

I got a whole lot of question but ill take my turn to ask them.

 

3.times do

puts 'Hello there'

end

What does the 'do' specifically do?

In this it make the hello there copy 3 times but does it do anything else?

Edited by TheGuy

Share this post


Link to post
Share on other sites

changing in game values : How can I do this? I'd like to change some values from the configuration part of the scripts I'm using while the game is being executed : It's gonna be from events with a script call but how can I do that (more precisely from true to false, values of an array and so on).

 

Depends if they're constants or variables.

If they're constants you can't do anything.

 

module Test
  My_Var = true   # you can't modify this
end

 

It is up to the script author to provide variables that you can actually modify.

Usually I add instance variables to Game_System so that you can modify them there, but not all scripters think about it.

 

Yo guys. I'm a new at ruby so please bare with me okay?

I got a whole lot of question but ill take my turn to ask them.

 

3.times do

puts 'Hello there'

end

What does the 'do' specifically do?

In this it make the hello there copy 3 times but does it do anything else?

 

The `do` is just an alternative for ruby's block syntax.

It is basically the same as saying

 

3.times { 
  p "hello there"
}

 

Blocks are long to explain so you are better off reading about them from someone that has written a nice explanation.

Edited by Tsukihime

Share this post


Link to post
Share on other sites

changing in game values : How can I do this? I'd like to change some values from the configuration part of the scripts I'm using while the game is being executed : It's gonna be from events with a script call but how can I do that (more precisely from true to false, values of an array and so on).

 

Depends if they're constants or variables.

If they're constants you can't do anything.

 

module Test
  My_Var = true   # you can't modify this
end

 

It is up to the script author to provide variables that you can actually modify.

Usually I add instance variables to Game_System so that you can modify them there, but not all scripters think about it.

 

Okay, so I'll start reading the help files with this in mind.

Share this post


Link to post
Share on other sites

Sorry if this is a dumb question, but I'm very, very new to scripting. I've been trying to google the answer to this but I only find actual ruby answers, and I'm not sure what does and doesn't apply in the ruby in vxa compared to the normal language.

 

How on earth do I wrap text? I feel dumb asking this, but I just can't figure it out. Like for instance, if I have a window I'm restricting to 200 pixels wide, and I want it to word wrap when it hits the edge of the window, how would I go about that? When I use draw_text it just runs off the edge of the window.

Share this post


Link to post
Share on other sites

The easiest way would probably be to take the text, remove all new-line characters, and then re-build the text and inserting your own new-line characters.

 

You would do a string parser that matches whole words (separated by spaces, or possibly a hyphen).

Then you calculate the width of the text using

 

text_size(str).width

 

Checking whether the string can fit on your line or not (that is, if the total width > window_width - padding), and inserting a new-line character before adding the string to your text.

 

Though, text_size may not support all possible fonts and stuff.

Edited by Tsukihime

Share this post


Link to post
Share on other sites

There's no Mutex class for RGSS3? How do I synchonize? I want to run a parallel process that spawns events but I keep getting:

 

 

errorHash.png

 

 

It only happens when the event is parallel processed, I'm not sure how to fix this without synchronization.

 

Nvm... I just made a parallel processed common event to do the same thing. Much more clunky but gets the job done.

Edited by eshra

Share this post


Link to post
Share on other sites

I have searched high and low, but cannot find the answer.

I have a custom window_selectable with two columns and I want the last two items to both be half the width and share the second column.

 

something like this

 

item 1------item2-------

item3-------item4-------

-------------item5-item6

 

Where is the code that determine the cursor size and placement?

I have only been able to find cursor_up etc... but that only seems to tell it which item to point to.

Am I missing something or is this even possible?

 

EDIT------

 

seems like anytime I post I immeddiately find the answer lol

 

this is the line I was looking for

cursor_rect.set(item_rect(@index))

Edited by Czernobog

Share this post


Link to post
Share on other sites

How can I pan the camera to a specific tile on the map, using RGSS?

 

I figure it's probably related to something inside $game_map, but I'm not quite sure what.

Share this post


Link to post
Share on other sites

 

 

How can I pan the camera to a specific tile on the map, using RGSS?

 

I figure it's probably related to something inside $game_map, but I'm not quite sure what.

 

Follow the "scroll map" event call from Game_Interpreter. You will likely have to take into consideration the screen resolution and corner/edge cases.

Share this post


Link to post
Share on other sites

Thanks for pointing that out; I had to write some extra logic on top of it to make the scrolling use absolute coordinates (the default stuff is all relative to current screen position), but it's working.

 

Related question: It looks like the map can only scroll in one direction at once, and it doesn't even buffer multiple scroll requests (if you call start_scroll while it's already scrolling, it'll ignore the previous request and start using the data from the new one, instead of finishing the first scroll before starting the second.)

 

Has anyone ever written an update to that so Game_Map can scroll diagonally, and/or buffer multiple scroll requests?

Share this post


Link to post
Share on other sites

I just took a look a Yanfly's, that won't quite work for me. His scrip still assumes that the x & y scroll distances are always the same; there's no way to scroll by 3 horizontally and 10 vertically at the same time, for example. That doesn't work for me when I need to scroll to a specific tile which will be any arbitrary amount of x/y away from the current center of the screen.

 

I just ended up writing my own version; you have to separate the x and y scrolling to make it work properly and I don't think anyone's bothered to do that. I'd share, but I had to break the regular scrolling to do it and I'm too lazy to make them both work together >_> (I only need my version anyway)

Edited by Kaelan

Share this post


Link to post
Share on other sites

You can do it in terms of "times to scroll" or scrolling speed (or even distance doesn't really matter)

 

So say we're doing it in terms of how many times you scroll, which you specify.

 

Suppose the center of the camera is currently as (10, 10) and we want to scroll to (20, 15)

Basically, we want to scroll +10x and +5y.

 

If we want to scroll 10 times, we would need to scroll +1x and +0.5y per scroll.

 

Which doesn't seem too bad, except you'd need to write a custom flag to tell it to use the custom scroll rather than overwriting the default scroll.

Edited by Tsukihime

Share this post


Link to post
Share on other sites

I didn't even bother with fractional scroll values, I just rewrote some of the logic so it calls do_scroll twice with the same speed, one for the x scroll and another for the y scroll. So if you have to go +10x/+5y, the y scroll will just finish earlier (which still looks fine, tbh).

 

I could probably rewrite it to be cleaner, use fractional values and not conflict with the default version, but what I have right now already does the job. I'm also in the middle of implementing like 500 other (bigger) things, so I just went with what was easiest/quickest to get done.

Edited by Kaelan

Share this post


Link to post
Share on other sites

Hey guys im back.

 

 

Points = ''

 

if (a == true)

points = points.to_i + 1

else

I want to use this to make the program count the points for the question. It works good but is there a way to make it into a method? Please explain and thanks.

Share this post


Link to post
Share on other sites

I know this is something very basic, but I'm new to RGSS and trying to learn the best I can. Any help would be appreciated. ^^;

 

I cloned Scene_Menu (In an attempt to edit the menu), and setup an event to call it, but it returns an error:

 

Script 'Window_MenuCommand' line 104: NameError occurred.

 

uninitialized class variable @@last_command_symbol in Window_MenuCommand

 

What am I doing wrong? I haven't made any changes to the script, and it's inheriting (I think that's the term) Scene_Menu. Any help is very much appreciated.

Edited by ZODIAK

Share this post


Link to post
Share on other sites

Usually when you call Scene_Menu, you need to initialize the command window's last command position (if it hasn't already been initialized). Look at how they do it in the Game_Interpreter:

 


 #--------------------------------------------------------------------------
 # * Open Menu Screen
 #--------------------------------------------------------------------------
 def command_351
return if $game_party.in_battle
SceneManager.call(Scene_Menu) # you need this
Window_MenuCommand::init_command_position # and this
Fiber.yield
 end

 

I dont know why they do that, but that's the way it works. If you make your own menu, you can change how that works so you only need to do the SceneManager.call for it to function properly (that's how mine works, at least).

Edited by Kaelan

Share this post


Link to post
Share on other sites

Usually when you call Scene_Menu, you need to initialize the command window's last command position (if it hasn't already been initialized). Look at how they do it in the Game_Interpreter:

 


 #--------------------------------------------------------------------------
 # * Open Menu Screen
 #--------------------------------------------------------------------------
 def command_351
return if $game_party.in_battle
SceneManager.call(Scene_Menu) # you need this
Window_MenuCommand::init_command_position # and this
Fiber.yield
 end

 

I dont know why they do that, but that's the way it works. If you make your own menu, you can change how that works so you only need to do the SceneManager.call for it to function properly (that's how mine works, at least).

 

Thanks, that worked. Now I'm trying to figure out how to close out and return back to the scene before calling the menu. Been/am skimming through the code, and ctrl+shift+f for close, but haven't found anything yet. I feel so embarrassed asking such simple questions. *^^;

Share this post


Link to post
Share on other sites

Like this:

 

 return_scene

 

or, if you're not inside a scene class

 

 SceneManager.return

 

Thanks again! You're very helpful. :D

 

I'll work on it some more, and undoubtedly have more questions later. Thanks!

Share this post


Link to post
Share on other sites

Hey guys im back.

 

 

Points = ''

 

if (a == true)

points = points.to_i + 1

else

I want to use this to make the program count the points for the question. It works good but is there a way to make it into a method? Please explain and thanks.

 

You need to first decide how you're going to store that points variable. Will you define your own global variables? Or will you use existing variables?

 

Then you need to decide whether how the method will be called. Will people just write a script call like

 

add_points(3)

 

Which means it will go Game_Interpreter, or will they say something like

 

$game_system.add_points(3)
Point_System.add_points(3)
$game_actors[2].add_points(3)

 

All of them will go to different places, but you will define your add_points method the same way.

Share this post


Link to post
Share on other sites

I decided to toss the menu edits for now, I think that's a bit over my head. So I was brainstorming some easier things to learn RGSS3. How difficult is it to change the message system? I want to change the message box (probably just hide the base) and show a picture in it's place. Could anyone guide me in the right direction? Not asking for a script written for me, but help with the process so I can do it myself. Thanks for any advice in advance. I appreciate it greatly. ^^

Share this post


Link to post
Share on other sites

Thanks for the help. :) I got the window opacity fixed, but still unsure on calling a bitmap. It is through bitmap right? (contents.bitmap?) I found a few lines with "bitmap" in it, but I never found where they specified the file location. I think I have it all wrong.

Edited by Catastrophe

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.

×