Jump to content

Photo

Mod ACTION_READLN removal - brainstorming


75 replies to this topic

#61 Jarno Mikkola

Jarno Mikkola

    The Imp

  • Modders
  • 6787 posts
  • Gender:Male
  • Location:The town where the dead haven't keeled over, yet. In Finland.

Posted 10 October 2018 - 01:01 PM

Or else just define some defaults, and revert to the defaults unless the player choices pass validation.

Code that to 3 variables and well see on going with that...
Welcome to the sanity, you are free to search for the limit, it's out there, we drew it in the sand.
Here's how to install all the ... mods you ever really could want to Infinity Engine games. I removed the stable word from there as Roxanne began to add BS mods that are likely to break compatibility from the BWS.

#62 c4_angel

c4_angel
  • Modders
  • 62 posts
  • Gender:Male
  • Location:Shanghai, China

Posted 10 October 2018 - 01:29 PM

I suppose you could make the installer automatically increment a wrong letter by one until it hits a free slot. But yes, it's not not exactly user friendly.

 
 

Or else just define some defaults, and revert to the defaults unless the player choices pass validation.


Thank you both.

But my concern is both doesnt give the users a second chance if any defination goes wrong or they just forget it. It could become a mess when using an install tool if there are mods install after it.

#63 DavidW

DavidW
  • Gibberlings
  • 4516 posts
  • Gender:Male

Posted 10 October 2018 - 03:30 PM

Or else just define some defaults, and revert to the defaults unless the player choices pass validation.

Code that to 3 variables and well see on going with that...

I don't understand what this means.

#64 Ardanis

Ardanis

    A very GAR character

  • Modders
  • 2613 posts
  • Gender:Male
  • Location:Saint-Petersburg, Russia

Posted 10 October 2018 - 04:31 PM

It's fine, I don't either :)


Retired from modding.


#65 Jarno Mikkola

Jarno Mikkola

    The Imp

  • Modders
  • 6787 posts
  • Gender:Male
  • Location:The town where the dead haven't keeled over, yet. In Finland.

Posted 10 October 2018 - 08:32 PM

Code that to 3 variables and well see on going with that... [/quote] I don't understand what this means. [/quote]

It's fine, I don't either :)[/quote] Nice.
@DavidW
K. You propose a principle solution, without any details. I would like a weidu.tp2 code solution for this kind of problem, aka if you have a working .tp2 code example, show it to us.
Why I ask... cause I could use it in my mod. More on why I ask a .tp2 code, is that I could assume that you don't mean a .tp2 solution, but a install tool solution which is not what is asked in the original post, as he already has this in BWS that requires updates to every mod and so forth... which he doesn't want to support any more.


Welcome to the sanity, you are free to search for the limit, it's out there, we drew it in the sand.
Here's how to install all the ... mods you ever really could want to Infinity Engine games. I removed the stable word from there as Roxanne began to add BS mods that are likely to break compatibility from the BWS.

#66 DavidW

DavidW
  • Gibberlings
  • 4516 posts
  • Gender:Male

Posted 10 October 2018 - 11:43 PM

More on why I ask a .tp2 code, is that I could assume that you don't mean a .tp2 solution, but a install tool solution which is not what is asked in the original post

It's just computation and variable substitution; of course it can be done in tp2. Here's a quick version (perhaps there are more elegant ones):
 
// Checks if each of key_1, key_2, key_3 is a letter; replaces it with default value if not; uppercases it in any case.
// Then if any two of key_i, key_j are equal, replaces all three with default values
DEFINE_ACTION_FUNCTION verify_hotkeys
   STR_VAR key_1=""
           key_2=""
           key_3=""
           default_1="A"
           default_2="B"
           default_3="C"
   RET     key_1
           key_2
           key_3
BEGIN
      OUTER_FOR (i=1;i<=3;i+=1) BEGIN
         OUTER_SPRINT letter $key("%i%")
         LAF is_a_letter STR_VAR letter RET value END
         ACTION_IF !value BEGIN
            OUTER_SPRINT letter $default("%i%")
         END
         ACTION_TO_UPPER letter
         OUTER_SPRINT $key("%i%") "%letter%"
      END
      ACTION_IF ("%key_1%" STRING_EQUAL "%key_2%") || ("%key_1%" STRING_EQUAL "%key_3%") || ("%key_2%" STRING_EQUAL "%key_3%") BEGIN
         OUTER_FOR (i=1;i<=3;i+=1) BEGIN
             OUTER_SPRINT $key("%i%") $default("%i%")
         END
      END
