Skip to content
  • 0 Unread 0
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Donate
Collapse

Plutonium

  1. Home
  2. BO2 Modding Support & Discussion
  3. Syntax Question: What this specific code do?

Syntax Question: What this specific code do?

Scheduled Pinned Locked Moved BO2 Modding Support & Discussion
4 Posts 2 Posters 384 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • mmmrkennedy Offline
    mmmrkennedy Offline
    mmmrkennedy
    wrote on last edited by
    #1

    I was looking at the get_weighted_random_perk function in _zm_perk_random (Line 503), and I saw this code:

    keys = player [[ level.custom_random_perk_weights ]]();

    I've never seen this kind of syntax for other coding languages. What does this do?

    1 Reply Last reply
    0
    • Xerxes Online
      Xerxes Online
      Xerxes
      Plutonium Staff
      wrote on last edited by
      #2

      It runs whichever function level.custom_random_perk_weights is referencing in the context of player and stores the return value in keys.

      mmmrkennedy 1 Reply Last reply
      0
      • Xerxes Xerxes

        It runs whichever function level.custom_random_perk_weights is referencing in the context of player and stores the return value in keys.

        mmmrkennedy Offline
        mmmrkennedy Offline
        mmmrkennedy
        wrote on last edited by
        #3

        Xerxes Thanks for the response. I found level.custom_random_perk_weights in include_perks_in_random_rotation, and it looks like this:

        level.custom_random_perk_weights = ::tomb_random_perk_weights;
        

        Is this just a simple reference to a function that can be called via custom_random_perk_weights later, or does tomb_random_perk_weights get called and referenced when this code is run?

        1 Reply Last reply
        0
        • Xerxes Online
          Xerxes Online
          Xerxes
          Plutonium Staff
          wrote on last edited by
          #4

          That is where the reference is set and not something like in an event driven system where you add yourself to the listeners of an event.

          1 Reply Last reply
          0

          Hello! It looks like you're interested in this conversation, but you don't have an account yet.

          Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

          With your input, this post could be even better 💗

          Register Login
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Unread 0
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Donate