The Dink Network

Choices in life and in choice menus

July 9th 2018, 12:35 PM
duck.gif
toof
Peasant He/Him
I disagree. 
Gotta admit, recent activity brought me back that itch to make something...
Gotta admit, having several different ideas in head is great, but realizing them in a dmod is hard, and not because of scripting or hardness.

So, I'm in no position to test this, so please let me know if this is possible. I'll need a little bigger choice menu which has different choices depending on some &dumb_and_overly_longly_named_variable. So far, I've been doing things like this:
void talk( void )
{
   if (&dumb_and_overly_longly_named_variable == 1) {
   choice start();
   "Choice #1"
   "Choice #2"
   choice end();
   if(&result==1) {
   //random crap 1
   }
   if(&result==2) {
   //random crap 2
   }
   }
   if (&dumb_and_overly_longly_named_variable == 2) {
   choice start();
   "Choice #1"
   "Choice #2"
   "Choice #3" //now I have more choices
   choice end();
   if(&result==1) {
   //random crap 1
   }
   if(&result==2) {
   //random crap 2
   }
   if(&result==3) { 
   //random crap 2  //now I've chosen those choices
   }
   }
   }

As you can see, this is long and stupid and messy. Lionel Messi. My question, will this work:
void talk( void )
{
   choice start();
   "Choice #1"
   "Choice #2"
   if(&dumb_and_overly_longly_named_variable == 2) {
   "Choice #3"
   }
   choice end();
   if(&result==1) {
   //random crap 1
   }
   if(&result==2) {
   //random crap 2
   }
   if(&result==3) {
   //random crap, but much more observable for the poor soul that produced it, and has to deal 
   //with it
   }
}

If the answer is no, I blame Shevek
July 9th 2018, 02:42 PM
spike.gif
SlipDink
Peasant He/Him United States bloop rumble
2nd generation. No easy way to be free. 
I do not think this will work as you expect it to for several reasons. One is that your variable name is too long (see quote from the DinkC "bible" below). Another is that you need to leave out the "if" in front of this line:
if(&dumb_and_overly_longly_named_variable == 2) { 
"Choice #3"

so it looks like this:
 (&dumb_and_overly_longly_named_variable == 2) "Choice #3"


(from DINKC Reference v3.1)
(2) The & must be followed by 1 to 18 characters to complete the variable's
name. By convention, C rules are followed (first character a letter or
underscore, remainder letters, underscores, or numbers); but in point of
fact, DinkC enforces no such rules. Virtually any non-blank characters
may be used to complete the variable name, including arithmetic
operators such as + and -.
July 9th 2018, 03:06 PM
duck.gif
toof
Peasant He/Him
I disagree. 
variable name is too long
Variable name is a joke. I'm way too lazy to type the name of 18 character variable.

But your solution works? I mean, it is possible to do that in choice menu? It will accept such code and &result will work fine and all. As I've said, I'm not in position to test this at the moment...
July 9th 2018, 04:57 PM
custom_king.png
redink1
King He/Him United States bloop
A mother ducking wizard 
Yeah, this definitely works. It's a weird 'shortcut' that's been baked into choice menus since the very very beginning.

For example, from the herb boot salesman in the original name:

 choice_start();
        set_y 240
        set_title_color 5
        title_start();
"I'm a cobbler/pharmacist.  I make
special herb boots.  When the herb
touches your skin, you'll want to
dance and be hyper."
        title_end();
(&mcrap == 0) "Buy his boots ($500)"
(&mcrap == 0) "Complain about the price"
(&mcrap != 0) "Complain about the price"
"Leave"
 choice_end();
July 9th 2018, 05:58 PM
peasantmp.gif
Skurn
Peasant He/Him Equatorial Guinea duck bloop
can't flim flam the glim glam 
mcrap
July 9th 2018, 06:06 PM
duck.gif
toof
Peasant He/Him
I disagree. 
Oh goodie...You can't imagine how much I was frustrated with choice menus...
July 16th 2018, 02:28 PM
duck.gif
toof
Peasant He/Him
I disagree. 
I'm really embarrassed to ask a question like this, after all these years

I need an intro. It's a blank screen with Dink invisible, and a guy talking (and I need a little fade up effect). I've edited start1.c file to point at intro.c, and I've deleted all that is needed from there.
The script so far:
void main( void )
{
	load_screen();
	draw_screen();
	sp_nodraw(1,1);
	preload_seq(343);
	freeze(1);
	fade_up();
	int &narr = create_sprite(143,231,5,343,4);
	sp_base_walk(&narr, 370);
	sp_speed(&narr, 1);
	wait(1);
	freeze(&narr);
	wait(250);
	say_top("Erm...", &narr);
        //etc

Dink is invisible, but not frozen, and the guy, never shows up...
July 16th 2018, 05:46 PM
spike.gif
SlipDink
Peasant He/Him United States bloop rumble
2nd generation. No easy way to be free. 
Did you perhaps mistakenly delete this last line from start-1.c?

	//We're done, so let's kill this task & the game will begin!
	kill_this_task();
}
July 16th 2018, 08:20 PM
duck.gif
toof
Peasant He/Him
I disagree. 
Nah. Here is the end of the file (start1.c)

    //This turns on the "status bar" for the beginning of the game. If you
    //want to have an "intro", simply comment out the next two lines, then
    //do them both after your intro is over...
	spawn("intro");
    //We're done, so let's kill this task & the game will begin!
    kill_this_task();
}


