Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

[Resolved] Hmm, a little help?

Status
Not open for further replies.
Hi,

I'm currently scripting something.

I was wondering, if there's a line or snippet of codes which let me;

View total experience earned

View total time played


Is this possible to do?

Thanks

~Kurisu
 

OS

Sponsor

Do you mean the total experience of the Party, or a single actor?

To see A single actor's exp use this:
Code:
a = $game_actors[actor_id].exp
It should return the current EXP of the actor[actor_id]

Or if you want total EXP of the Party, try:
Code:
a = $game_actors.actor[actor_id].exp + $game_actors.actor[actor_id].exp + $game_actors.actor[actor_id].exp + $game_actors.actor[actor_id].exp
This should return the combined values of the EXP of every actor[actor_id] you place in the code. Make sure each ID is different for accurate results...

I'm not sure about play_time though...

If this doesn't work, or you think there may be a better way (and there probably is), go to Tutorials and look in RGSS Tutorials. Go to the link RPG Advocate. It should take you to Phylimortis. There you must look at the default class definitions and see what they tell you.

Hope this helps!

~Broken
 

Mac

Member

Akahi Aomitsu
Code:
a = $game_actors.actor[actor_id].exp + $game_actors.actor[actor_id].exp + $game_actors.actor[actor_id].exp + $game_actors.actor[actor_id].exp

That code is just repeating the same command over and over again, all it would do is add the characters id you are onto itself 3 more times. I also believe you need to call it from data_actors, but i'm not too sure.

I think it should be something more like this:-

Code:
$data_actors[@actor_id].exp

Then i believe you would have to define it as a party, like refer to each party member id then add it all up and make sure it returns nil if a member of the party is missing so it adds up correctly..but i don't know how to do that ^_^
 
$data_actors[actor_id].exp doesn't exist. The $data objects are just the starting data structure for objects. $game_actors[actor_id] is actually the unique objects to each session.

I believe what Akahi Aomitsu was saying was to use:
Code:
a = $game_actors.actor[1].exp + $game_actors.actor[2].exp + $game_actors.actor[3].exp + $game_actors.actor[4].exp

But was far from the easiest way.
Code:
class Game_Party
  def party_exp
    n = 0
    @actors.each { |a| n += a.exp }
    return n
  end
end

Now if you wanted to get the total exp in the party, you can use $game_party.party_exp


As far as time goes, the Graphics.frame_count counts each frame that has passed. So the total time would be something like Graphics.frame_count / Graphics.frame_rate will give you the total seconds. Check Window_PlayTime for more details. ;)
 
Status
Not open for further replies.

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top