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

Torqus

Veteran
Veteran
Joined
Aug 2, 2015
Messages
169
Reaction score
26
First Language
English
Primarily Uses
Hi guys.

How do you link a "@volume" or something like that, to a volume you set in other script?

I have Message SE and System Options. I already made a new volume control in the system scene for voices.

Message SE asks you for a default volume, but I want the default volume to be the same volume the players set in the System Options.

Now I probably want to change the code of Message SE in line 49 but I'm not sure how.

EDIT: Oh my god I posted this and I solved it 2 minutes later xD

          I just needed "@volume = $game_system.volume:)voice)" in line 49.

          Sorry for posting this :p
 
Last edited by a moderator:

Leitha

Villager
Member
Joined
Sep 29, 2015
Messages
15
Reaction score
12
First Language
English
Primarily Uses
Hello all, new here. Odd place for a first post, I know, but I lean towards the practical.

It's probable this question is already in here, but after several minutes of searching I haven't found it.

I'm tring to customize the status screen, and am having issues with the actor.xparam variables displaying as floating points, thus hogging up valuable screen space. How might I display the parameter as a rounded whole number instead)?

This is what I have at the moment:

draw_text(x + 100, y, 48, line_height, actor.xparam(0) * 100, 2)Thank you in advance.
 

KockaAdmiralac

Cube-shaped garbage can
Veteran
Joined
Jun 15, 2015
Messages
569
Reaction score
153
First Language
Serbian
Primarily Uses
N/A
I think you can use actor.xparam(0).to_i instead

If it's not working try .round(0) instead of .to_i
 

Leitha

Villager
Member
Joined
Sep 29, 2015
Messages
15
Reaction score
12
First Language
English
Primarily Uses
That's exactly what I was looking for, thank you! I had to use both, as only rounding would still print .0 after each value, and only converting to int would cause rounding errors. I also needed to apply both after multiplying by 100, as the stats I'm working with are percentages, and so would otherwise all end up as either 100 or 0.

Final version is as follows:

draw_text(x + 100, y, 48, line_height, (actor.xparam(0) * 100).round(0).to_i, 2)And it works perfectly:

View attachment 23975

Thank you again.

EDIT: In case anyone actually wants to use it, the following version has much cleaner spacing and includes the line for the percentage sign:

draw_text(x + 100, y, 32, line_height, (actor.xparam(0) * 100).round(0).to_i, 2)draw_text(x + 128, y, 16, line_height, "%", 2)Edit II: Ignore this edit. Profile picture upload is being stubborn.

Edit III: Hah! It worked!

Edit IV: Updated the attachment image to better show the end result.

In case anyone wants it, the full edited code for draw_actor_param (in Window_Base) is below. Feel free to use it for whatever, I do not need, nor ask, to be credited for it.

  #--------------------------------------------------------------------------  # * Draw Parameters  #--------------------------------------------------------------------------  def draw_actor_param(actor, x, y, param_id)    change_color(system_color)    if param_id == 8      draw_text(x, y, 100, line_height, "Accuracy")    elsif param_id == 9      draw_text(x, y, 100, line_height, "Evasion")    elsif param_id == 10      draw_text(x, y, 100, line_height, "M Evade")    elsif param_id == 11      draw_text(x, y, 100, line_height, "Critical")    elsif param_id == 12      draw_text(x, y, 100, line_height, "Counter")    elsif param_id == 13      draw_text(x, y, 100, line_height, "M Counter")    else      draw_text(x, y, 100, line_height, Vocab::param(param_id))    end    change_color(normal_color)    if param_id == 8      draw_text(x + 100, y, 32, line_height, (actor.xparam(0) * 100).round(0).to_i, 2)      draw_text(x + 128, y, 16, line_height, "%", 2)    elsif param_id == 9      draw_text(x + 100, y, 32, line_height, (actor.xparam(1) * 100).round(0).to_i, 2)      draw_text(x + 128, y, 16, line_height, "%", 2)    elsif param_id == 10      draw_text(x + 100, y, 32, line_height, (actor.xparam(4) * 100).round(0).to_i, 2)      draw_text(x + 128, y, 16, line_height, "%", 2)    elsif param_id == 11      draw_text(x + 100, y, 32, line_height, (actor.xparam(2) * 100).round(0).to_i, 2)      draw_text(x + 128, y, 16, line_height, "%", 2)    elsif param_id == 12      draw_text(x + 100, y, 32, line_height, (actor.xparam(6) * 100).round(0).to_i, 2)      draw_text(x + 128, y, 16, line_height, "%", 2)    elsif param_id == 13      draw_text(x + 100, y, 32, line_height, (actor.xparam(5) * 100).round(0).to_i, 2)      draw_text(x + 128, y, 16, line_height, "%", 2)   else      draw_text(x + 100, y, 36, line_height, actor.param(param_id), 2)    end  end
With the script change, simply calling draw_actor_param with a param_id of 8 to 13 will draw the xparams instead of the default params.