Edit:
I dunno if it's worth mentioning, since this language is buggy as a corpse eaten by many many many many many many many bugs... I'm using WDE2+, and I edit my scripts with notepad++. It has pretty colors, indentation and shit...

Edited edit edition:
When I said that Dink is invisible, but not frozen, well, I know it because you can hear him when he punches the thin air while I'm pressing CTRL.
July 16th 2018, 09:56 PM
wizardg.gif
LeprochaUn
Peasant He/Him Japan bloop
Responsible for making things not look like ass 
When I said that Dink is invisible, but not frozen, well, I know it because you can hear him when he punches the thin air while I'm pressing CTRL.

That's because you did sp_nodraw() and then never reset the value so he's visible again. (Unless you reset it in intro.c) Also I'm not sure if the issue is that he's invisible or that he can move around while invisible.

Even if you make dink invisible you'll still be able to move him around and have all the interactions you're normally have. You should use freeze(1) to stop movement. I believe that should also stop him from being able to punch things and do really any sort of interaction that isn't skipping text. Though, it has been a while for me. Just remember to unfreeze when you're done.

July 17th 2018, 07:12 AM
duck.gif
Toof
Peasant He/Him
I disagree. 
The first script that I've posted is intro.c. It contains both sp_nodraw(), and freeze() functions. Not to mention that create_sprite isn't working. I remember vaguely that create_sprite() requires several other functions to work properly, such as preload_seq, wait(1), and (possibly) sp_base_walk. But alas...

Edit:
Now that I'm familiar with more languages than just DinkC, can someone shed some light on
int &someSprite = create_sprite(number, number, number, number, number)

I always thought that int is short of initiate or something, it never occurred to me that int is probably integer. Is that integer sprite's object number that is generated automatically or what?
July 17th 2018, 11:40 AM
spike.gif
SlipDink
Peasant He/Him United States bloop rumble
2nd generation. No easy way to be free. 
@ Toof:
> I always thought that int is short of initiate or something, it never occurred to me that int is probably integer. Is that integer sprite's object number that is generated automatically or what?

To quote the Dink Bible*, "The only type of variables that may be defined in DinkC are 32-bit integers (range of values +2147483647 to -2147483648)." So, yes, you are right. In your example, &someSprite is indeed an integer that becomes an "&active_sprite" number for this object, suitable for use in any sp_xxxxx() function, etc.

*=DINKC Reference v3.1 text file.
July 17th 2018, 11:54 AM
duck.gif
Toof
Peasant He/Him
I disagree. 
@SlipDink
Good reminder to download that thing again.

