-2

ok im trying to parse a file into key value pairs but the Dictionary says the keys are the same

what im trying to do is parse a file into key value pairs then i have a huge text file i templated and want to store certin values to it before i save the file out.

Visit https://pastebin.com/YXkxVBuA

this file is all one line seprated by // but some of the keys are the same so it wont let me store in the dictunary and this is the file im trying to add some of the files too.

the code showed below is just a sniplet the file is got loads of key value pairs and i want to say open up the other file listed above get the key value pairs and on the code below i want to add the values to this

so like angleError = mydic.key["angleError"] + mydic.value and it prints the value to that line so when i save i have the updated the value of that file to what was in the file i parsed

    "elf_cp_bo2_pdw_ads_down" ( "xanim.gdf" )
    {
        "angleError" "0.05"
        "boneStabilizers" ""
        "customnote0action" "None"
        "customnote0actionparam1" ""
        "customnote0actionparam2" ""
        "customnote0frame" "1"
        "customnote0useexistingnote" ""
        "filename" "elfenliedtopfan5_anims\\elf_bo3_pdw\\elf_cp_bo2_pdw_ads_down.xanim_bin"
        "fx_customnote0action" "None"
        "fx_customnote0actionparam1" ""
        "fx_customnote0actionparam2" ""
        "fx_customnote0frame" "1"
        "fx_customnote0useexistingnote" ""
        "fx_shutdownnote0action" "None"
        "fx_shutdownnote0actionparam1" ""
        "fx_shutdownnote0actionparam2" ""
        "fx_startupnote0action" "None"
        "fx_startupnote0actionparam1" ""
        "fx_startupnote0actionparam2" ""
        "ignoreSpineBones" "0"
        "leftHandGripIK" "0"
        "looping" "0"
        "loopsync" "0"
        "model" "corpse_party_weapons_bo3\\t6_wpn_smg_pdw57_view\\elf_pdw_animated.xmodel_bin"
        "node" ""
        "previewAlignChildTag" ""
        "previewAlignParentTag" ""
        "previewAttachModel" ""
        "previewModel" ""
        "shutdownnote0action" "None"
        "shutdownnote0actionparam1" ""
        "shutdownnote0actionparam2" ""
        "sound_customnote0action" "None"
        "sound_customnote0actionparam1" ""
        "sound_customnote0actionparam2" ""
        "sound_customnote0frame" "1"
        "sound_customnote0useexistingnote" ""
        "sound_shutdownnote0action" "None"
        "sound_shutdownnote0actionparam1" ""
        "sound_shutdownnote0actionparam2" ""
        "sound_startupnote0action" "None"
        "sound_startupnote0actionparam1" ""
        "sound_startupnote0actionparam2" ""
        "startupnote0action" "None"
        "startupnote0actionparam1" ""
        "startupnote0actionparam2" ""
        "translationError" "0.025"
        "type" "relative"
        "useBones" "0"
        "useNtExportFile" "0"
    }

1 Answers1

0

It seems that each key contains an array (possibly blank) of values. You will have to decide how to store those in your map but you can have a map of ArrayList. Alternatively you can use a multimap (multimap in .NET ) below is the same data but I have split the the lines on // and is more readable

for example

fireSound\wpn_ak47_fire_npc\fireSoundPlayer\wpn_ak47_fire_plr\loopFireSound

looks like either 4 values or a set of pairs. It might turn out that each key has its own specific format. So you need to store the the whole string for each key

Dictionary m... m["fireSound"]=@"wpn_ak47_fire_npc\fireSoundPlayer\wpn_ak47_fire_plr\loopFireSound";

**original file - line separated by dobleshah **

