Jump to content
New account registrations are disabed. This website is now an archive. Read more here.
  • 0
Vinderex

A question about configuring Minkoff's animated battlers

Question

Is there a way to configure a range of characters or enemies in one statment?

 

For example, if I want all enemies with IDs between and including 1 and 9 to use 4x4 charsets as their battler graphics, is there a shorter way than this?

MNK_POSES_ENEMY = {1 => 4,2 => 4,3 => 4,4 => 4,5 => 4,6 => 4,7 => 4,8 => 4,9 => 4}

 

Almost all of my enemies I'm planning on having use charset graphics, so if I have to do this for every one of them, then the list will get really long. So if anyone knows of a shorthand way to configure them all to use the same layout, I'd really appreciate the help. smile.png

Share this post


Link to post
Share on other sites

2 answers to this question

Recommended Posts

  • 0

In a single statement, no. However, you could do this:

MNK_POSES_ENEMY = {}
(1..9).each do |i| MNK_POSES_ENEMY[i] = 4 end

Which is not very clean because constants aren't supposed to be modified, even though Ruby allows it.

 

Another possibility is to keep MNK_POSES_ENEMY empty, but set its default return value to 4:

MNK_POSES_ENEMY = Hash.new(4)

You could bind some IDs to a different number afterwards, which once again is not very clean, but each ID which is not present in MNK_POSES_ENEMY will return 4.

Share this post


Link to post
Share on other sites
  • 0

Alright. Thanks.

That second suggestion I hate to say makes very little sense to me, but the first one opens up another question. Would I be able to use several ranges with that method, like for example 1-9, exclude 10, and then continue with 11-20 etc.?

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...