Note that it does slightly shorten the space for parameter names from 120 to 100, so there may be squishing if you use big words.
 
Last edited by a moderator:

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,107
Reaction score
13,713
First Language
English
Primarily Uses
RMMV
I would approach the issue by questioning WHY they are all floating point in the first place.  Seems you may have edited something else and not taken into account that they need to be converted back to integers.
 

Engr. Adiktuzmiko

Chemical Engineer, Game Developer, Using BlinkBoy'
Veteran
Joined
May 15, 2012
Messages
14,682
Reaction score
3,003
First Language
Tagalog
Primarily Uses
RMVXA
Xparams are floating points...
 

Leitha

Villager
Member
Joined
Sep 29, 2015
Messages
15
Reaction score
12
First Language
English
Primarily Uses
I would approach the issue by questioning WHY they are all floating point in the first place.
It may vary by version. I'm using VX Ace, which stores accuracy, evasion, counter, and critical rates as floating point values.

65%, for example, is stored as 0.65. I cannot speak for the regeneration XParameters, as I haven't needed to check those.

Edit: I modified my earlier post to include the final version of everything, if anyone is curious.
 
Last edited by a moderator:

Sixth

Veteran
Veteran
Joined
Jul 4, 2014
Messages
2,162
Reaction score
823
First Language
Hungarian
Primarily Uses
RMVXA
Is there any way to check for a file's existence within the encrypted part of the project?


I tried to search for any way, but could not find anything about this.
 

KockaAdmiralac

Cube-shaped garbage can
Veteran
Joined
Jun 15, 2015
Messages
569
Reaction score
153
First Language
Serbian
Primarily Uses
N/A
I think it is very hard to achieve.

Dir.glob, Filetest, File.new, open, File.open don't work

From documentation :

