Click here to Skip to main content
15,885,823 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: (untagged)
I have been trying to find a solution to my issue. I have a few configs that I am trying to build. But I have a single string that needs to be replaced OVER AND OVER but with different values. EX:
{
        "Blueprint": "Blueprint'/Game/PrimalEarth/CoreBlueprints/Weapons/PrimalItem_TekRifle.PrimalItem_TekRifle'",
        "Player": {
          "AllowDamage": true,
          "AllowDamageText": true,
          "MaxDistance": -1,
          "DamageMultiplier": 1,
          "MaxDamage": -1
        },
        "TamedDino": {
          "AllowDamage": false,
          "AllowDamageText": true,
          "MaxDistance": -1,
          "DamageMultiplier": 1,
          "MaxDamage": -1
        },
        "WildDino": {
          "AllowDamage": true,
          "AllowDamageText": true,
          "MaxDistance": -1,
          "DamageMultiplier": 1,
          "MaxDamage": -1
        },
        "Structure": {
          "AllowDamage": true,
          "AllowDamageText": true,
          "MaxDistance": 1000,
          "DamageMultiplier": 1,
          "MaxDamage": -1
        }
      },

I would like to replace:
"Blueprint'/Game/PrimalEarth/CoreBlueprints/Weapons/PrimalItem_TekRifle.PrimalItem_TekRifle"
over and over with multi different strings from a list of entries. I would like to find a way to dump in said list and have it copy that whole code block and replace said value with the first thing in the list and so on till it is finished. I have over 100 entries and copy and paste is starting to cause my eyes to go crossed.I know that I have to be doing it the hard way right now. But I have not found a solution.

What I have tried:

Been copying and pasting the above block of code and replacing said string by hand. Would like to find a automated way if possible. Would make creating BIG config files easier. Doing the editing in notepad++
Posted
Updated 11-Jan-21 7:27am
v3

Sometimes, it's just easier to "hard code" it into your app; versus xml, json or raw and serializing / deserializing.

You have a "thing" class: type, damage, damageText, etc.

Add them at run time to a collection / dictionary: e.g.

// List.
things.Add( new thing( WildDino, false, true, 100, ...
things.Add( new thing( TamedDino, etc.

// Dictionary.
or things[WildDino] = new thing( ... );
 
Share this answer
 
Comments
mininja2131 11-Jan-21 11:38am    
It is not my app. It is a app that has a config file. And I have to add/edit the total count now is over 430 entries to config the app that is supplied to me. That is why I was wondering if there is a easier way then going line by line editing out :
"Blueprint'/Game/PrimalEarth/CoreBlueprints/Weapons/PrimalItem_TekRifle.PrimalItem_TekRifle'"

for like

"Blueprint'/Game/PrimalEarth/Dinos/Rex/Rex_Character_BP.Rex_Character_BP'",

ect like I said over 400 entries now. Because the original only had 1 entry and you can add more. So I copied the above 400 times so I had all the templates then I just have to change the "Tek_Rifle" part for a different entry out of the 400 that I have to do.
If you are willing to do some programming, you can generate classes automatically using this online tool: JSON Utils: Generate C#, VB.Net, SQL Table, Java and PHP from JSON[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900