Layman's guide on how to build Interactive Config UI's
Re: Layman's guide on how to build Interactive Config UI's
antithesis wrote:
- Code: Select all
/*******************************************************************************
<cfgdesc>
[Quick Scope]
color = #000060
shortdesc = <<<MULTILINE
Mod trigger - share & L2
MULTILINE
[Quick Scope]
group = true
byteoffset = 1
bitsize = 8
control = checkbox
default = 0
item = Quick Scope off/on
[Quick Scope Setting]
group = true
shortdesc = <br><b><font color="blue">Quick Scope Setting:</font></b>
byteoffset = 2
bitsize = 16
control = spinbox
default = 420
minimum = 50
maximum = 1000
step = 1
</cfgdesc>
/*************************************************************************
*
**************************************************************************/
bool q_scope;
uint16 QuickScopeAdjustment;
init {
pmem_load();
pmem_read(2, &QuickScopeAdjustment);
q_scope = (pmem_read(1));
}
main {
//quick scope
if(get_val(BUTTON_2) && event_active(BUTTON_8)) {
q_scope=!q_scope;}
if(q_scope) {
if(event_release(BUTTON_8) && time_active(BUTTON_8) < 500) {
combo_run(QuickScope);
}
}
}
combo QuickScope
{
set_val(BUTTON_5, 0.0);
set_val(BUTTON_8, 100.0);
set_val(BUTTON_9, 100.0);
wait(QuickScopeAdjustment);
set_val(BUTTON_5, 100.0);
set_val(BUTTON_8, 100.0);
set_val(BUTTON_9, 100.0);
wait(40);
}
combo sniper_breath
{
set_val(BUTTON_9, 100.0);
wait(10);
set_val(BUTTON_9, 100.0);
}
Variables are declared before init, which was causing the scope error.
I simplified your toggle logic, it works the same way.
Thank you so much, this is a great explanation and it does work. The reason I had the toggle logic written that way is because I actually use LED and rumble to tell me if the mod turns on or off. This is what it looks like when Im done.
- Code: Select all
if(get_val(BUTTON_2) && event_active(BUTTON_8)) {
if(q_scope == 0) {
q_scope = 1;
combo_run(RUMBLE_ON);
combo_run(flash_on);
}else if(q_scope == 1) {
q_scope = 0;
combo_run(RUMBLE_ON);
combo_run(flash_off);
}
}
if(q_scope == 1) {
if(event_release(BUTTON_8) && time_active(BUTTON_8) < 500) {
combo_run(QuickScope);
}
}
Trying to teach myself how to program these scripts even though I'm old
-
umpmanjoe - First Sergeant
- Posts: 45
- Joined: Mon May 25, 2015 1:23 am
Re: Layman's guide on how to build Interactive Config UI's
antithesis wrote:e.g ToggleAON = (pmem_read(0) >> ?) & 0b1; ToggleBON = (pmem_read(0) >> ?) & 0b1;
bonefisher wrote:It will always be 7
Why always 7 ? I would do like that:
ToggleAON = (pmem_read(0) >> 1) & 0b1; ToggleBON = (pmem_read(0) >> 2) & 0b1;
Console tuner since my 1st controller.
Scripting, a game in the game.
Believe or dare, It's Titanic!
Scripting, a game in the game.
Believe or dare, It's Titanic!
-
Prototype - Major General
- Posts: 3252
- Joined: Sun Dec 16, 2012 1:43 pm
Re: Layman's guide on how to build Interactive Config UI's
I made this Interactive UI. Is there a way to have it that the "Auto Sniper Breath" and only be checked if "Quick scope" is checked? Another way would be if "Auto Sniper Breath" is checked, it automatically checks "Quick Scope"
Trying to teach myself how to program these scripts even though I'm old
-
umpmanjoe - First Sergeant
- Posts: 45
- Joined: Mon May 25, 2015 1:23 am
Re: Layman's guide on how to build Interactive Config UI's
umpmanjoe wrote:I made this Interactive UI. Is there a way to have it that the "Auto Sniper Breath" and only be checked if "Quick scope" is checked? Another way would be if "Auto Sniper Breath" is checked, it automatically checks "Quick Scope"
There is no such logic at the moment, but it is planned if I understood J2kbr correctly.
You have to handle that logic within your code and update the pmem values at the byteoffset of your UI yourself.
You may call
- Code: Select all
printf("GCMD:InteractiveConfiguration.Refresh");
-
Scachi - Brigadier General
- Posts: 3044
- Joined: Wed May 11, 2016 6:25 am
- Location: Germany
Re: Layman's guide on how to build Interactive Config UI's
prototype wrote:bonefisher wrote:It will always be 7
Why always 7 ? I would do like that:
ToggleAON = (pmem_read(0) >> 1) & 0b1; ToggleBON = (pmem_read(0) >> 2) & 0b1;
This is what I was curious about. I assumed the 7 represented the bit offset.
Can't booleans be assigned to bits in a byte then pulled using the bit offset? That's how it works with bytes, which is why I asked if there was an easier way to do it than run the code through multiple functions to pull bits from bytes.
-
antithesis - Colonel
- Posts: 1912
- Joined: Sat May 28, 2016 10:45 pm
Re: Layman's guide on how to build Interactive Config UI's
Yes i do like that and it works:
MOD1_ON = (pmem_read(0) >> 0) & 0b1;
MOD2_ON = (pmem_read(0) >> 1) & 0b1;
MOD3_ON = (pmem_read(0) >> 2) & 0b1;
MOD4_ON = (pmem_read(0) >> 3) & 0b1;
MOD5_ON = (pmem_read(0) >> 4) & 0b1;
MOD6_ON = (pmem_read(0) >> 5) & 0b1;
MOD7_ON = (pmem_read(0) >> 6) & 0b1;
MOD8_ON = (pmem_read(0) >> 7) & 0b1;
MOD1_ON = (pmem_read(0) >> 0) & 0b1;
MOD2_ON = (pmem_read(0) >> 1) & 0b1;
MOD3_ON = (pmem_read(0) >> 2) & 0b1;
MOD4_ON = (pmem_read(0) >> 3) & 0b1;
MOD5_ON = (pmem_read(0) >> 4) & 0b1;
MOD6_ON = (pmem_read(0) >> 5) & 0b1;
MOD7_ON = (pmem_read(0) >> 6) & 0b1;
MOD8_ON = (pmem_read(0) >> 7) & 0b1;
Console tuner since my 1st controller.
Scripting, a game in the game.
Believe or dare, It's Titanic!
Scripting, a game in the game.
Believe or dare, It's Titanic!
-
Prototype - Major General
- Posts: 3252
- Joined: Sun Dec 16, 2012 1:43 pm
Re: Layman's guide on how to build Interactive Config UI's
prototype wrote:Yes i do like that and it works:
MOD1_ON = (pmem_read(0) >> 0) & 0b1;
MOD2_ON = (pmem_read(0) >> 1) & 0b1;
MOD3_ON = (pmem_read(0) >> 2) & 0b1;
MOD4_ON = (pmem_read(0) >> 3) & 0b1;
MOD5_ON = (pmem_read(0) >> 4) & 0b1;
MOD6_ON = (pmem_read(0) >> 5) & 0b1;
MOD7_ON = (pmem_read(0) >> 6) & 0b1;
MOD8_ON = (pmem_read(0) >> 7) & 0b1;
Now that's exactly how I thought it should work. Thanks for the confirmation, that'll free up some pmem
What about pmem_write operations to those same bits?
-
antithesis - Colonel
- Posts: 1912
- Joined: Sat May 28, 2016 10:45 pm
Re: Layman's guide on how to build Interactive Config UI's
prototype wrote:Yes i do like that and it works:
MOD1_ON = (pmem_read(0) >> 0) & 0b1;
MOD2_ON = (pmem_read(0) >> 1) & 0b1;
MOD3_ON = (pmem_read(0) >> 2) & 0b1;
MOD4_ON = (pmem_read(0) >> 3) & 0b1;
MOD5_ON = (pmem_read(0) >> 4) & 0b1;
MOD6_ON = (pmem_read(0) >> 5) & 0b1;
MOD7_ON = (pmem_read(0) >> 6) & 0b1;
MOD8_ON = (pmem_read(0) >> 7) & 0b1;
Just confirming this works perfectly for toggles in the IC for both reads and writes, so thanks for the info prototype.
I'm not sure however about the syntax to push an update to the IC from a button combo. I can do that easily for a byte (e.g a combobox menu or a toggle dedicated to a full byte, but I'm not sure about bits.
Is it (pmem_write(0) >> 0) & 0b1; etc? That doesn't seem right at a glance.
-
antithesis - Colonel
- Posts: 1912
- Joined: Sat May 28, 2016 10:45 pm
Re: Layman's guide on how to build Interactive Config UI's
antithesis wrote:What about pmem_write operations to those same bits?
+1 I would like to know the best way to do that!
Console tuner since my 1st controller.
Scripting, a game in the game.
Believe or dare, It's Titanic!
Scripting, a game in the game.
Believe or dare, It's Titanic!
-
Prototype - Major General
- Posts: 3252
- Joined: Sun Dec 16, 2012 1:43 pm
Re: Layman's guide on how to build Interactive Config UI's
antithesis wrote:Also, can you explain pointers and how they might be used? Is that "switch" and "case"?
Here is an example on how to use pointer for this purpose, in a similar fashion to what I replied by email to you this morning.
- Code: Select all
const uint8 mode_configs[] = {
// Character, HIP_RF_Mode, ADS_RF_Mode, HIP_AR_Mode, ADS_AR_Mode
10, 1, 1, 1, 1, // Config 1
12, 2, 1, 3, 1, // Config 2
};
const uint16 time_configs[] = {
// HIP_RapidHold, HIP_RapidWait, ADS_AutoHold, ADS_AutoWait
50, 50, 5000, 1500, // Config 1
100, 150, 4000, 1800, // Config 2
};
const fix32 position_configs[] = {
// HIP_Recoil_V, HIP_Recoil_H, ADS_Recoil_V, ADS_Recoil_H
24.5, -7.5, 26.0, 0.0, // Config 1
26.3, -9.2, 32.0, 2.4, // Config 2
};
uint8 *Character, *HIP_RF_Mode, *ADS_RF_Mode, *HIP_AR_Mode, *ADS_AR_Mode;
uint16 *HIP_RapidHold, *HIP_RapidWait, *ADS_AutoHold, *ADS_AutoWait;
fix32 *HIP_Recoil_V, *HIP_Recoil_H, *ADS_Recoil_V, *ADS_Recoil_H;
void load_configuration(uint8 i) {
// Modes
Character = &mode_configs[5 * i + 0];
HIP_RF_Mode = &mode_configs[5 * i + 1];
ADS_RF_Mode = &mode_configs[5 * i + 2];
HIP_AR_Mode = &mode_configs[5 * i + 3];
ADS_AR_Mode = &mode_configs[5 * i + 4];
// Time
HIP_RapidHold = &time_configs[4 * i + 0];
HIP_RapidWait = &time_configs[4 * i + 1];
ADS_AutoHold = &time_configs[4 * i + 2];
ADS_AutoWait = &time_configs[4 * i + 3];
// Position
HIP_Recoil_V = &position_configs[4 * i + 0];
HIP_Recoil_H = &position_configs[4 * i + 1];
ADS_Recoil_V = &position_configs[4 * i + 2];
ADS_Recoil_H = &position_configs[4 * i + 3];
}
init {
load_configuration(0);
}
main {
// Pointers need to be dereferenced with * to get the value, example:
if(*Character == 10) {
}
}
However, the more appropriate way would be use the pointers to index the configuration arrays, something like this:
- Code: Select all
const uint8 mode_configs[] = {
// Character, HIP_RF_Mode, ADS_RF_Mode, HIP_AR_Mode, ADS_AR_Mode
10, 1, 1, 1, 1, // Config 1
12, 2, 1, 3, 1, // Config 2
};
const uint16 time_configs[] = {
// HIP_RapidHold, HIP_RapidWait, ADS_AutoHold, ADS_AutoWait
50, 50, 5000, 1500, // Config 1
100, 150, 4000, 1800, // Config 2
};
const fix32 position_configs[] = {
// HIP_Recoil_V, HIP_Recoil_H, ADS_Recoil_V, ADS_Recoil_H
24.5, -7.5, 26.0, 0.0, // Config 1
26.3, -9.2, 32.0, 2.4, // Config 2
};
uint8 *mode;
uint16 *time;
fix32 *position;
void load_configuration(uint8 i) {
// Modes
mode = &mode_configs[5 * i];
// Time
time = &time_configs[4 * i];
// Position
position = &position_configs[4 * i];
}
init {
load_configuration(0);
}
main {
// Index to access the values
if(mode[0] == 10) { // mode[0] -> Character
}
}
ConsoleTuner Support Team
-
J2Kbr - General of the Army
- Posts: 20323
- Joined: Tue Mar 18, 2014 1:39 pm
Who is online
Users browsing this forum: No registered users and 67 guests