Jump to content
kal

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

Recommended Posts

I just made them for testing purposes, in seriousness - I wanted to make a 664 x 504 window to make it completely full screen.

Also... what do you mean by sprites?

Share this post


Link to post
Share on other sites

I mean the Sprite class, like pictures or characters or stuff. You might wanna look at the RGSS Built-in Classes in the help file. At it's most basic you can just use them to put random pictures wherever you want on the screen.

Share this post


Link to post
Share on other sites

I didn't knew about such a thing, but I think I'll stick to standard methods. =P

Share this post


Link to post
Share on other sites

What you are doing can hardly be called "standard methods", but good luck! *sprinkles fairy dust on you*

Edited by KilloZapit

Share this post


Link to post
Share on other sites

LOL that bad? xD

So... would you care to explain me how the 'sprite' way looks like, how it works and what is the difference? =3

 

(Yay! Fairy dust! =3)

Edited by Rikifive

Share this post


Link to post
Share on other sites

Sprites are just a picture on the screen. They don't have borders or arrows or cursors or anything and just display a bitmap directly. You can do a lot more with sprites then you can do with windows, rotating them, scaling them, doing funky wave effects... stuff like that. Of course all the menu selection stuff and default drawing of info is built into Window subclasses but you will probably have to rewrite all of that anyway. No reason you can't use some windows (borderless or not) and some sprites though. The best and simplest use of sprites in the default script is in Scene_Title (I think that was it's name, the title screen). It just creates sprites for the background and makes one window and that's it.

 

Also using sprites and maybe a few windows is often a better idea then drawing everything to one big image, it's much easier to update them individually and makes the script more modular. You can even make every window use it's own window skin if you want, some with blank borders.

Edited by KilloZapit

Share this post


Link to post
Share on other sites

Hmm.. I don't need anything fancy, just easily draw text/icons/pictures in it, update playtime and stuff.

 

WtvmtpT.png

And All of my windows are transparent.

I'm planning to make something like this:

 

 

Ngofn1x.png

 

 

I'm wondering if I should make multiple windows (marked in red) or to make just one (marked in green).

 

WtvmtpT.png

OKAY, so I did 2 windows for all that stuff - merged 4th and 5th together and and 6th will be alone, due to refreshing.

So.. it's solved.

Edited by Rikifive

Share this post


Link to post
Share on other sites

Yeah, it's just easier not to have to clear the whole image and redraw it every frame, which is what you pretty much will have to do if you do it that way.

Share this post


Link to post
Share on other sites

I have gold, location, picture of current location and playtime in one window - where only playtime is updated each second - the rest is fixed and works perfectly.

In the second window I have drawn ponies - that window refreshes ONLY when the formation is changed. (I spend so much time on making it refresh only if formation is changed - and when I realized, that I was thinking correctly all the time then *TRIPLE FACE PALM*.

There's nothing updated for no reason, it's as much simple as possible. It should not be bad.

Everything is correctly made I think. =]

Share this post


Link to post
Share on other sites

Neato! I guess you have it handled then...

 

You know what that means...

 

*sprinkles fairy dust on you*

Share this post


Link to post
Share on other sites

Cannot figure this out. I have ten variables and I want a certain event of ten events to activate according to the highest of these variables. Any way to do that?

Edited by DarthVollis

Share this post


Link to post
Share on other sites

Well, are you looking for a way to tell the highest of a list of variables? Say you have a list of variable numbers like [1, 2, 3, 4, 5] and you want to know which one is the highest. You can use something like this:

 

 

a = [1, 2, 3, 4, 5]
vnum = a.max {|a, b| $game_variables[a] <=> $game_variables[b]}

 

You will probably need a master event or script to check the variables and activate the right script though... do you need help activating events too?

Share this post


Link to post
Share on other sites

ehhh... there is probably more you will have to do... all I covered was how to figure out what variable is higher.

Share this post


Link to post
Share on other sites
Question time from me : P
I have a common event that gets killed when a boss enemy uses a summon skill. 
It let an enemy appear when the enemy is dead it gets revived and appears again.

But I got a problem  with it. This boss also gets used in a another fight with 2 other bosses. (Over kill much : P). In this fight this boss can also use the summon skill.
But what happens now is if one of the other bosses is dead it gets summoned again....(to much overkill)
 

So my question: Is there a way to get the note's of the enemies in the current troop?

 

EDIT:

Not needed anymoar already got it :P
 

$game_troop.members.each do | member |
  p $data_enemies[member.enemy_id].note
end

Gave me what I need : P

EDIT 2:

Finished it already. So i thought I would share it here.

Set a $game_variables[21] to the amount you want to let summon, or fill that place with a random if your choice.
It shuffles the array and summons them. If they are dead they will get revived.
 

Make a common event and paste this script in there.

Finalized:
 

i = 0
$game_troop.members.shuffle.each do | member |
    if member.hidden == true || member.dead?
        notetag = $data_enemies[member.enemy_id].note
        if notetag !~ /<boss>/
            member.recover_all
            member.appear
            i += 1

            if i >= $game_variables[21]
                break
            end
        end
    end
end

edit 3: Code blocks...

Edited by Frysning

Share this post


Link to post
Share on other sites

Hey! im wondering why this doesent work (as a "script" in an event):
         msgbox($game_map.events_xy(1, 2)[0].name)

 

i get the error: Undefined method "name" for #<Game_Event:0x7675910>

 

when in a script i have (in class Game_Map) :

map = load_data(sprintf("Data/Map%03d.rvdata2", mapid))
    map.events.each do |i, event|
      if event.name == eventName
 
where event.name clearly works
 
 
any help is greatly appreciated :)
Edited by lazyV

