share class content to a another class

● ARCHIVED · READ-ONLY
Started by nio kasgami 9 posts View original ↗
  1. 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
  2. @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.
  3. Shaz said:
    @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 
  4. I don't understand what you want to do.
  5. Tsukihime said:
    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 
  6. 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?
  7. 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.
  8. 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.
  9. 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