Chaos Project

RPG Maker => RPG Maker Scripts => Script Troubleshooting => Topic started by: Satoh on November 18, 2008, 10:17:42 am

Title: Another troubleshooter....(Datesim script) >.>
Post by: Satoh on November 18, 2008, 10:17:42 am
Its a basic datesim system

I want every character to have affection ratings for every other character.

Quotehow do I initialize an array to have all Actor_IDs in the first slot and zero in the second?  [actor_id(1, 2, 3, 4, etc), 0]

Quotebasically I want array[1] to = [actor_id[1],0] and array[2] = [actor_id[2],0]... but I want it to work for all IDs and any new ones I make later...


Spoiler: ShowHide
class Game_Actor
  alias satoh_date_init setup
  def setup(actor_id)
    satoh_date_init(actor_id)
    @love_pts = []
    @love_scene = 0
  end
  def play_scene #(love_scene)
    case @love_scene
    when 1
      #execute scene 1
    when 2
      #execute scene 2
    when 3
      #execute scene 3
    when 4
      #execute scene 4
    when 5
      #execute scene 5
    when 6
      #execute scene 6
    when 7
      #execute scene 7
    end
  end
end
Title: Re: Another troubleshooter....(Datesim script) >.>
Post by: Fantasist on November 19, 2008, 06:07:35 am
@love_pts = []

That's it. Now every element in that array is also an array which contains the actor ID and a value: [ID, value]. But think about this, you don't need arrays again because the position in the array @love_pts will serve as the actor ID, right? So @love_pts[ID] = value would do just fine.

So instead of your @love_pts array looking like this:

[ [ID1, value1], [ID2, value2], [ID3, value3] ]

it would look like this:

[ dummy value (because actor ID with 0 doesn't exist), value1, value2, value3 ]

You can just refer to the array like this. Say you need to access the affinity level Arshes ( ID 1 ) has towards Gloria ( ID 8 ).
$game_party.actors[0].love_pts[8]

"$game_party.actors[0]" is Arshes, and ".love_pts[8]" is his affinity level towards Gloria.

I hope I was not too confusing...
Title: Re: Another troubleshooter....(Datesim script) >.>
Post by: Satoh on November 19, 2008, 06:23:44 am
Quote from: Fantasist on November 19, 2008, 06:07:35 am
You can just refer to the array like this. Say you need to access the affinity level Arshes ( ID 1 ) has towards Gloria ( ID 8 ).
$game_party.actors[0].love_pts[8]

"$game_party.actors[0]" is Arshes, and ".love_pts[8]" is his affinity level towards Gloria.

I hope I was not too confusing...


No, that's exactly how I planned on accessing the information... (however I HAD forgotten about using ID 0 for the first character...)
Title: Re: Another troubleshooter....(Datesim script) >.>
Post by: Fantasist on November 19, 2008, 06:28:13 am
Oh, and if you want to access @love_pts from outside Game_Actor, you need to make it an attr_accessor.

class Game_Actor

  attr_accessor :love_pts

end
Title: Re: Another troubleshooter....(Datesim script) >.>
Post by: Blizzard on November 19, 2008, 11:10:37 am
I actually explained it to Satoh in IRC already. xD
Title: Re: Another troubleshooter....(Datesim script) >.>
Post by: Fantasist on November 19, 2008, 02:20:32 pm
...oh... I guess this is pretty much resolved then ^_^'
Title: Re: Another troubleshooter....(Datesim script) >.>
Post by: Satoh on November 19, 2008, 04:01:54 pm
It's resolved for now... I wasn't gonna put a tag in it yet, so it's open for future questions...