Documentation
¶
Overview ¶
Package for ORM access to freelancer game configs data.
configs_mapped allows directly accesing config files for reading in a type safe way and writing values back code is easily extendable without need to write explicit code for reading/writing to files, everything is done by universal custom ini reader
configs_export for type safer data export that has a lot of data already combined from configs for easy usage. See examples folder for how to use library.
This library is used in projects fl-darklint and fl-darkstat.
Checking stuff.
Example (ExtractIniSection) ¶
ExampleExtractIniSection demonstrates how to extract specific freelancer ini sections out
freelancer_folder := configs_settings.Env.FreelancerFolder mapped := configs_mapped.NewMappedConfigs() logus.Log.Debug("scanning freelancer folder", utils_logus.FilePath(freelancer_folder)) // Reading to ini universal custom format and mapping to ORM objects // which have both reading and writing back capabilities mapped.Read(freelancer_folder) order_gun := mapped.Equip().GunMap["fc_or_gun01_mark02"] var output strings.Builder order_gun_section := order_gun.Model.RenderModel() output.WriteString(fmt.Sprintf("%s\n", string(order_gun_section.OriginalType))) for _, param := range order_gun_section.Params { output.WriteString(fmt.Sprintf("%s\n", param.ToString(inireader.WithComments(true)))) } order_munition := mapped.Equip().MunitionMap[order_gun.ProjectileArchetype.Get()] order_munition_section := order_munition.Model.RenderModel() output.WriteString(fmt.Sprintf("%s\n", string(order_munition_section.OriginalType))) for _, param := range order_munition_section.Params { output.WriteString(fmt.Sprintf("%s\n", param.ToString(inireader.WithComments(true)))) } fmt.Println(output.String()) // Example of output // [Gun] // nickname = fc_or_gun01_mark02 // ids_name = 263221 // ids_info = 264221 // da_archetype = equipment\models\weapons\li_heavy_ion_blaster.cmp // material_library = equipment\models\li_equip.mat // hp_child = HPConnect // hit_pts = 7500 // explosion_resistance = 0.14 // debris_type = debris_normal // parent_impulse = 20 // child_impulse = 0.08 // volume = 0 // mass = 0.01 // hp_gun_type = hp_gun_special_1 // damage_per_fire = 0 // power_usage = 56.9 // refire_delay = 0.120000 // muzzle_velocity = 800 // toughness = 4.200000 // flash_particle_name = pi_death_01_flash // flash_radius = 15 // light_anim = l_gun01_flash // projectile_archetype = fc_or_gun01_mark02_ammo // separation_explosion = sever_debris // auto_turret = false // turn_rate = 90 // lootable = true // lodranges = 0, 40, 70, 100, 150 // [Munition] // nickname = fc_or_gun01_mark02_ammo // hp_type = hp_gun // requires_ammo = false // hit_pts = 2 // hull_damage = 84 // energy_damage = 21 // armor_pen = 0.2 // weapon_type = W_Laser01 // one_shot_sound = fire_laser5 // munition_hit_effect = pi_laser_04_impact // const_effect = pi_death_01_proj // lifetime = 0.7 // force_gun_ori = false // mass = 1 // volume = 0
Output:
Example (ImportIniSection) ¶
ExampleImportIniSection demonstrates how to add section to specific section
// can be having imperfections related to how to handle comments. To improve some day freelancer_folder := configs_settings.Env.FreelancerFolder mapped := configs_mapped.NewMappedConfigs() logus.Log.Debug("scanning freelancer folder", utils_logus.FilePath(freelancer_folder)) // Reading to ini universal custom format and mapping to ORM objects // which have both reading and writing back capabilities mapped.Read(freelancer_folder) // TODO Adding Section manually // var new_section *inireader.Section = &inireader.Section{} // mapped_gun := &equip_mapped.Gun{} // mapped_gun.Map(new_section) // mapped_gun.Nickname.Set("my_gun_nickname") // mapped_gun.IdsName.Set(3453453) // mapped_gun.HPGunType.Set("some_hp_type") // configs.Equip.Files[0].Sections = append(configs.Equip.Files[0].Sections, new_section) ///////////// Alternatively feeding in memory section entirely content := ` [Gun] nickname = some_gun hp_gun_type = some_hp_type ` memory_file := file.NewMemoryFile(strings.Split(content, "\n")) scanned_file := iniload.NewLoader(memory_file).Scan() mapped_equip := equip_mapped.Read([]*iniload.IniLoader{scanned_file}) fmt.Println(mapped_equip.Guns[0].Nickname.Get()) fmt.Println(mapped_equip.Guns[0].HPGunType.Get()) // Adding to main Freelancer instance.. mapped.Equip().Files[0].Sections = append(mapped.Equip().Files[0].Sections, mapped_equip.Guns[0].Model.RenderModel()) // Write without Dry Run for writing to files modified values back! mapped.Write(configs_mapped.IsDruRun(true))
Output:
Example (ModifyingConfigs) ¶
ExampleModifyingData demononstrating how to change configs values
freelancer_folder := configs_settings.Env.FreelancerFolder configs := configs_mapped.NewMappedConfigs() logus.Log.Debug("scanning freelancer folder", utils_logus.FilePath(freelancer_folder)) // Reading ini reading universal format // and mapping to ORM objects configs.Read(freelancer_folder) // Modifying files for _, base := range configs.Universe.Bases { base.Nickname.Set(base.Nickname.Get()) base.System.Set(base.System.Get()) base.File.Set(base.File.Get()) } for _, system := range configs.Universe.Systems { system.Nickname.Set(system.Nickname.Get()) system.Msg_id_prefix.Set(system.Msg_id_prefix.Get()) if system.File.Get() != "" { system.File.Set(system.File.Get()) } } // Write without Dry Run for writing to files modified values back! configs.Write(configs_mapped.IsDruRun(true))
Output:
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CliConfigs ¶
func CliConfigs()
from configs. Refactor to integrate it go run . configs go tool pprof -alloc_space -http=":8001" -nodefraction=0 http://localhost:6060/debug/pprof/heap CliConfigs currently contains just debugging run to parse info, useful to profile or integration testing This entrypoint will serve for all commands related to configs if there will be more of them
Types ¶
This section is empty.
Directories
¶
Path | Synopsis |
---|---|
Tool to parse freelancer configs
|
Tool to parse freelancer configs |
freelancer_mapped/data_mapped
This package is equal to DATA folder present in Freelancer Discovery.
|
This package is equal to DATA folder present in Freelancer Discovery. |
freelancer_mapped/data_mapped/universe_mapped
parse universe.ini
|
parse universe.ini |
freelancer_mapped/exe_mapped/go-binary-pack
Package binary_pack performs conversions between some Go values represented as byte slices.
|
Package binary_pack performs conversions between some Go values represented as byte slices. |
parserutils/filefind
Package with reusable code for discovery of files and other reusable stuff like universal ini reader
|
Package with reusable code for discovery of files and other reusable stuff like universal ini reader |
parserutils/inireader
Okay we need to create syntax.
|
Okay we need to create syntax. |
parserutils/semantic
ORM mapper for Freelancer ini reader.
|
ORM mapper for Freelancer ini reader. |