Skip to content
View in the app

A better way to browse. Learn more.

LCPDFR.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

A way to change CalloutProbability from .ini file

Featured Replies

  • Community Team

I'm really stumped here, I bet it's an easy fix but my problem is i'm trying to allow users to change the CalloutProbability from the config. Although I can't figure out how to set it in the code. The only way I think I can store the value is with a string, but transferring it to the CalloutProbability is not working.

 

//Settings class reading the ini file, here is just one callout peice to show it's storing as string. 

internal static string Animals = "Medium";

Animals = ini.ReadEnum<string>("Settings", "AttackingAnimal", "Medium");
//It stores the string fine 
          
  
// Ini file peice for this specific callout
          
[Settings]
AttackingAnimal = Medium
          
  
//Callout class
  
[CalloutInfo("AttackingAnimal", CalloutProbability.[Settings.Animals])]
  
  //This error shows up only under the first [.   (Identifier expected   'CalloutProbability' does not contain deffinition for ")
  

 

I'm assuming it's because Settings.Animal is a string, but what else could I do to make it work?

  • Management Team

The callout probability is an attribute, which is a compile-time variable. It hence cannot be changed at runtime like you are trying to do. That being said, using reflection you should be able to modify the value, but that is a little it more complicated. First, get the attribute from your class at runtime (attributes are static and not instance, but type based). Once you have a reference to the attribute, you can use reflection to write to the CalloutProbability property, which has a private setter.

Please do not PM me unless really necessary (knowing you helps). If you think you need my attention in a topic, tag me.

  • Author
  • Community Team
16 hours ago, LMS said:

The callout probability is an attribute, which is a compile-time variable. It hence cannot be changed at runtime like you are trying to do. That being said, using reflection you should be able to modify the value, but that is a little it more complicated. First, get the attribute from your class at runtime (attributes are static and not instance, but type based). Once you have a reference to the attribute, you can use reflection to write to the CalloutProbability property, which has a private setter.

 

Thank you, i'll see about attempting to get that to work, or just find a work around.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.