The Dink Network

What are all the keys that can be used in scripts?

June 10th 2024, 11:11 PM
fairy.gif
Pupperoni
Peasant He/Him United States
Takes an idiot to make an idiot 
Y'know, like Pilgrim's Quest's "S" key to pull up extra stats or Dink Goes Boating's "T" key for the Tutorial Mode.
June 10th 2024, 11:43 PM
custom_simon.gif
SimonK
Peasant He/Him Australia
 
DinkC Ref Click here!
June 11th 2024, 12:23 AM
peasantmb.gif
yeoldetoast
Peasant They/Them Australia
LOOK UPON MY DEFORMED FACE! 
June 11th 2024, 04:19 AM
custom_robj.png
Robj
Jester He/Him Australia
You feed the madness, and it feeds on you. 
I believe some of the DinkHD key codes in that uploaded file are inaccurate for the latest version of DinkHD. I can't remember when but at some point in an update, I'm almost positive the odd keys(non letter and number keys) changed key codes.

Please note, I could be wrong, but I'm confident they changed at some point. Worth testing. Unfortunately with DinkHD pressing a key doesn't display the key code in the log or console unless the key code script exists in the story folder(even if it's just a blank script).

I used a python script to just generate a bunch of key-### codes up to 256 and use that so they'll display in console so I can check. Although as part of that generation script it also generates a main procedure with a say line that makes Dink say "This key is key ###" where ### is the actual key code, just so I don't have to check debug, or console and I can rapidly check key codes by just hitting them. Dunno if it'd be worth uploading that, other than checking key codes it's an otherwise redundant file. Also not hard for someone to also generate those scripts in the same way to do the same tests.
June 11th 2024, 10:16 AM
peasantmb.gif
yeoldetoast
Peasant They/Them Australia
LOOK UPON MY DEFORMED FACE! 
There's also the consideration that these may only apply to US keyboard layouts. I believe Scratcher had trouble with that in the past. In general however, I find that alphabetical key codes work best, and usually correspond to their uppercase ASCII value meaning values below 32 probably aren't useful.

I decided to write a Python3 program that does what you describe in case it's hard for anyone:

for i in range(256):
    with open("key-" + str(i) + ".c", "w") as f:
        f.write("void main()\n{\nint &key = " + str(i) + "\nsay(\"Key &key\", 1)\n}")


If you save it in STORY as keycodegen.py and run it with python3 keycodegen.py (py -3 on windows), it'll generate a bunch of key-*.c files to test with. Preferably use your designated testmod, as it'll overwrite existing key scripts. It might be worth posting our findings if the spreadsheet's out of date.

edit: more complete revision which doesn't overwrite existing key scripts and cleans up script slot afterwards
June 12th 2024, 04:31 PM
fairy.gif
Pupperoni
Peasant He/Him United States
Takes an idiot to make an idiot 
Thank you guys! You just helped me unlock a whole slew of ideas for future Dmods!
Test 'em out in the Evolving Magic Demo whenever the patch gets approved! ^ ~ ^
June 12th 2024, 09:14 PM
pq_knight.gif
ExDeathEvn
Peasant He/Him New Zealand rumble
"Skinny Legend" 
Only downside is that using custom keys for different actions or commands isn't viable for the poor phone players very easily, if at all.
June 12th 2024, 09:33 PM
fairy.gif
Pupperoni
Peasant He/Him United States
Takes an idiot to make an idiot 
I'm sure some talents programmer out there could do it.
Iiiit's just not me.
June 12th 2024, 10:35 PM
custom_robj.png
Robj
Jester He/Him Australia
You feed the madness, and it feeds on you. 
There are a couple options for keyboard key presses for phone users.
One is they could connect a keyboard to their phone (probably not viable for most people)

The other is to re-purpose the map button on the touch screen, and make it throw Dink into mouse mode and display an "on-screen" keyboard over the status bar menu, and if any of the keys are touched it calls the same key-### scripts as pressing the proper key. Takes a bit of setup, but I have it working in a (so far)unreleased Dmod, Im still refining it though, but it works. Also, the player can still use the map, just add the map as one of the buttons along with the on screen keyboard, you can also add other buttons this way for the player to quickly press extra things in the dmod. It's much quicker than them trying to go to the DinkHD menu and open the phones keyboard in the action of the game, it refines it down to 2 quick clicks - open the keyboard, press the key. You can also pause the enemies on the screen when it's displayed (since Dink is in mouse mode), I just used sp_disabled on a loop (since disable_all_sprites) is bugged, to temporarily stop the enemies. And then re-enable them when done. As I said, takes some work, but it can work. I might release something later for it, but I have too many projects on the go atm and I never seem to actually get anything finished.
June 12th 2024, 10:41 PM
custom_simon.gif
SimonK
Peasant He/Him Australia
 
And currently there is a bit of bug on mobile with key presses, the engine reads the press twice, which is a bug with PQ on mobile for the Frog-bot activation/de-activation using the F-key, as one press activates it and the next deactivates it etc. So on mobile you can't toggle between the two states.

Seth was going to look into this.

I did try pitching the idea of having 4 visible button icons on screen for mobile versions, which could be configured in DinkC to Seth, but a fair bit of work to do this, which is beyond my skills.

It may be possible to achieve it with just DinkC and keeping the mouse active as a pointer, similar to the start.c script with the buttons you can press to either START, LOAD, QUIT etc.
June 12th 2024, 11:02 PM
custom_robj.png
Robj
Jester He/Him Australia
You feed the madness, and it feeds on you. 
> It may be possible to achieve it with just DinkC and keeping the mouse active as a pointer, similar to the start.c script with the buttons you can press to either START, LOAD, QUIT etc.

It's a good idea, but you can't have Dink mode and mouse mod active at the same time, unfortunately (none of the normal Dink action keys on the kayboard will work while in mouse mode), so it does have to be a toggle. But toggle can work. Hopefully Seth fixes that bug, but also, that on screen keyabord idea would solve that problem of the double press, since it isn't an actual keyboard press anymore. It's an in-game button calling the script.

Also I was just thinking, bit of a crude fix until he looks into it, but if a double key press happens on every key press and not randomly, could you account for this in the script if the player is on phone (you can check the platform using get_platform, a return value of 1 or 4 would mean the player is playing on iphone or android). You can then do something like increment a variable each time and if it equals 1, kill the script instantly, so it only runs on even numbers(every second press). Could use a custom key for this so it doesn't use a global variable.

something like:
//retrieve the value, increment it and re-store it without using a global variable
int &phonefix = sp_custom("phone_fix", 1, -1);
&phonefix += 1;
sp_custom("phone_fix", 1, &phonefix);

&phonefix = math_mod(&phonefix, 2);
if (&phonefix == 1)
{
//odd number, kill this
kill_this_task();
}

I guess it's really something that shouldn't have to be fixed with DinkC though, and should be fixed by Seth, and if you add this and then it does get fixed in the engine, then you have to remove it again, unless you also enclose that entire check in a get_client_fork() and get_version() to only make it active for <= the current DinkHD version (assuming Seth will fix it in the next version).
June 13th 2024, 03:06 AM
peasantmb.gif
yeoldetoast
Peasant They/Them Australia
LOOK UPON MY DEFORMED FACE! 
So far i've tested in yedink (likely same for freedink) on a US layout on macOS:

A-Z: uppercase ASCII value
B, N, M: reserved for music pause/resume and button6
1 to 5: 30-34
6 to 0: reserved for button scripts
F1 to F12: 58-69
Insert to Page Down: 73-78
- and +: 45-46
Left bracket down to ?: 47-56
Backtick: 53
Backspace: 42
Numpad starting at / and going clockwise round to 9: 84-97 plus a few more

Brief testing in RTDink on windows suggests that anything other than A-Z will most likely have a completely different scancode, with many keys overlapping others such as delete and backspace. One must consider, what does a Hebrew or Cyrillic layout user do when asked to press the "T" key for example?
June 13th 2024, 07:07 PM
custom_simon.gif
SimonK
Peasant He/Him Australia
 
The other solution is to remove the frog-bot disguise as a key press and make it an actual item. I started doing this for the redux, but stopped because I really like the ability to press a key and have an immediate response rather than work through the inventory button system.

Yet, if the mobile solution doesn't happen in a couple of weeks I'll probably go back and make the Frog-bot thing an item in the inventory.
June 14th 2024, 03:49 AM
pq_knight.gif
ExDeathEvn
Peasant He/Him New Zealand rumble
"Skinny Legend" 
The other solution is to remove the frog-bot disguise as a key press and make it an actual item

At least the disguise is more like a suit, so for an item you would have to equip it's viable. An alternative could be if you turned it into a spell, so it'd be armed and just casting to switch, at the cost of a combat spell.
With consumables like an elixir, adding a shortcut key to heal vs how we set up multi-consumption in Charlie's Legacy is something else that could have been considered, and separating said consumables to free inventory space, but in that situation we didn't add enough equipment items to need it.

I can understand adding additional keys for alternative options being useful in the long term though; maybe there's a simpler way to detect a keypress and lock it out of being able to be pressed again for a delay to solve the double press issue for mobile.
June 14th 2024, 08:41 AM
custom_robj.png
Robj
Jester He/Him Australia
You feed the madness, and it feeds on you. 
FIX dupe keycall bug on phone below, will work now and forever, even if Seth fixes the engine bug and/or breaks it again in any future release!

This fix uses no new global variables, and no editor_seq or editor_frame fake variables, it won't interfere with your dmod. It only stores things in unique sp_custom key values on sprite 1 (Dink).

Good thing is, this fix does not check for if the player is playing on the phone specifically, it only checks if any time at all has passed between the previous key### script and the new one. I did some testing, and the duplicate script on phone is called at exactly the same time as the first one without even 1 millisecond delay. So I wrote a procedure you can call from external that will return the time between the previous key### script call and the current one, then you just check the return value and if it equals 0, do a kill_this_task(). All this will do is make sure there has to be at least 1 millisecond between script calls for whichever key### scripts that have this applied.

It can be applied to key scripts and I tested it on PC DinkHD which doesn't have the dupe bug, and it doesn't interfere, so even if Seth fixes the bug, you don't have to remove it!

All you have to do is put the following script in your story folder: dupekill.c

And then put this at the very top of the main procedure of your key-### so it runs before anything else:
 external("dupekill", "dupekill");
 int &dupekill = &return;
 if (&dupekill == 0)
 {
  //There was no delay since the last key-### call and this one!
  //dupe key-### call detected without even a millisecond between calls - kill this off now!
  kill_this_task();
 }

June 15th 2024, 11:21 AM
peasantmb.gif
yeoldetoast
Peasant They/Them Australia
LOOK UPON MY DEFORMED FACE! 
Something just occurred to me, the key scripts button6 through to button10 are supposed to be configurable as assignable gamepad buttons in the escape menu, and also triggered on numbers six through zero, although that doesn't seem to be the case in RTDink where they just trigger scancodes or perhaps both.

They'd also be a much cleaner way to implement a usable shortcut, and those number keys are fairly standard across international keyboard layouts. Nobody wants to have to reach for the keyboard while they're using a controller.

Do any iOS/Android users want to tell us which controller they use, or if they have a Retroid Pocket etc, and if reassigning in the escape menu works? Surely nobody's masochistic enough to be using the touch screen as the primary mode of input.
June 17th 2024, 02:31 AM
custom_simon.gif
SimonK
Peasant He/Him Australia
 
I have a game controller for my iPad, which I was using for Fortnite a few years back. So charged it up for a Dink Smallwood iPad test.

I tried renaming the scripts in PQ that use the keyboard - "A" for Skard attacking, "C" for Cthullos casting a sleep spell, "F" for Frog-bot mode and "H" for instant heal to buttons 6 to 10 but no response on the iPad using a Nimbus Steelseries gc-0004 controller when testing this version of the DMOD.

As far as I could figure out, even changing the options via the standard Dink Menu which is meant to let you assign the current six available options to buttons 7 thru 10, such as Map to button 8, Dink Menu to button 7, talk to button 9, and Inventory to button 10, pressing any of the buttons on the front of the console other than the left front top one, which must be button 6 for this controller as it triggered the "I don't have a map for this world" in the End World. (Buttons 1 thru 4 are "A, B, X, Y" on the top right side of the controller, button 5 is the MENU button on the top middle of the controller.

//this is run when the escape key is pressed

void main(void)
{
int &old_result;
Playsound(18, 22050, 0,0,0);
freeze(1);
help:

        choice_start();
        "Load a previously saved game"
        "Restart"
        "Quit to Windows"
        "Help"
        "Continue"
        "View/change gamepad buttons"
        choice_end();


So not sure what &buttoninfo is doing as such here, as this is where the DinkC code deals with "View/change gamepad butttons"

   if (&result == 6)
   {
   buttonstart:
        choice_start();
        "Button 1 - &buttoninfo"
        "Button 2 - &buttoninfo"
        "Button 3 - &buttoninfo"
        "Button 4 - &buttoninfo"
        "Button 5 - &buttoninfo"
        "Button 6 - &buttoninfo"
        "Button 7 - &buttoninfo"
        "Button 8 - &buttoninfo"
        "Button 9 - &buttoninfo"
        "Button 10 - &buttoninfo"
        "Nevermind"
        choice_end();

if (&result != 11)
  {
  &old_result = &result;
        choice_start();
        set_y 140
        title_start();
What should button &old_result do?
        title_end();
        "Attack"
        "Talk/look"
        "Magic"
        "Item screen"
        "Main menu"
        "View map (if you have one)"
        "Nevermind"
        choice_end();
  if (&result < 7)
   set_button(&old_result, &result);

   goto buttonstart;
  }
    
       goto help;

   }

   if (&result == 7)
   {
        choice_start();
        "&savegameinfo"
        "&savegameinfo"
        "&savegameinfo"
        "&savegameinfo" 
        "&savegameinfo" 
        "&savegameinfo" 
        "&savegameinfo" 
        "&savegameinfo" 
        "&savegameinfo" 
        "&savegameinfo" 
        "Nevermind"
        choice_end();

   save_game(&result);

   }

  unfreeze(1);
  kill_this_task();


Shame this didn't work, as the controller has three unused buttons at the front when playing Dink: front bottom left (button7 ?), front top right (button8 ?) front bottom right (button9 ?) and the right joystick maybe that's button 10?

But as I don't use the "map" in the End World of PQ and Frog-bot mode is only available in the End World, I'm going to test changing the button6.c script to be a Frog-bot mode toggle.
June 17th 2024, 04:28 AM
peasantmb.gif
yeoldetoast
Peasant They/Them Australia
LOOK UPON MY DEFORMED FACE! 
Buttoninfo is magically replaced by the button action. The last four, quite helpfully labelled "unused" are button actions 7 through 10.

Here are the raw keybindings which are somewhat confusing to me, but may suggest that Seth hasn't bound those extra buttons.
June 17th 2024, 04:53 AM
custom_simon.gif
SimonK
Peasant He/Him Australia
 
Oh well, shame they aren't available or customizable via DinkC as in, the game engine detects any key-##.c scripts the DMOD has and gives the player the opportunity to choose which one of those they assign to which buttons.

Either way, making the button6.c script in PQ toggle the frog-bot works fine so the next patch will include that. It makes playing in the End World easier once Dink can disguise himself/Skard as a frog.