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]Ive changed my mind...

I've changed this post to instead ask for help on what might be an easier problem to solve.

Say I have an array of 10 variables('num1', 'num2', 'num3', 'num4', etc) and I wanted to add a chara's id to these variables. now say i set 'num1' to the first hero in the database. the easy thing would be to just set the other variables to to the rest of the heroes in the database, right? but say i have them join my party in a random order. what i want to do is add a hero's id to a variable that is empty(=0) but only to the first variable the system finds that is equal to 0 and not to every variable that is 0.

ie a code that looks like this.
Code:
variable array {1...20}

add hero id to the first variable found that = 0

i hope this makes sense
 
that's for that but that's mot quite what i was looking for. i want to use an array of variables to store actor IDs in but i wanted to do that in order of when i add them to my party instead of the database order.

hope that makes more sense to you.
 
Hm, I think I get it... (but that's what I kind of thought before :p )

[rgss]def push_actor_id(id)
  needs_push = true
  for i in 0...@variable.size
    if @variable == 0
      @variable = @actor.id
      needs_push = false
      break
    end
  end
  @variable.push(@actor.id) if needs_push
end
[/rgss]

If you put this method in Game_Party, you can add the reference to Game_Party.add_actor (or whatever it's called) and thereby automatically add to your array each time an actor is added to the party.


Note that you still have to correct the variable names, as these are merely placeholders, as I have no idea what framework you're working with.
 
Um... you want to populate an array with numbers from 1 to 100? While that's fairly easy to do...
Code:
100.times do |i|

  @variable.push(i+1)

end
...it seems quite pointless to me... the method I provided will automatically add to the array size when a new member is added. In other words, when there's actors 2, 3 and 1 in the party (in this order), the array will be [2, 3, 1], when you then add 4, it'll be [2, 3, 1, 4]. Now I guess you have some need to replace zeroes in there, so let's assume you'd remove 3 and replace the array entry by 0, getting you [2, 0, 1, 4]. If you'd add 5 now, you'd get [2, 5, 1, 4].
In my opinion, that's all you really want, because having a bunch of unused zeroes at the end doesn't really do much... but maybe you should explain what you want instead of asking for methods to do it ^^"
 
no i mean an array of variable. the reason why i say that i because i want to turn on switches whose id equals what inside the variables. now if there's a way to do that with this method, that would be great.
 
I may be wrong, but it doesn't seem like you know how to script. If so, you need to post a Script Request.

To turn the switches ON, like you said, you can add this line to Bluescope's code after line 5
$game_switches[@actor.id] = true
However, you must know some scripting to use his code.
 

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