Share this post


Link to post
Share on other sites

They aren't the same class. Your first example is a Game_Event object that is created in the game script with full methods for moving around and animating and stuff, and your second example is the built in data container class RPG::Event that just holds imported map event data. Since an event's name is never used in the default scripts and is mostly just for convenience of people using the editor, it's not one of the things stored in the Game_Event class. Game_Event does remember what RPG::Event was used to make it, but only in a private instance variable, You will have to modify Game_Event to get the name.

 

This is a simple way to do it: 

class Game_Event

  def name
    @event.name
  end

end
But you may want to do this instead (needed if you want to change the name during the game):

class Game_Event
 
  attr_reader :name # or use attr_accessor if you want to be able to change it

  alias name_initialize initialize
  def initialize(map_id, event)
    name_initialize(map_id, event)
    @name = event.name
  end
 
end
Edited by KilloZapit

Share this post


Link to post
Share on other sites

Thanks for the quick reply, and im gonna add some more questions :P

 

If i understand correctly(probably not), i can use the first example if i use it in a regular script, but not in an event-called "script"?

and you said that i could just add

 

class Game_Event

  def name
   
@event.name
 
end

end

 

i dont see how this would work, since the variable name doesent actually exist in Game_event, or in anny of the parent classes...

 

im sorry but this is the first time i have tried to learn rmvxa scripting so the questions may be a bit stupid :P

bonus question what does the @ infront of the event mean?

Share this post


Link to post
Share on other sites

Yeah use that in the script editor. You are right it doesn't exist, so we have to make a script that adds it for us! That's what that does, makes a new method called "name" for the Game_Event class. Ruby classes are always open so we can just add new things to them when ever we want you see.

 

And the @ means that it's an instance variable. Every object can have them and uses them to store properties. But they are private, which means you can only access them from within the class (well unless you blatantly cheat and use a special method), so you have to add methods to the class for it to work! See, @event is set to the RPG::Event object used to make the Game_Event object when the Game_Event object is created, so we can just make a name method that looks up the name from there!

 

I think it should be worth saying, but because in Ruby instance variable are always private, you have to make a method to access any kind of variable for an object. Saying object.thing always will run a method on object called thing. But Ruby lets you automatically create the right methods to access any instance variable with the attr_reader attr_writer and attr_accessor! Actually the fun thing is those are methods too, ones that create methods and exist as part of the Class class. But that isn't important. :3

Edited by KilloZapit

Share this post


Link to post
Share on other sites

Thanks! you are so incredibly helpfull!

I think i understand most of it, but i will probably post more questions here in the near future :P

thanks again

Share this post


Link to post
Share on other sites

Your welcome! I like to help! Good luck! *sprinkles fairy dust on you*

Share this post


Link to post
Share on other sites

I am currently hoping to create a skill which affects the enemy user in a different way based on who the actor target is. The skill is using a common event to process this information, but I am running into syntax problems.

 

My question is, is there a conditional branch script call that can be used to set the actor that is being targeted when the skill is used? (the skill targets One Enemy which would be a party member since this skill is only used by enemies)

 

A rough example would be that the enemy uses the skill on actor ID 5. The enemy is then applied with a status condition. The status condition applied would be different if the target of the skill were, say, actor 4.

 

Edit: I've since figured this out. Disregard. :D

Edited by WCouillard

Share this post


Link to post
Share on other sites

My apologies if this isn't exactly in the right spot.

 

I am attempting to use a script call to directly change the amount of items given, rather than using the default tools, which won't let me pass a variable to determine the item I want given. I want to do this because earlier in an event chain I have the player pick what item they want and capture the item id in a variable.

 

 

I found this posted in another thread.

 

$game_party.gain_item($data_items[5], 1, false)

 

Can I place my variable loaded with the item ID I want to give away in the slot with the 5? If so, what's the correct syntax to use?

 

If I want to take items away, can I just use a negative number for the last amount, or is it a different command?

 

Thank you.

 

Share this post


Link to post
Share on other sites

The script call is indeed

$game_party.gain_item(item, amount, include_equip = false)

And your thoughts are correct; a negative amount will result in items lost.

The default "lose item" method actually calls the "gain item" one, with a negative value.

 

To use a variable for the amount, just do something like this:

x = $game_variables[1]
$game_party.gain_item($data_items[5], x, false)
Edited by ???nOBodY???

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