Skip to content
  • 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 69 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • mmmrkennedyundefined Offline
    mmmrkennedyundefined 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
    • Xerxesundefined Offline
      Xerxesundefined Offline
      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.

      mmmrkennedyundefined 1 Reply Last reply
      0
      • mmmrkennedyundefined Offline
        mmmrkennedyundefined Offline
        mmmrkennedy
        replied to Xerxes 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
        • Xerxesundefined Offline
          Xerxesundefined Offline
          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

          • Login

          • Don't have an account? Register

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