So, I'm checking the intro from my earlier attempts that used to work just fine
old intro file
void main( void )
{

	sp_nodraw(1,1);
	wait(1);
	freeze(1);
	int &drag1 = create_sprite(152,103,0,212,1);
	int &drag2 = create_sprite(452,303,0,216,1);
//etc

Basically, what I read was that wait(1) is needed right after sp_nodraw(), so I've rearranged my new intro script a bit, but still nothing. The &narr sprite is created, dink is frozen (can't even press escape button), and script doesn't continue.
July 17th 2018, 12:06 PM
spike.gif
SlipDink
Peasant He/Him United States bloop rumble
2nd generation. No easy way to be free. 
@toof:
> and the guy, never shows up...

Maybe part of the problem you are having with &narr not seeming to be created is that you tried to create it as a corpse, using brain #5(*) and sprite 343. So, that suggests to me that DinkC should display the red merchant animation, starting from frame 4 and then stop at the end of that animation. But in the next line, you use 370 as the parameter for sp_base_walk() for the newly created &narr sprite, which is actually the blue merchant. I understand why you'd think that should work. After all, Seth seemed to make changes sort of like this all the time, though they were different. Take this example where (as he often does), he uses alot of zeros for create_sprite() and then makes external assignments found in s3-tc.c in the source for the original game.

&pp8 = create_sprite(295, 50, 0, 0, 0);
sp_brain(&pp8, 16);
sp_base_walk(&pp8, 370);
sp_speed(&pp8, 1);
sp_timing(&pp8, 0);
//set starting pic
sp_pseq(&pp8, 373);
sp_pframe(&pp8, 1);
sp_script(&pp8, "s3-peeps");


But perhaps your code does not work because you chose brain 5 for your brain type in your create_sprite() function call and then changed the sprite? Anyway, if you decide to try any of these possible changes(see below), let me know if one of them helps.

int &narr = create_sprite(143,231,16,373,4);
sp_base_walk(&narr, 370);


int &narr = create_sprite(143,231,0,373,4);
sp_base_walk(&narr, 370);
sp_brain(&narr, 5);


int &narr = create_sprite(143,231,0,373,4);
sp_base_walk(&narr, 370);
sp_brain(&narr, 16);