WEAPONFILE\AIOverlayDescription
gunModel\t6_wpn_ar_ak47_view\gunModel1
gunModel2
gunModel3
gunModel4
gunModel5
gunModel6
gunModel7
gunModel8
gunModel9
gunModel10
gunModel11
gunModel12
gunModel13
gunModel14
gunModel15
handModel
modeName
playerAnimType\default\weaponType\bullet\weaponClass\rifle\penetrateType\medium\impactType\bullet_large\inventoryType\primary\fireType\Full Auto\clipType\bottom\barrelType\Single\parentWeaponName\ak47\jamFireTime\0.05\overheatWeapon\0\overheatRate\1\cooldownRate\30\overheatEndVal\25\coolWhileFiring\0\fuelTankWeapon\0\tankLifeTime\0\offhandClass\None\offhandSlot\0\stance\stand\viewFlashEffect\weapon/muzzleflashes/fx_rifle1_flash_base\worldFlashEffect\weapon/muzzleflashes/fx_rifle1_flash_base\barrelCooldownEffect
barrelCooldownMinCount\0\viewFlashOffsetX\0\viewFlashOffsetY\0\viewFlashOffsetZ\0\worldFlashOffsetX\0\worldFlashOffsetY\0\worldFlashOffsetZ\0\pickupSound\fly_generic_pickup_npc\pickupSoundPlayer\fly_generic_pickup_plr\ammoPickupSound\wpn_ammo_pickup_npc\ammoPickupSoundPlayer\wpn_ammo_pickup_plr\projectileSound
pullbackSound
pullbackSoundPlayer
fireSound\wpn_ak47_fire_npc\fireSoundPlayer\wpn_ak47_fire_plr\loopFireSound
loopFireSoundPlayer
loopFireEndSound
loopFireEndSoundPlayer
startFireSound
stopFireSound
killcamStartFireSound
startFireSoundPlayer
stopFireSoundPlayer
killcamStartFireSoundPlayer
lastShotSound
lastShotSoundPlayer
emptyFireSound\wpn_ak47_dryfire_npc\emptyFireSoundPlayer\wpn_ak47_dryfire_plr\crackSound
whizbySound
meleeSwipeSound
meleeSwipeSoundPlayer
meleeHitSound
meleeMissSound
rechamberSound
rechamberSoundPlayer
reloadSound
reloadSoundPlayer
reloadEmptySound
reloadEmptySoundPlayer
reloadStartSound
reloadStartSoundPlayer
reloadEndSound
reloadEndSoundPlayer
rotateLoopSound
rotateLoopSoundPlayer
rotateStopSound
rotateStopSoundPlayer
deploySound
deploySoundPlayer
finishDeploySound
finishDeploySoundPlayer
breakdownSound
breakdownSoundPlayer
finishBreakdownSound
finishBreakdownSoundPlayer
detonateSound
detonateSoundPlayer
nightVisionWearSound
nightVisionWearSoundPlayer
nightVisionRemoveSound
nightVisionRemoveSoundPlayer
altSwitchSound
altSwitchSoundPlayer
raiseSound\fly_generic_raise_npc\raiseSoundPlayer\fly_generic_raise_plr\firstRaiseSound\fly_generic_first_raise_npc\firstRaiseSoundPlayer\fly_generic_first_raise_plr\adsRaiseSoundPlayer\fly_generic_ads_plr\adsLowerSoundPlayer\fly_generic_ads_lower_plr\putawaySound\fly_generic_down_npc\putawaySoundPlayer\fly_generic_down_plr\overheatSound
overheatSoundPlayer
adsZoomSound
shellCasing
shellCasingPlayer
standMountedWeapdef
crouchMountedWeapdef
proneMountedWeapdef
viewShellEjectEffect\weapon/shellejects/fx_rifle\worldShellEjectEffect\weapon/shellejects/fx_rifle\viewLastShotEjectEffect\weapon/shellejects/fx_rifle\worldLastShotEjectEffect\weapon/shellejects/fx_rifle\viewShellEjectOffsetForward\0\viewShellEjectOffsetRight\0\viewShellEjectOffsetUp\0\worldShellEjectOffsetForward\0\worldShellEjectOffsetRight\0\worldShellEjectOffsetUp\0\viewShellEjectRotationPitch\0\viewShellEjectRotationYaw\0\viewShellEjectRotationRoll\0\worldShellEjectRotationPitch\0\worldShellEjectRotationYaw\0\worldShellEjectRotationRoll\0\reticleCenter
reticleSide\reticle_side_small\reticleCenterSize\4\reticleSideSize\8\reticleMinOfs\0\activeReticleType\None\standMoveForward\0\standMoveRight\0\standMoveUp\0\standRotPitch\2\standRotYaw\0\standRotRoll\-2\duckedOfsForward\-1\duckedOfsRight\0.8\duckedOfsUp\-0.2\duckedMoveForward\0\duckedMoveRight\0\duckedMoveUp\0\duckedSprintOfsForward\0\duckedSprintOfsRight\0\duckedSprintOfsUp\0\duckedSprintRotPitch\0\duckedSprintRotYaw\0\duckedSprintRotRoll\0\duckedSprintBobHoriz\0\duckedSprintBobVert\0\sprintOfsForward\0\sprintOfsRight\0\sprintOfsUp\0\sprintRotPitch\0\sprintRotYaw\0\sprintRotRoll\0\sprintBobHoriz\0\sprintBobVert\0\sprintScale\0.8\lowReadyOfsForward\2\lowReadyOfsRight\-5\lowReadyOfsUp\-1\lowReadyRotPitch\20\lowReadyRotYaw\46.6\lowReadyRotRoll\-29.6\rideOfsForward\0\rideOfsRight\0\rideOfsUp\0\rideRotPitch\0\rideRotYaw\0\rideRotRoll\0\dt
Dr Phil
  • 833
  • 6
  • 18
  • yeah that amazing thank you but only issue is i never hurd of multimap and reading into it i have no idea how i would implement what i need to do with that ? – Yuuta Togashi Mar 29 '19 at 07:32
  • A multi map is the fancy name of a dictionary that can hold multiple values per one (same) key. – Dr Phil Mar 29 '19 at 09:59
  • It can be simulated by a dictionary of lists. IDuctionary. However, you also have to decide what you gonna do about the fact that you have multiple values per key when you generate your output. Do you want to display a list? Repeated template? Skip. That could also influence you choices on how to represent the dictionary in memory – Dr Phil Mar 29 '19 at 10:03
  • In the answer there is a link how to implement/simulate it in C#. However, you have to decide what to do with the duplicate values – Dr Phil Mar 29 '19 at 10:14