Announcement

Collapse
No announcement yet.

Passing values between objects

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Passing values between objects

    Hi there,
    i've been tryint to pass a bunch of variables from object to another and im getting in a right mess with it.lol
    heres what i tried:
    Code:
    Class My1Mover extends Mover
    Placeable; 
    var()  bool                bpacketSent;
    var()  My2Mover       triggernext;
    struct PacketData
    {
    var() Float                time1;
    var() Float                time2;
    var() Float                time3;
    }; Var() PacketData Mypacket;
    
    Function YouHaveMail (PacketData IncomingPacket)
    { 
    Mypacket=IncomingPacket;
    if (triggernext!=none) TheyHaveMail ();
    }
    
    Function TheyHaveMail ()
    {
    triggernext.YouHaveMail(Mypacket);
    bPacketSent=true;
    }
    also i tried ;-

    Code:
    Function FD_TheyHaveMail ()
    {
    triggernext.Mypacket=Mypacket;
    bPacketSent=true;
    }
    First method getting a type mismatch on call to 'YouHaveMail' and i think the second way its giving me types incompatable with '='. Can anyone see what im doing wrong?
    Thanks.

    #2
    Is packetsent defined somewhere? If so, is it bool?

    Comment


      #3
      yes its bool...but that wouldnt change the error at all

      Comment


        #4
        It may not be possible to assign structs as a whole. You might have to assign each part of it individually (thats what the types incompatible with = is telling you). I dont recall if this is true or not, but I know none of my code (written months ago) does it, and thats probably the reason.

        Comment


          #5
          I have managed to get it to work once or twice but it would only let me pass structs with only one layer.Unfortunatley i think the code got wrecked whil i was trying to work out why. I'll have a nose around see if i can find it.

          Comment


            #6
            Originally posted by FatalOverdose
            yes its bool...but that wouldnt change the error at all
            I think that it would if it was defined as something other than bool.

            For example, if you had like var float packetsent and tried to assign true to it, it would give a similar error message (incompatible types);

            Comment


              #7
              Packetsent is just a flag to lett me know if the packet has been sent
              ? There only one action in the code that uses it and thats to switch it to true after the packet has been sent. its not in a struct and not in the packet that gets sent.

              This is the bit of code i statrted with and im getting no errors, no warnings with it.

              Code:
              class MyMover extends mover
              placeable;
              
              struct FDTheSegments
              {
              Var() bool               FDbBody;
              Var() bool               FDbFemur;
              Var() bool               FDbTibia;
              Var() bool               FDbTarsus;
              };
              struct FDTimeFrame
              {
              Var() bool               FDbOpening;
              Var() bool               FDbOpened;
              Var() bool               FDbClosing;
              Var() bool               FDbClosed;
              };
              
              struct PacketData
              {
              var() Float                     FD_Openspeed;
              var() Float                     FD_CloseSpeed;
              var() Float                     FD_StayOpenTime;
              var() class<FD_FX>       FD_TheFX;
              Var() FDTheSegments   FD_SpawnSEG;
              Var() FDTimeFrame        FD_HardAttachFX;
              Var() FDTimeFrame        FD_SpawnAt;
              Var() FDTimeFrame        ToggleHide;
              }
              ; Var(FDPacketData) PacketData FDFX_Packet;
              
              Function FD_YouHaveMail (PacketData FDIncomingPacket)
              {                                                                           
              log ("i have mail=========");
              FDFX_Packet=FDIncomingPacket;
              }
              i cant see why this bit of code doesnt give error when the one above comes up with a type mismatch?

              Comment


                #8
                Are you declaring the PacketData struct in each class, or once and using it in two different classes? When you use a struct in a different class, you have to fully qualify it, like var MyClass.MyStructType MyVariableName;

                If you delcare it twice with the same name, they probably wont work together.

                Comment


                  #9
                  nice one........i havent checked yet but i think that might be the right answer. At first i got the script working in a single class then split it up into 3 separate classes....thats when it all started to go a bit haywire.

                  Comment


                    #10
                    Thanks for the help Bonehed. Ive subclassed all the packet sending bit s off mover along with my custom movers and its passed the first test...no errors no warnings. If this works ok i'll be able to lose whole chunks of code from the main scripts.

                    Comment


                      #11
                      still not quite sorted
                      I can make the thing sending the packets the same class as the thing recieving the packets no problem. But im still getting a type mismatch when i try to pass the info across in a struct. The error happens as soon as i attach whatever method im using to send the info to a valid actor ref. Ie
                      Code:
                      struct firststruct
                      {
                      var float whatever1;
                      var float whatever2;
                      };
                      var firststruct SendPacket;
                      var firststruct IncommingPacket;
                      
                      Function recievethepacket(firststruct TheIncommingPacket)
                      {
                      IncommingPacket==TheIncommingPacket;
                      SendPacket=IncommingPacket;
                      }
                      will accept the packet ok, but as soon as i then try to pass the packet on to the next actor by any means the valid actor ref is causing the mismatch.
                      Code:
                      ValidActorRef.recievethepacket(SendPacket);
                      or
                      ValidActorRef.recievethepacket(self.SendPacket);
                      or
                      ValidActorRef.IncommingPacket=SendPacket;
                      or
                      ValidActorRef.IncommingPacket=self.SendPacket;
                      what bonehead said seems to make sense but i cant get it to work right.I tried just making a single class that passes the packet to another object of the same class so there would be need to quallify it but im still the missmatch error.
                      In fact the' ValidActorRef.IncommingPacket=self.SendPacket;'
                      gives me: Error ';' expresion has no effect here.
                      Think i might just give up on using struct to send datat at the moment and do it the long way round and see what happens.
                      Code:
                      ValidActorRef.IncommingPacket.whatever1==SendPacket.whatever1;
                      ValidActorRef.IncommingPacket.whatever2==SendPacket.whatever2;
                      works ok just means loads more work for me + plus with unreal script being so based on efficiancy the whole method just feels wrong.

                      Comment

                      Working...
                      X