END



/// Returns true iff input is A-Z or a-z
DEFINE_ACTION_FUNCTION is_a_letter
   STR_VAR letter=""
   RET value
BEGIN
   ACTION_IF !(STRING_LENGTH "%letter%"=1) BEGIN
      OUTER_SET value=0
   END ELSE BEGIN
      ACTION_IF "%letter%" STRING_MATCHES_REGEXP "[A-Za-z]" BEGIN
         OUTER_SET value=0
      END ELSE BEGIN
         OUTER_SET value=1
      END
   END
END

Edited by DavidW, 10 October 2018 - 11:57 PM.


#67 Jarno Mikkola

Jarno Mikkola

    The Imp

  • Modders
  • 6787 posts
  • Gender:Male
  • Location:The town where the dead haven't keeled over, yet. In Finland.

Posted 11 October 2018 - 04:37 AM

...

Congratulation on input variable validation and substitution of a single character to three variables. But now you need to also take input from the installer, as you have not done so thus far. Aka you made a useful function, but you are not using it yet.
And can weidu use a function that has not been define-d before using it ? It is likely that, I read that from somewhere, but I just want to make sure.
And yeah, it might be a single line... or few in use-case depending things, but that counts.

What I intent to use is a mix of a .tpa coding, ALIENQuake's suggestion on default file and non-default file substitution to switch between the .tpa files, and functions that use their unique variable names on each component... and if the non-default inputs fail if its in the game folder, so what ... it will interrupt the install, as the mod user needs to re-edit that file or remove it to get the default file to usage. And a separated components to use insert the READNL variables during install that has variable verification for each.
This idea is still in the air, cause I haven't had the time and inclination to tackle (a lot of cursing)/it.

Edited by Jarno Mikkola, 11 October 2018 - 04:43 AM.

Welcome to the sanity, you are free to search for the limit, it's out there, we drew it in the sand.
Here's how to install all the ... mods you ever really could want to Infinity Engine games. I removed the stable word from there as Roxanne began to add BS mods that are likely to break compatibility from the BWS.

#68 DavidW

DavidW
  • Gibberlings
  • 4516 posts
  • Gender:Male

Posted 11 October 2018 - 05:17 AM

...

Congratulation on input variable validation and substitution of a single character to three variables. But now you need to also take input from the installer, as you have not done so thus far. Aka you made a useful function, but you are not using it yet.

Sorry, that’s the most of other people’s coding I’m willing to do right now!

#69 CamDawg

CamDawg

    ALL GLORY TO THE HYPNOTOAD

  • Gibberling Poobah
  • 9724 posts
  • Gender:Not Telling

Posted 11 October 2018 - 05:42 AM

 

...

Congratulation on input variable validation and substitution of a single character to three variables. But now you need to also take input from the installer, as you have not done so thus far. Aka you made a useful function, but you are not using it yet.
And can weidu use a function that has not been define-d before using it ? It is likely that, I read that from somewhere, but I just want to make sure.
And yeah, it might be a single line... or few in use-case depending things, but that counts.

What I intent to use is a mix of a .tpa coding, ALIENQuake's suggestion on default file and non-default file substitution to switch between the .tpa files, and functions that use their unique variable names on each component... and if the non-default inputs fail if its in the game folder, so what ... it will interrupt the install, as the mod user needs to re-edit that file or remove it to get the default file to usage. And a separated components to use insert the READNL variables during install that has variable verification for each.
This idea is still in the air, cause I haven't had the time and inclination to tackle (a lot of cursing)/it.

 

Tweaks pretty much has a working example of this. It will accept input from a config file, but if it contains invalid input then it falls back to ACTION_READLN. Granted the input is simpler, but it's had a working config/input scheme with validation since v1.


Why is this Hypnotoad video so popu... ALL GLORY TO THE HYPNOTOAD.


#70 DavidW

DavidW
  • Gibberlings
  • 4516 posts
  • Gender:Male

Posted 11 October 2018 - 06:25 AM

And can weidu use a function that has not been define-d before using it ?


I hadn't originally understood what you meant here. But: WEIDU can't actually use a function before it's defined. But you can include a function in part of the definition of another function before defining it (as I did above). WEIDU isn't strongly typed and doesn't do any kind of validation on variables when you define things; if you do LAF my_function END the install will fail if my_function isn't defined, but the failure happens at install time. You can put that line in a function or macro before you define my_function, provided that you define it before actually running that function or macro.

#71 Jarno Mikkola