(*)(from DinkC Reference v4.0 from sp_brain() description)
5 Sequence (Corpse) Plays through the current sequence and kills the sprite, but leaves the last frame drawn to the background.
July 17th 2018, 12:25 PM
duck.gif
Toof
Peasant He/Him
I disagree. 
void main( void )
{
	sp_nodraw(1,1);
	wait(1);
	freeze(1);
	int &narr = create_sprite(143,231,0,343,4);
	sp_base_walk(&narr, 343);
	sp_speed(&narr, 1);
	freeze(&narr);
	say_top("Erm...", &narr);


Ok, here is the new one. The person is frozen, never gets to say_stop() part, Dink is also frozen and invisible, and escape button isn't working. The game is basically frozen.
Note, that I've changed brain from 5 to 0, and I've tried sp_base_walk(&narr, 340)
July 17th 2018, 01:00 PM
custom_king.png
redink1
King He/Him United States bloop
A mother ducking wizard 
Base walk should be 340 (always ends with 0).

Say_top should be say_stop?

Escape menu won't work until dink is unfrozen with unfreeze(1)
July 17th 2018, 01:53 PM
spike.gif
SlipDink
Peasant He/Him United States bloop rumble
2nd generation. No easy way to be free. 
I agree with redink1 that sp_base_walk() values should always end in zero. And he is certainly right about say_top() not being valid. About the only thing I'd add here is that I think you need to assign a brain to &narr if functions like sp_base_walk() and sp_speed() are going to do anything (assuming you unfreeze your narrator later).

I'd change your code to look like this:

void main( void )
{
    sp_nodraw(1,1);
    wait(1);
    freeze(1);
    int &narr = create_sprite(143,231,0,343,4);
    sp_brain(&narr, 16);
    sp_base_walk(&narr, 340);
    sp_speed(&narr, 1);
    freeze(&narr);
    say_stop("Erm...", &narr);
July 17th 2018, 02:56 PM
duck.gif
toof
Peasant He/Him
I disagree. 

I wonder how hard would be to implement auto correction for DinkC in visual studio code, or some similar editor. I've actually copied say_top() 12 times, and haven't spotted the error in any of them...
Well, welcome back to the before ancient times, when men were real men, and actually had to bother checking for spelling errors.
Thanks.
July 17th 2018, 05:13 PM
slayer.gif
rabidwolf9
Peasant He/Him United States
twitch.tv/rabidwolf9 
This file has pretty decent error checking function although lacking in other areas.
July 17th 2018, 05:22 PM
duck.gif
Toof
Peasant He/Him
I disagree. 
Yeah, I am familiar with syntax checker. The problem is that I don't take into account that spelling might have caused the error. Well, last time I've attempted a dmod, I gradually adjusted to the idea to check such things in the first place, but the effect fades away over time. Guess this was the warm welcoming slap in the face
July 17th 2018, 07:50 PM
custom_king.png
redink1
King He/Him United States bloop
A mother ducking wizard 
This file adds visual studio style intellisense for DinkC in Notepad++
July 18th 2018, 04:38 AM
duck.gif
toof
Peasant He/Him
I disagree. 
@redink1

You should really add another sticky thread with links to several files such as "an introduction to dmod making", that another scripting tutorial I think Sabre wrote, WDE+, DinkC reference...

Possibly a few links that lead to development topics which address a few common beginner issues.
This site can be confusing for newcomers, and even I forget half of the things I plowed through over the years.

Thanks for the file. Again, I totally forgot about that. Last time, I decided not to use it, because writing commands by yourself completely is a useful learning process if you ask me. But now, it's slowly becoming a chore.
July 18th 2018, 05:03 PM
duck.gif
toof
Peasant He/Him
I disagree. 
Ok, back to the original issue. I understand that this might pose a problem. I need a choice menu, within a choice menu. Like this =>
choice start();
"Option first"
"Option second"
choice end();
  if(&result == 1) {
    //random crap
  }
    if(&result == 2) {
      choice start();
      "Option first"
      "Option second"
      choice end();
      if(&result == 1) {
        //even more random crap
      }
      if(&result == 2) {
        //some action
      }
   }

I understand that it might create a conflict, since both menus use &result. So should I abandon this idea, or not?

Edit:
Don't pay attention to syntax or properly closed braces, just about the possibleness(?) of such script.
July 18th 2018, 05:29 PM
spike.gif
You can save the value of the first &result in another variable, E.g.

choice_start
"Suck bananas"
"Suck mandarins"
choice_end
int &old_result = &result
if (&old_result == 1)
{
choice_start
"Yes"
"No"
choice_end
if (&result == 1)
say("I sucketh the banana",1)
if (&result == 2)
say("I refrain",1)
}
if (&old_result == 2)
say("I sucketh the mandarin",1)
July 18th 2018, 08:30 PM
wizardg.gif
LeprochaUn
Peasant He/Him Japan bloop
Responsible for making things not look like ass 
Honestly it shouldn't really matter so long as you present the choice with additional options last.
Your way shouldn't pose any problems as it currently is, but if you continue to develop choices within choices it might start to pose an issue. Scratchers way solves this issue, but if you're planing to have lots of choices within choices you could use gotos. That's what I normally did.
July 19th 2018, 06:45 AM
duck.gif
toof
Peasant He/Him
I disagree. 
Hmmm. A goto never occurred to me. Combined with my previous question about changing options based on a variable, would actually produce more readable and significantly shorter code, although only in some cases, which are probably the most cases, unless it's a branching conversation.
July 21st 2018, 11:35 AM
duck.gif
toof
Peasant He/Him
I disagree. 
Just a quicky. I've already asked this in the before times, but I can't find where.
So I'm making bartender behind a desk, and when you talk to desk, he responds, standard stuff. In the WDE+ when I press 'i' I get sprite info and number. Da code:
void talk(void)
{
  int &btd = sp(41); //that's the number for bartender
  say_stop("Oh my...", 1);
  say_stop("...so high", &btd);
  //blah blah blah
}

Aaaand, it doesn't work.

Note
I'm fully aware that I can insert void main(void) in the desk script, and initiate bartender from there, but I prefer my method.

EDIT
Scratch that question, the code is good, sprite was background type. No idea how or why...