Jump to content
kal

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

Recommended Posts

I ended up just going another route, having a conditional branch in the Teleport event that checks to see if "$game_map.screen.shake == 0". That way the player can still walk around the elevator as it's "moving" and can't get out until $game_map.screen.shake == 0. It actually looks surprisingly elegant this way. Thanks for your solutions though! :)

Edited by Jolt Android

Share this post


Link to post
Share on other sites

Silly question! ^^

 

~ How to remove a mark from a certain position in a string? ~

 

To add a mark to the string, I have this:

@string.insert(@cursor_position, @sym)
# where @string is for example @string = "A random string!!";
#       @cursor_position is the position of the cursor;
#       @sym is the pressed key

~ but now how to remove them in a similar way?

I know how to remove first/last mark, but can't figure out how to make it based on the cursor's position.

Of course there is a way to achieve this with using some logic here and there, but I wanted to ask if there is a simple function for that first.

 

I've tried to use delete_at, but it seems that it's not intended for use in strings.

 

Solved!

Thank you Sixth!

Share this post


Link to post
Share on other sites

Not sure if this should have its own thread or not as I feel like the solution should be fairly intuitive, or is at least easier than I'm making it.

 

Question: How can I adjust the Save/Load Screen to stack the save files horizontally instead of vertically? 

 

I've fixed the window size already and I'm trying to figure out where the part of the script that controls window x and y for subsequent save file indexes is in Scene_File or Window_SaveFile.

Share this post


Link to post
Share on other sites

Extremely silly question:

 

What is viewport and what it exactly does?

 

Do I have to specify that viewport when drawing sprites?

 

like:

When drawing a sprite:

@sprites << Some_Sprite.new(@viewport)

Sprite superclass:

class Some_Sprite < Sprite
  def initialize(viewport)
    super(viewport)
#(...)

I was looking through the default scripts, but it's still not clear for me.

 

When I'm creating a sprite in the instance itself, then there's no viewport required - but when the sprite has its superclass - it cries for that.

 

I just wanted to know what it really does and what kind of information it yields.

Thank you!

Share this post


Link to post
Share on other sites

Extremely silly question:

 

What is viewport and what it exactly does?

 

Do I have to specify that viewport when drawing sprites?

 

like:

When drawing a sprite:

@sprites << Some_Sprite.new(@viewport)

Sprite superclass:

class Some_Sprite < Sprite
  def initialize(viewport)
    super(viewport)
#(...)

I was looking through the default scripts, but it's still not clear for me.

 

When I'm creating a sprite in the instance itself, then there's no viewport required - but when the sprite has its superclass - it cries for that.

 

I just wanted to know what it really does and what kind of information it yields.

Thank you!

 

A veiwport is a way to group windows and sprites into one object, like a layer in an image editing software, or even more like a group in vertex image software. When a sprite has a viewport for example, it's z value applies inside the viewport and the viewport's z value is the z value all of the sprites/windows as a group are drawn at. Also you can set tones/colors/flash for whole viewports at a time, and mess with the location of the screen and offset that all sprites are drawn in.

Edited by KilloZapit
  • Like 1

Share this post


Link to post
Share on other sites

Oh I see!

That makes sense, thank you for explaining. =3

Share this post


Link to post
Share on other sites

You are very welcome! *sprinkles fairy dust on you*

  • Like 1

Share this post


Link to post
Share on other sites

Hope this will be simple <.< For some reason I can't read actor notetag and I don't get why :(

 

Code:

 

class Game_Battler < Game_BattlerBase
  def item_apply(user, item) # trying to read it from here
    user.equips[0].note.include?("blabla") #Works!
    $data_classes[user.class_id].note.include?("blabla") #Works!
    
    user.note.include?("blabla") 
    # => undefined method 'note' for #<Game_Actor:0x86fa164>
    user.character_index 
    # => integer
    $data_actors[user.character_index].note.include?("blabla")
    # => undefined method 'note' for nil:NilClass
  end

end

 

 

I would love to know why it doesn't work and how I can get around it?^^

 

Pls, I'd be thankful for any ideas!  :wub:

Share this post


Link to post
Share on other sites

note is a method of RPG::Actor not Game_Actor

 

Try

user.actor.note.include?("blabla")  instead

 

 

Edit: Also character index is the character graphic index

Edited by Shiggy
  • Like 1

Share this post


Link to post
Share on other sites

Worked like a charm! Thx! ^^

 

Sometimes its just the simplest of things xD

Share this post


Link to post
Share on other sites

Hello again, everyone! :) Hope you're doing well.

 

