share class content to a another class

Status
Not open for further replies.

nio kasgami

VampCat
Veteran
Joined
May 21, 2013
Messages
8,949
Reaction score
3,042
First Language
French
Primarily Uses
RMMV
I now have a question about transpose data from a class to a another class

exemple I have this 

class ap def initalize(ap)@ap = ap enddef ap(ap)@ap = 0 endendNow I wanted exemple to transport the AP to the Scene Battle saddly I don't found how to fix this 

exemple I want my ap to increase with a action in the Scene Battle 

EG : 

class Scene_Battle def initialize @ap = Ap.ap enddef progression(ap)@ap += action_cost #this is a exemple don't take considerationenddef action_costreturn 3endend  sadly i can transfert the current ap from the ap class to the scene battle ....

I hope I don't lost people....

thanks if people can help me
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
@ap = ap.new


Though class names usually start with a capital letter.


@ap = Ap.new


Also not a good idea to use the same name for different things. You've called your class ap and you've passed in a variable called ap. It PROBABLY won't get them mixed up, but it can be awfully confusing to read.
 
Last edited by a moderator:

nio kasgami

VampCat
Veteran
Joined
May 21, 2013
Messages
8,949
Reaction score
3,042
First Language
French
Primarily Uses
RMMV
@ap = ap.new

Though class names usually start with a capital letter.

@ap = Ap.new

Also not a good idea to use the same name for different things. You've called your class ap and you've passed in a variable called ap. It PROBABLY won't get them mixed up, but it can be awfully confusing to read.
thanks I will test it for be sure  and yes I will change the name of the class by is true name Action_Point 
 

Tsukihime

Veteran
Veteran
Joined
Jun 30, 2012
Messages
8,564
Reaction score
3,846
First Language
English
I don't understand what you want to do.
 

nio kasgami

VampCat
Veteran
Joined
May 21, 2013
Messages
8,949
Reaction score
3,042
First Language
French
Primarily Uses
RMMV
I don't understand what you want to do.
simply take a value named @ap from the class AP 

 and now transfert it in the Scene_Battle

and after the Scene_battle change the value @ap  in battle 

but the way shaz explain work as well xD 
 
Last edited by a moderator:

Tsukihime

Veteran
Veteran
Joined
Jun 30, 2012
Messages
8,564
Reaction score
3,846
First Language
English
It is still not clear what you are trying to do.


Can you just explain what want to achieve?


Is this AP class supposed to be a static class? Are you creating a new instance of AP everytime a battle begins? Why "transfer" a variable from one class to another?
 
Last edited by a moderator:

nio kasgami

VampCat
Veteran
Joined
May 21, 2013
Messages
8,949
Reaction score
3,042
First Language
French
Primarily Uses
RMMV
in simple the AP class only serve for store all procedure and data of a specific battle system I work on 

and yes I create a new instance of AP each battle begins because the AP (or action point) always refresh to each battle and also each turn 

the action point serve for fight like YANFLY free turn battle but in some ways this is diffirent 

I try my best to explain this but this is not rather simple for me

and I need to transfert the variable because the method battle start is and turn start are in the Scene Battle and the original ap variable in the AP class I can use a module but the AP class handle a tons of variable and method so I prefer a class.
 

cremnophobia

Veteran
Veteran
Joined
Dec 10, 2013
Messages
216
Reaction score
97
Primarily Uses
Do you mean something like this?

class Action_Point
def initalize(ap = 0)


@ap = ap


end


def ap


@ap


end


def ap=(ap)


@ap = ap


end


end

class Scene_Battle
def initialize


@ap = Action_Point.new


end


def progression


@ap.ap += action_cost


end


def action_cost


3


end


end

That doesn't make much sense to me, though.
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
Nio doesn't really want to TRANSFER or TRANSPOSE one class to another. He just wants to create an instance of once class to use in another.


This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.


at OP's request
 
Status
Not open for further replies.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Profile Posts

People3_5 and People3_8 added!

so hopefully tomorrow i get to go home from the hospital i've been here for 5 days already and it's driving me mad. I miss my family like crazy but at least I get to use my own toiletries and my own clothes. My mom is coming to visit soon i can't wait to see her cause i miss her the most. :kaojoy:
Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.

Forum statistics

Threads
105,868
Messages
1,017,081
Members
137,582
Latest member
Spartacraft
Top