Another troubleshooter....(Datesim script) >.>

Started by Satoh, November 18, 2008, 10:17:42 am

Previous topic - Next topic

Satoh

November 18, 2008, 10:17:42 am Last Edit: November 18, 2008, 10:50:12 am by Satoh
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
Requesting Rule #1: BE SPECIFIC!!

Light a man a fire and he'll be warm for a night...
Light a man afire and he'll be warm for the rest of his life... ¬ ¬;

My Resources

Fantasist

@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...
Do you like ambient/electronic music? Then you should promote a talented artist! Help out here. (I'm serious. Just listen to his work at least!)


The best of freeware reviews: Gizmo's Freeware Reviews




Satoh

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...)
Requesting Rule #1: BE SPECIFIC!!

Light a man a fire and he'll be warm for a night...
Light a man afire and he'll be warm for the rest of his life... ¬ ¬;

My Resources

Fantasist

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
Do you like ambient/electronic music? Then you should promote a talented artist! Help out here. (I'm serious. Just listen to his work at least!)


The best of freeware reviews: Gizmo's Freeware Reviews




Blizzard

I actually explained it to Satoh in IRC already. xD
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

Fantasist

...oh... I guess this is pretty much resolved then ^_^'
Do you like ambient/electronic music? Then you should promote a talented artist! Help out here. (I'm serious. Just listen to his work at least!)


The best of freeware reviews: Gizmo's Freeware Reviews




Satoh

It's resolved for now... I wasn't gonna put a tag in it yet, so it's open for future questions...
Requesting Rule #1: BE SPECIFIC!!

Light a man a fire and he'll be warm for a night...
Light a man afire and he'll be warm for the rest of his life... ¬ ¬;

My Resources