List of commits:
Subject Hash Author Date (UTC)
Add string scripting with $ operator 20034a2b658ee8ad4f2082c44301c231b0323fc7 mse 2021-09-03 10:20:55
Enhance console /set command to support operators 61032844fcb833f04e2f6d1e123f8f0f89333107 mse 2021-09-02 11:06:00
Add scriptable bribing & remove hard-coded karma increment 41b4d79da6331b4b1ffd96f36ae1b032a869b482 mse 2021-08-31 17:51:29
Add floor operator (_) 819304b561d474e962afa7397ef68ffae83e8649 mse 2021-08-31 13:49:57
Switch inventories and stats to floating-point c6e4142e664648ca8f4aa913b48526093c985987 mse 2021-08-31 13:35:20
Switch scripting to floating-point & code comments eb067496f4edb4420c05a09dc034ad0a25ad1e56 mse 2021-08-31 11:06:01
Add top-level command: GOSUB 62e9520aec0471fe023ead290595f735a30eb806 mse 2021-08-26 09:31:27
Add persistent VN stats 2d1ffc35afd8ae0f477cbd5aac0559fc02571600 mse 2021-08-23 10:44:16
Bribes increase karma 643f0fc6da65316aa799bbe00cea2030e2c1ccd6 mse 2021-08-17 08:16:36
Add command: #RUMBLE <intensity> <milliseconds> 02964b2ecc57a48192522ef369e33c4912d2f0d2 mse 2021-08-16 07:17:40
Reset position in non-mouse menu selection c21eb6a9d238fa1909dbbbc49907ad09bfca52c8 mse 2021-08-16 03:30:49
Add haptic rumble for combat 65ff172308b0ba26b8930e8e83eb41bd36c6b008 mse 2021-08-15 06:11:25
Reduce joystick sensitivity 3804492a52d36c40cd51d42a971fe92f4fdd52ba mse 2021-08-14 22:37:19
Set audio buffer 1024 to reduce latency b1733b33b3342b32f08e1bafb5baf63ed7db419e mse 2021-07-11 02:56:22
Update readme, deps, bump to v0.5.0 2f96bc1fe9af48874750f2ba507eda5d704313b0 mse 2021-07-05 12:14:52
New license c9932a52aaa81e6b136510157bfc3ce3e10ab800 mse 2021-07-04 16:01:57
Fix joystick dead zone 303dc3276d27f2a123e5370b31b79cdf87afc879 mse 2021-06-26 07:09:28
Windows-compatible locale 65244a8360ad6a65fea64f43f115f5c93bf966dd mse 2021-06-11 17:13:26
Detect language using std::locale 60f1680d73e559dc85f6b85e9ca69cb9be717ae6 mse 2021-06-09 16:11:30
Rename data -> base and load game as mod ec3b8aa10ee005d89d897b43c68cecd4b9ea8a75 mse 2021-06-07 12:31:53
Commit 20034a2b658ee8ad4f2082c44301c231b0323fc7 - Add string scripting with $ operator
Author: mse
Author date (UTC): 2021-09-03 10:20
Committer name: mse
Committer date (UTC): 2021-09-03 10:20
Parent(s): 61032844fcb833f04e2f6d1e123f8f0f89333107
Signing key:
Tree: 8f4583841a5953c59d46645720f00e6229946034
File Lines added Lines deleted
confec.cpp 9 3
include/dialogue.h 21 4
File confec.cpp changed (mode: 100644) (index 76d9309..d3fc62a)
... ... void Render(){
4661 4661 } }
4662 4662 }else if( str.length() > 5 }else if( str.length() > 5
4663 4663 && str.substr( 0, 4 ) == "/get" ){ && str.substr( 0, 4 ) == "/get" ){
4664 double result =
4665 convo.getVariable( str.substr( 5 ) );
4664 std::string key = str.substr( 5 ), result = "";
4665 if( key.back() == '$' ){
4666 key.resize( key.length() - 1 );
4667 auto it = convo.strings.find( key );
4668 if( it != convo.strings.end() ) result = it->second;
4669 }else{
4670 result = convo.stringifyNumber( convo.getVariable( key ) );
4671 }
4666 4672 Notify( Notify(
4667 4673 &tex_notification, &tex_notification,
4668 convo.stringifyNumber( result ),
4674 result,
4669 4675 "" ""
4670 4676 ); );
4671 4677 }else if( str.length() > 5 }else if( str.length() > 5
File include/dialogue.h changed (mode: 100755) (index d57bf57..c927e01)
12 12 #include <cmath> #include <cmath>
13 13
14 14 #include <functional> #include <functional>
15 #include <map>
15 16 #include <string> #include <string>
16 17 #include <vector> #include <vector>
17 18
 
... ... class Talk {
55 56 Screen screen; Screen screen;
56 57 std::vector<Screen> screens; std::vector<Screen> screens;
57 58 std::vector<Variable> variables; std::vector<Variable> variables;
59 std::map<std::string,std::string> strings;
58 60 std::function<double(std::string)> callback; std::function<double(std::string)> callback;
59 61 void go( std::string id ); void go( std::string id );
60 62 void append( std::string filePath ); void append( std::string filePath );
 
... ... bool Talk::hasVariable( std::string key ){
179 181 } }
180 182
181 183 double Talk::getVariable( std::string key ){ double Talk::getVariable( std::string key ){
184 // Apply string replacement to the key.
185 transformString( key );
182 186 if( key == "RAND" ){ if( key == "RAND" ){
183 187 // Returns a (pseudo)random number. // Returns a (pseudo)random number.
184 188 return std::rand(); return std::rand();
185 189 }else if( key.length() >= 8 && key.substr( 0, 8 ) == "CALLBACK" ){ }else if( key.length() >= 8 && key.substr( 0, 8 ) == "CALLBACK" ){
186 190 // Returns the result of the callback function. // Returns the result of the callback function.
187 191 std::string arg = key.length() >= 10 ? key.substr( 9 ) : ""; std::string arg = key.length() >= 10 ? key.substr( 9 ) : "";
188 transformString( arg );
189 192 return callback( arg ); return callback( arg );
190 193 }else if( key.length() >= 5 && key.substr( 0, 5 ) == "GOSUB" ){ }else if( key.length() >= 5 && key.substr( 0, 5 ) == "GOSUB" ){
191 194 // Executes the specified dialogue, then returns 0. // Executes the specified dialogue, then returns 0.
192 195 std::string arg = key.length() >= 7 ? key.substr( 6 ) : ""; std::string arg = key.length() >= 7 ? key.substr( 6 ) : "";
193 transformString( arg );
194 196 go( arg ); go( arg );
195 197 return 0.0; return 0.0;
196 198 }else{ }else{
 
... ... Talk::Talk( std::string filePath ){
305 307
306 308 Operation Talk::getOperation( std::string key, double valueNumber, std::string valueKey ){ Operation Talk::getOperation( std::string key, double valueNumber, std::string valueKey ){
307 309 char op = ':'; char op = ':';
308 if( key.length() > 0 && key.find_last_of( "=!<>?%*/+-_" ) == key.length() - 1 ){
310 if( key.length() > 0 && key.find_last_of( "$=!<>?%*/+-_" ) == key.length() - 1 ){
309 311 op = key.back(); op = key.back();
310 312 key.resize( key.length() - 1 ); key.resize( key.length() - 1 );
311 313 } }
 
... ... Operation Talk::getOperation( std::string key, double valueNumber, std::string v
318 320 } }
319 321
320 322 void Talk::operate( Operation o ){ void Talk::operate( Operation o ){
323 // String assignment.
324 if( o.op == '$' ){
325 transformString( o.valueKey );
326 strings[o.key] = o.valueKey;
327 return;
328 }
329 // Numerical operations.
321 330 double in = o.valueNumber, out = getVariable( o.key ); double in = o.valueNumber, out = getVariable( o.key );
322 331 if( o.valueKey.length() > 0 ){ if( o.valueKey.length() > 0 ){
323 332 in = getVariable( o.valueKey ); in = getVariable( o.valueKey );
 
... ... void Talk::transformString( std::string &str ){
359 368 case '`': case '`':
360 369 if( replacing ){ if( replacing ){
361 370 if( i - start > 1 ){ if( i - start > 1 ){
362 outStr += stringifyNumber( getVariable( str.substr( start + 1, i - start - 1 ) ) );
371 // Add the variable value to the string.
372 std::string key = str.substr( start + 1, i - start - 1 );
373 if( key.back() == '$' ){
374 key.resize( key.length() - 1 );
375 auto it = strings.find( key );
376 if( it != strings.end() ) outStr += it->second;
377 }else{
378 outStr += stringifyNumber( getVariable( key ) );
379 }
363 380 } }
364 381 start = i + 1; start = i + 1;
365 382 }else{ }else{
Hints:
Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"

Clone this repository using HTTP(S):
git clone https://rocketgit.com/user/mse/ConfectionerEngine

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@ssh.rocketgit.com/user/mse/ConfectionerEngine

Clone this repository using git:
git clone git://git.rocketgit.com/user/mse/ConfectionerEngine

You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a merge request:
... clone the repository ...
... make some changes and some commits ...
git push origin main