Question: is there a way to permanently change the camera's position? I'm asking this because my game has a fixed HUD, which takes up a lot of the screen:

 

screenshot.png

So it would feel more natural for the player to have the character appear half a tile lower.

 

Which of the default scripts handles the centering of the camera? The only related thing I've found is $game_map.set_display_pos, and changing that kind of messes everything up, so I'm probably not using it properly.

 

I'll appreciate any help or tips or ideas you can give me :) Best of luck!

 

Edit: nevermind, I fixed it! I just changed this part of Game_Player

def center_y
  (Graphics.height / 32 - 1) / 2.0
end

to this

def center_y
  (Graphics.height / 32 - 1) / 2.0 + 0.5
end

and then the screen was centered half a tile lower.

Edited by Absurdiness

Share this post


Link to post
Share on other sites

I'm trying to script a non-standard jump (I want the player to move one tile left and half a tile up, so it looks like he's on top of a table instead of merely next to it).  However, I can't figure out how to script a Jump movement.  It appears to require defining x_plus.abs and y_plus.abs, but I can't figure out how to do that specifically.  Could anyone please help me with that?

 

For now, I've merely created a move route that has a script in it to move the player up half a tile just before he jumps, but it creates an awful-looking jerking of the screen, and I don't like how it looks.

Edited by TaranAlvein

Share this post


Link to post
Share on other sites

here this should work

 

Script:

 

class Game_Character < Game_CharacterBase
  def jump(x_plus, y_plus)
    if x_plus.abs > y_plus.abs
      set_direction(x_plus < 0 ? 4 : 6) if x_plus != 0
    else
      set_direction(y_plus < 0 ? 8 : 2) if y_plus != 0
    end
    @x += x_plus
    @y += y_plus - 0.5 # Here i added the '- 0.5'
    distance = Math.sqrt(x_plus * x_plus + y_plus * y_plus).round
    @jump_peak = 10 + distance - @move_speed
    @jump_count = @jump_peak * 2
    @stop_count = 0
    straighten
  end

end

 

 

just showing you what line you are looking for ^^

Share this post


Link to post
Share on other sites

Yeah, I was able to find where it was defined.  What I'm having trouble with is figuring out the syntax for calling it.  I tried looking at examples of calling methods, but they didn't seem to help.

 

I thought I had it with this, which didn't throw an error, but nothing happens when the jump should occur:

 

 

move_route = RPG::MoveRoute.new
move_route.repeat = false
move_route.skippable = false
m = RPG::MoveCommand.new

m.code = 14 -1, -0.5
move_route.list.insert(0, m.clone)

$game_player.force_move_route(move_route)

 

 

What am I missing?

Share this post


Link to post
Share on other sites

Ok, this works like a charm ;) Not really sure about your script, you are over complicating things, is the only thing I can say for sure.

 

Script:

 

class Game_Character < Game_CharacterBase
  def cookie_jump(x_plus, y_plus, arg)
    if x_plus.abs > y_plus.abs
      set_direction(x_plus < 0 ? 4 : 6) if x_plus != 0
    else
      set_direction(y_plus < 0 ? 8 : 2) if y_plus != 0
    end
    @x += x_plus
    @y += y_plus + arg
    distance = Math.sqrt(x_plus * x_plus + y_plus * y_plus).round
    @jump_peak = 10 + distance - @move_speed
    @jump_count = @jump_peak * 2
    @stop_count = 0
    straighten
  end

end

 

 

Event:

PGAg7mc.png

Share this post


Link to post
Share on other sites