Encrypted archives make it difficult for others to analyze and/or modify the game contents. Normally, all data and graphic files (but not audio and font files) are stored in Game.rgss3a. You can create an encrypted archive by checking the [Create encrypted archive] box when compressing the game data.The files within the encrypted archive can be accessed as though they were in the game folder by using the following methods from the built-in game library:load_data, Bitmap.new, Graphics.transitionSo, you can do it if you actually, before encrypting, save all Graphics directory listings (Graphics/Animations, Graphics/Battlebacks1 etc.) to file located in Data folder (or located externally, but that's not really my recommendation), and then load listings from that file.

I noticed this issue when @ksjp17 pointed that out in one post where parallax script didn't work because it was Dir.glob-ing the Graphics/Parallaxes

I saw some scripts, like DerTraveler's Language File System, that convert their files into .rvdata2 and put it in Data folder with a script call, if you want to encrypt your project.

Not connected with the above, can anybody recommend me some proper way of serializing other than Marshal?

Like, if I want to store map data would I store it in XML-like format :

<map id = 144>  <name>Map001</name>  <bgm>    <autoplay>1</autoplay>    <name>Battle1</name>    <volume>100</volume>    <pitch>80</pitch>  </bgm>  <data>    Random characters here  </data></map>Or YAML-like format :

Code:
- 144:    - name : Map001    - bgm :        - autoplay : 1        - name : Battle1        - volume : 100        - pitch : 80    blah, blah, blah...
 
Last edited by a moderator:

MobiusXVI

Game Maker
Veteran
Joined
Mar 20, 2013
Messages
383
Reaction score
91
First Language
English
Primarily Uses
Not connected with the above, can anybody recommend me some proper way of serializing other than Marshal?

Like, if I want to store map data would I store it in XML-like format :

<map id = 144>  <name>Map001</name>  <bgm>    <autoplay>1</autoplay>    <name>Battle1</name>    <volume>100</volume>    <pitch>80</pitch>  </bgm>  <data>    Random characters here  </data></map>Or YAML-like format :

- 144:    - name : Map001    - bgm :        - autoplay : 1        - name : Battle1        - volume : 100        - pitch : 80    blah, blah, blah...
Ruby has a built-in extension for YAML

http://ruby-doc.org/stdlib-1.9.3/libdoc/yaml/rdoc/YAML.html
 

Leitha

Villager
Member
Joined
Sep 29, 2015
Messages
15
Reaction score
12
First Language
English
Primarily Uses
*waves* Me again.

How might one modify variables like HP, MP, or TP using the skill formula script?

b.hp += 1 or similar lines don't appear to do anything.
This is relevent because I have a fourth point type, LP, which for obvious reasons cannot be modified using traditional methods.

Or if there's another option altogether for 'healing' a nonstandard parameter I'll take anything that'll work.

Edit: Nevermind, got it.

Just had to add:  #--------------------------------------------------------------------------  # * Add LP  #--------------------------------------------------------------------------  def add_lp(value)    if self.lp < self.mlp - value      @lp += value    else      @lp = self.mlp    end  end...to Game_Battler, and then I can just use b.add_lp(1) or a.add_lp(5) or whatever I need in the formula box.
 
Last edited by a moderator:

Cristiander

Veteran
Veteran
Joined
Aug 13, 2015
Messages
41
Reaction score
1
First Language
Romanian
Primarily Uses
Question: Can I change the position the program draws the player sprite?

I have a 2d section in my game and the player sprite of that area floats (it is drawn above the ground).

The individual sprites are 64x64 and the image is 768x512. I need the Y value of the draw function down by 4 pixels. Any help?
 
Last edited by a moderator:

KockaAdmiralac

Cube-shaped garbage can
Veteran
Joined
Jun 15, 2015
Messages
569
Reaction score
153
First Language
Serbian
Primarily Uses
N/A
@Cristiander

By 2D section, you mean platform section? With something like Khas Arc Engine?

Try to add the '!' in the character name, that means, if your character name is 'Actor1', change it to '!Actor1'

I think so...
 

Cristiander

Veteran
Veteran
Joined
Aug 13, 2015
Messages
41
Reaction score
1
First Language
Romanian
Primarily Uses
@Cristiander

By 2D section, you mean platform section? With something like Khas Arc Engine?

Try to add the '!' in the character name, that means, if your character name is 'Actor1', change it to '!Actor1'

I think so...
It's like Lisa the painfull.

I'm not using any aditional scripts, I managed without them.

I tried the !. Nothing changes ...

Edit: I made a mistake. It works now. Thank you, I didn't know about the exclamation point
 
Last edited by a moderator:

KockaAdmiralac

Cube-shaped garbage can
Veteran
Joined
Jun 15, 2015
Messages
569
Reaction score
153
First Language
Serbian
Primarily Uses
N/A
Just to note, this was not Ruby/RGSSx related question, but I won't blame you for that, because you didn't know.

But the other thing I noticed that you made a mistake, is that you didn't read this post (or at least not carefully, or you read the not-new version of it) :

http://forums.rpgmakerweb.com/index.php?/topic/14727-a-starting-point-for-new-users-v08/

That tutorial is the BEST tutorial on the forums, and lots of people, as you may have noticed, have it in signature.

So here : 

http://forums.rpgmakerweb.com/index.php?/topic/14727-a-starting-point-for-new-users-v12/#entry147337

is explained how ! and $ are used, and lots of other things, so read it whole. Carefully.
 

Neok

Veteran
Veteran
Joined
Jul 31, 2014
Messages
45
Reaction score
15
First Language
English
Primarily Uses
Hey, do any of you guys know if it's possible to override the passability behaviour for ceiling tiles (a.k.a. A4 tiles)? Even when marked with an X, you can still walk on them as long as you get inside. I'd like to change that and make it so that ceiling tiles can't be walked on, period.
 
Last edited by a moderator:

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,107
Reaction score
13,713
First Language
English
Primarily Uses
RMMV
The easy, non-script way would be to use a blank tile from the B-E tab which is set to X, and draw over your ceilings.


Otherwise, you will need to request a script to do it. There might be some scripts available already that will let you mark a terrain tag or a region id (in which case you'd have to draw with the region as well) as non-passable.


It's not a "question that doesn't deserve its own thread" because it's not as easy to accomplish as saying "I don't want to walk on ceiling tiles"
 

Rikifive

Bringer of Happiness
Veteran
Joined
Jun 21, 2015
Messages
1,441
Reaction score
680
First Language
Polish
Primarily Uses
Other
Quick question - how to improve this code?

Originally I have  much more @thing (16 in total), but there I have put only 5 to not spam with this.

def update_thing @timer += 1 @timer = 0 if @timer == 10 @thing = 0 if @timer == 0 @thing = 1 if @timer == 2 @thing = 2 if @timer == 4 @thing = 3 if @timer == 6 @thing = 4 if @timer == 8Can I leave it like this without performance loss or should I do for example:

@thing = @timer / 2 if @timer ... #(there I'm not sure what to put in to refresh that every two frames)Any suggestions?
 

KockaAdmiralac

Cube-shaped garbage can
Veteran
Joined
Jun 15, 2015
Messages
569
Reaction score
153
First Language
Serbian
Primarily Uses
N/A
I'm not sure what are you trying to achieve, but you can try:


def update_thing


@timer = @timer == 10 ? 0 : @timer + 1 # Replaces the first two lines


@thing = @timer / 2 if @timer % 2 == 0 # Replaces other things


end


And, since @Shaz is pointing out you should learn something new every day, do you know what % operator does, and what are the uses of it?
 
Last edited by a moderator:

Users Who Are Viewing This Thread (Users: 0, Guests: 2)

Latest Threads

Latest Posts

Latest Profile Posts

This is relevant so much I can't even!
Frostorm wrote on Featherbrain's profile.
Hey, so what species are your raptors? Any of these?
... so here's my main characters running around inside "Headspace", a place people use as a safe place away from anxious/panic related thinking.
Stream will be live shortly! I will be doing some music tonight! Feel free to drop by!
Made transition effects for going inside or outside using zoom, pixi filter, and a shutter effect

Forum statistics

Threads
105,998
Messages
1,018,218
Members
137,777
Latest member
Bripah
Top