Example Configstrings - Interactive Configuration presets

Documentation, usage tips and configuration guides for Titan Two scripts and bytecodes published by the community users.

Example Configstrings - Interactive Configuration presets

Postby Scachi » Wed Mar 14, 2018 1:00 am

OLD
Replaced by newer improved version. Available here: CtrlCfg.gph : Apply control=config items by code

The code is based on the idea of NitemareMarauder

Here is some info about my example code "Configstrings" for using a string for defining Interactive Configuration presets.

By selecting a preset name from a combobox any number of interactive configuration values can be changed with a single string.

The preset data is defined in char *CfgSets[]
In a format to set pmem data like: #DataTypeName:Byteoffset:Value#DataTypeName:Byteoffset:Value#...
Where the possible datatypes are:
b = bool, u8 = uint8, u16 = uint16, u32 = uint32, i8 = int8, i16 = int16, i32 = int32, f = fix32

Example of a definition string for 4 Interactive Controls at byte offsets 0,1,2,4:
Code: Select all
char *CfgSets[] = { 
  //#DataTypeName:Byteoffset:Value#DataTypeName:Byteoffset:Value#...
  "#b:0:0#b:1:0#i16:2:0#f:4:0", // all values to zero
  "#b:0:1#b:1:1#i16:2:1#f:4:1", // all values to 1
  "#f:4:-50.717",                // spinboxf only
  "#f:4:88.888",                 // spinboxf only
};
 


For more information take a look at the code "Configstrings" in the Online Resources and its codes comments.

There might be some/a lot /stupid datatype casting that may not be needed. I don't understand enough of datatypes to be able to get an idea of a better, more universal approach, but the code does its job for me.
..If someone more experienced can minimize this code..please do so :innocent_smile_1:
Last edited by Scachi on Sat Dec 29, 2018 5:17 pm, edited 3 times in total.
User avatar
Scachi
Brigadier General
Brigadier General
 
Posts: 3044
Joined: Wed May 11, 2016 6:25 am
Location: Germany

Re: Example Configstrings - Interactive Configuration preset

Postby NitemareMarauder » Wed Mar 14, 2018 11:01 am

is there a way to possibly chop this down to strictly int values, just for my case? or in some way make this a header file? i have incorporated your code into my script and it works perfectly aside from me having to add a IC refresh line
Code: Select all
printf("GCMD:InteractiveConfiguration.Refresh");
 
inside of the init after the clear preset load flag in order to see the changes to the IC immediately and even made an addition to spit out the exact string needed for presets based on already picked options but my problem now is i have to have space for 52 preset codes each having a length of 51 different choices and my bytecode usage is 98+%
this is my modified init
Code: Select all
init  {
    pmem_load(); // load slot data
  // check if to load a preset for secondary
 
    if (pmem_read(60) == 0) { // Print preset code in output
        printf("Preset Code: #b:2:%u#b:3:%u#b:4:%u#b:5:%u#b:6:%u#b:7:%u#b:8:%u#b:9:%u#b:10:%u#b:11:%u#b:12:%u#b:13:%u#b:14:%u#b:15:%u#b:16:%u#b:17:%u#b:18:%u#b:19:%u#b:20:%u#b:21:%u#b:22:%u#b:23:%u#b:24:%u#b:25:%u#b:26:%u#b:27:%u#b:28:%u#b:29:%u#b:30:%u#b:31:%u#b:32:%u#b:33:%u#b:34:%u#b:35:%u#b:36:%u#b:37:%u#b:38:%u#b:39:%u#b:40:%u#b:41:%u#b:42:%u#b:43:%u#b:44:%u#b:45:%u#b:46:%u#b:47:%u#b:48:%u#b:49:%u#b:50:%u#b:51:%u#b:52:%u#b:53:%u",pmem_read(2),pmem_read(3),pmem_read(4),pmem_read(5),pmem_read(6),pmem_read(7),pmem_read(8),pmem_read(9),pmem_read(10),pmem_read(11),pmem_read(12),pmem_read(13),pmem_read(14),pmem_read(15),pmem_read(16),pmem_read(17),pmem_read(18),pmem_read(19),pmem_read(20),pmem_read(21),pmem_read(22),pmem_read(23),pmem_read(24),pmem_read(25),pmem_read(26),pmem_read(27),pmem_read(28),pmem_read(29),pmem_read(30),pmem_read(31),pmem_read(32),pmem_read(33),pmem_read(34),pmem_read(35),pmem_read(36),pmem_read(37),pmem_read(38),pmem_read(39),pmem_read(40),pmem_read(41),pmem_read(42),pmem_read(43),pmem_read(44),pmem_read(45),pmem_read(46),pmem_read(47),pmem_read(48),pmem_read(49),pmem_read(50),pmem_read(51),pmem_read(52),pmem_read(53));
 
        }
    if (pmem_read(60) == 1) {
    uint8 pidx; // selected preset combobox value
        pmem_write(60,0);
        pmem_read(61,&pidx); // read selected preset combobox value
        CfgStr(CfgSets[pidx]); // load the select data preset
        printf("GCMD:InteractiveConfiguration.Refresh");
  }

an example of one of my presets is
Code: Select all
/*Preset 33*/"#b:2:1#b:3:0#b:4:0#b:5:7#b:6:7#b:7:7#b:8:9#b:9:6#b:10:7#b:11:7#b:12:0#b:13:0#b:14:0#b:15:2#b:16:2#b:17:2#b:18:7#b:19:7#b:20:7#b:21:9#b:22:6#b:23:0#b:24:0#b:25:0#b:26:0#b:27:0#b:28:3#b:29:0#b:30:0#b:31:7#b:32:7#b:33:7#b:34:7#b:35:7#b:36:0#b:37:0#b:38:0#b:39:0#b:40:0#b:41:4#b:42:0#b:43:0#b:44:0#b:45:0#b:46:0#b:47:0#b:48:0#b:49:0#b:50:0#b:51:0#b:52:0#b:53:0",
do you think there is any way to help me out? if need be i can update my script so that someone may download it and see if i have any redundencies in my work/ ways to condense my script. i do not have that much scripting knowledge, only what i have learned from modding skyrim with papyrus and from learning from other peoples code on here.
User avatar
NitemareMarauder
Master Sergeant
Master Sergeant
 
Posts: 38
Joined: Thu Dec 07, 2017 12:30 pm

Re: Example Configstrings - Interactive Configuration preset

Postby Scachi » Wed Mar 14, 2018 11:13 am

Can you PM me your complete code with the integration of this code? I can try to reduce my code then to try it to fit it.
User avatar
Scachi
Brigadier General
Brigadier General
 
Posts: 3044
Joined: Wed May 11, 2016 6:25 am
Location: Germany


Return to User's Script Documentation

Who is online

Users browsing this forum: No registered users and 101 guests

cron