Ohhh, sorry.  I thought you were telling me what to look for, since it looks so similar to the default script (didn't even notice it was called "cookie_jump" and not "jump").  It works perfectly.  Thanks a ton!

 

Edit:  Actually, the script ended up being unnecessary.  Seeing how you used the script, I finally realized what the "Script" button was for in the Move Event menu.  I was able to achieve the same effect by simply entering the script "jump(-1, -0.5)".  Still, I greatly appreciate your help.  Thanks again!

Edited by TaranAlvein
  • Like 1

Share this post


Link to post
Share on other sites

Hi everyone. I don't know if this deserves its own thread, it seems like it would be pretty straightforward but nothing I've been doing has been working.

 

Does anyone know how to have a character's magic bypass magic reflection, if they have learned a certain skill?

 

I tried this so far:
 
class Game_Battler < Game_BattlerBase

  #--------------------------------------------------------------------------
  # alias method: item_mrf
  #--------------------------------------------------------------------------
  alias bypass_item_mrf item_mrf
  def item_mrf(user, item)
    return 0 if user.skills.include?($data_skills[111])
    return bypass_item_mrf(user, item)
  end
end

but it doesn't do what I want it to do. I also tried adding the same but with self instead of user, but it's of no use.

 

 

EDIT: I got it. I have a few other scripts that deals with reflect... my battle system is too heavily scripted for its own good.

Edited by Jolt Android

Share this post


Link to post
Share on other sites
Hey, guys! I have a small question: what should I edit in the default scripts to make events always move in multiples of 2px? My game has a x2 ratio, but events move too smoothly and break the illusion of the pixels:

 

screenshot.png

 

I remember somehow fixing this for the player and the camera a while ago, but I don't seem to be able to do the same with events. I'd be very grateful if somebody could give me a hand :)

Share this post


Link to post
Share on other sites

Also any other sprites will, also scrolling will, also parallax will... you get the point. You are probably better off actually reducing the resolution and upstaging it with win32 api tricks or something, or going thorough the base graphic classes and adjust how their x and y locations are reported. Either way it's bound to be a lot of little finicky work to do right.

Share this post


Link to post
Share on other sites

In game_characterbase, there is a method called 

def distance_per_frame

You should try to alias it and multiply the result by 2

Share this post


Link to post
Share on other sites

Also any other sprites will, also scrolling will, also parallax will... you get the point. You are probably better off actually reducing the resolution and upstaging it with win32 api tricks or something, or going thorough the base graphic classes and adjust how their x and y locations are reported. Either way it's bound to be a lot of little finicky work to do right.

 

You have a point. Galv's Layer Graphics script is a good fix for the parallax problem, though; and I haven't needed scrolling yet, but when the time comes I will look into it. I prefer working with one problem at a time. Changing the resolution, on the other hand... Since Ace has a fixed grid size of 32x32 px and I require a grid of 16x16, I think that would be quite more difficult than what I'm doing now (small patches vs. total overhaul).

 

Also, my game doesn't have a battle system, so fixing all this isn't as troublesome as it'd seem. I basically need to tweak event movement and map scrolling, since I already fixed player/camera movement.

 

In game_characterbase, there is a method called 

def distance_per_frame

You should try to alias it and multiply the result by 2

 

Thanks again for the help!  :) But I'm afraid I had already tried that, and it only makes the characters move faster. The "smoothness" of the movement remains untouched. I've tried multiplying by 2 many things in many different methods and classes, such a Game_Event, but in the end the result is always the same.

 

I've been doing some tests and this only happens with events moving at x2 slower or even lower speeds: at normal and fast speeds the "half-pixel" problem isn't apparent. So it isn't as much of an issue as I thought at first, but being able to have visually consistent slower speeds would still be useful. Any idea where these movement calculations are handled? I can't find them. Could they be in one of the hidden classes? In that case, I may have to forget about it.

Share this post


Link to post
Share on other sites

Silly question:
 
How to check if something equals to one of array's values?
 
For example I have a variable:
@var = 0
and an array:
@arr = [23,36,46,70]
 
Now I want to check if the @var equals to any of @arr's values.

 

@var will be increased by 1 each frame~ so the conditional will run on every single frame as well.
So... should I do something like this?

if @arr.include? @var

~Thanks!

Share this post


Link to post
Share on other sites

@arr.include?(@var)

Yes this should work

 

and I will drop this here just in case

 

 

@arr.any? { |array_member| array_member == @var }

any? checks if the condition if true for any element of the array,it might giv eyou some ideas

  • Like 1

Share this post


Link to post
Share on other sites

Ooooh .any? was also something I had in mind, though I was not sure how to use that properly.

 

Now everything is clear, thanks!

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.

×
Top ArrowTop Arrow Highlighted