Jarno Mikkola

    The Imp

  • Modders
  • 6787 posts
  • Gender:Male
  • Location:The town where the dead haven't keeled over, yet. In Finland.

Posted 11 October 2018 - 06:34 AM

@DavidW, no need to be sorry... and I am glad of the help you, and other give.

Ahh, that's what I read in the ..somewhere. Thanks for the clarification.

Tweaks pretty much has a working example of this. It will accept input from a config file, but if it contains invalid input then it falls back to ACTION_READLN. Granted the input is simpler, but it's had a working config/input scheme with validation since v1.

You probably mean this in ALWAYS:

  ACTION_IF NOT VARIABLE_IS_SET cd_always THEN BEGIN
    OUTER_SET cd_always = 1 // just do this once per install
    ACTION_IF FILE_EXISTS ~cdtweaks/cdtweaks.txt~ THEN BEGIN
      INCLUDE ~cdtweaks/cdtweaks.txt~ // config file
	  ACTION_IF !VARIABLE_IS_SET romance_speed_use_config_values THEN BEGIN OUTER_SET romance_speed_use_config_values = 0 END
	  ACTION_IF !VARIABLE_IS_SET minimum_stats_use_config_values THEN BEGIN OUTER_SET minimum_stats_use_config_values = 0 END
	  ACTION_IF !VARIABLE_IS_SET romance_use_config_values       THEN BEGIN OUTER_SET romance_use_config_values = 0 END
    END ELSE BEGIN    
      OUTER_SET romance_speed_use_config_values = 0
      OUTER_SET minimum_stats_use_config_values = 0
      OUTER_SET romance_use_config_values = 0
    END

Yeah, ... that's like the idea... but I will probably have say 17 integers, a few Y/N -questions and their explanations in // -lines. And definitely non-zero defaults.

Hmm, that doesn't have the ... ACTION_READLN to fall back on to, and the whole folder doesn't contain the term either... unless my Windows can't read it for --- reasons.

Is there a file extension restriction on what the weidu can read via INCLUDE .. as a coding file. I know not to probably make a .wav file for reasons that should be obvious... but other-vice ?


Edited by Jarno Mikkola, 11 October 2018 - 07:00 AM.

Welcome to the sanity, you are free to search for the limit, it's out there, we drew it in the sand.
Here's how to install all the ... mods you ever really could want to Infinity Engine games. I removed the stable word from there as Roxanne began to add BS mods that are likely to break compatibility from the BWS.

#72 CamDawg

CamDawg

    ALL GLORY TO THE HYPNOTOAD

  • Gibberling Poobah
  • 9724 posts
  • Gender:Not Telling

Posted 11 October 2018 - 08:02 AM

The ALWAYS block just reads in the config file, if present. The heavy lifting, so to speak, is still done in the components themselves--the validation of config input and the default to READLN if invalid.


Why is this Hypnotoad video so popu... ALL GLORY TO THE HYPNOTOAD.


#73 c4_angel

c4_angel
  • Modders
  • 62 posts
  • Gender:Male
  • Location:Shanghai, China

Posted 11 October 2018 - 01:39 PM

Here's a quick version (perhaps there are more elegant ones):

Impresive! Thanks DavidW.
And I think an extra component with READLN to reconfigure the hotkeys (and modify the scripts) could fix the typo/conflict issue.

#74 CamDawg

CamDawg

    ALL GLORY TO THE HYPNOTOAD

  • Gibberling Poobah
  • 9724 posts
  • Gender:Not Telling

Posted 11 October 2018 - 04:21 PM

 

Here's a quick version (perhaps there are more elegant ones):

Impresive! Thanks DavidW.
And I think an extra component with READLN to reconfigure the hotkeys (and modify the scripts) could fix the typo/conflict issue.

 

And, if I may, that function can be further shortened. You can dump the string length check and just use a regexp match against ~^[A-Za-z]$~, as it would only match a one-character input.


Why is this Hypnotoad video so popu... ALL GLORY TO THE HYPNOTOAD.


#75 c4_angel

c4_angel
  • Modders
  • 62 posts
  • Gender:Male
  • Location:Shanghai, China

Posted 12 October 2018 - 12:06 PM

Here's a quick version (perhaps there are more elegant ones):

Impresive! Thanks DavidW.
And I think an extra component with READLN to reconfigure the hotkeys (and modify the scripts) could fix the typo/conflict issue.

And, if I may, that function can be further shortened. You can dump the string length check and just use a regexp match against ~^[A-Za-z]$~, as it would only match a one-character input.

Ahh...You just opened a new door to me. Thanks very much.



Reply to this topic



  


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users