The Dink Network

Potion puzzle

January 31st, 05:06 AM
duck.gif
Toof
Peasant Male
I disagree. 
Here is a little brain teaser that I've got on my hands (and if this turns out to be a monstrosity of a code, forget about it). Also, I don't need an exact script for everything, just a logic behind it (unless, there is a command I maybe that I don't know about).

So, Dink is helping an alchemist, and has to make potions for him. There are, say... 5 potions player should know how to make, and each of them has few of 5 ingredients.

Lets call em 1stPotion, 2ndPotion, etc... and ingredients 1stIng, 2ndIng, and so on. Just to make it clear, let's say that:

1stPotion = 1stIng + 4thIng
2ndPotion = 3rdIng + 1stIng + 5thIng
3rdPotion = 3rdIng + 3rdIng + 1st Ing etc

The order of putting ingredients into pot doesn't matter.

Finally, the alchemist should walk in three times in a row, and ask Dink for a random 1-5 potion to make. This opens a list of all ingredients, and a 'finish' button. Player must know when to finish, and ingredients don't diminish... from the list after being used, cause some of them are might needed twice.

My solution kinda goes like this:
each potion and ingredient is a global variable with a specific number value, say:

1stPotion = 5; 1stIng = 2; 4thIng = 3

So when you add values of ingredients needed, you get the value of potion wanted. I just have to try and avoid the possibility of making same sums with wrong input, by using numbers of very different value.
Is this possible to do? ( Yes / Nooooooooooooooooooooo )

So, finally, how do I make alchemist to order some random potion, and then open a menu with ingredients after which the engine knows which potion is needed to be made?
January 31st, 08:51 AM
wizardg.gif
LeprochaUn
Peasant Male Japan xbox steam bloop
Responsible for making things not look like ass 
Since dink probably doesn't need to collect the ingredients and the mixing is most likely taking place in a single script, I don't think you need to use global variables for them.

This is definitely possible to do. As for doing a random potion, you could do something like:

random(5, 1);

if(&result == 1)
{
//Order 1st Potion
}
if(&result == 2)
{
//Order 2nd Potion
}
etc.

Then you could at the end of the script open up a choice menu, with the options.
MixStart:
wait(1);
choice_start();
set_y 240
set_title_color %
title_start();
"You should be making PotionX right now. What ingredients would you like to add?"
title_end();
"Ing1"
"Ing2"
"Ing3"
"Submit Potion"
choice_end();

if(&result == 1)
{
//add ing1 to the mix
}
if(&result == 2)
{
//add ing2 to the mix
}
etc...
goto MixStart;

if(&result == 4)
{
//submit potion
}

This is probably close to what you want to go for.
January 31st, 11:56 AM
duck.gif
toof
Peasant Male
I disagree. 
I don't think you need to use global variables for them

True. Good observation

And I totally forgot about the 'goto' command. Didn't script anything in a long time. This would be a heck of a lot easier if Dink.C had lists, or arrays, and a way to sort them. Trying to avoid duplicate results with numbers is really messy. Not to mention a small cutscenes between each mixing... This is going to become a monster of a code after all. Oh well...
January 31st, 07:14 PM
peasantmb.gif
yeoldetoast
Peasant Australia steam
discord.gg/Ukugfbh 
Look into Shevek's DinkC preprocessor if you're interested in extra features.
February 1st, 05:59 AM
duck.gif
Toof
Peasant Male
I disagree. 
Ooh, extra features. He did mentioned the preprocessor a while ago, while helping me with my dmod, but I never checked it, because I gave up on it after realizing just how much the scripts I needed were complicated (and maybe uncodable in DinkC alone), plus I ran out of ideas... and hardness... oh the darkness of hardness...

Anyway, I might just flesh out something more reasonable to my skills, in a very distant future, in which the word 'God' transcends to 'Google', 'cause I still have that itch to make something.

In addition, I might write a small 'Noob's friendly scripting almanac' that addresses those little things other tutorials left out (or at least, I never saw them), such as dealing with sprite numbers (properly), changing sprites on screen without leaving and returning to the screen etc... But I forgot what were most of these quacky things that I've encountered... So when I remember...
February 11th, 09:06 PM
duck.gif
toof
Peasant Male
I disagree. 
Due to the lack of real life, he was sitting in front of his computer shocked by his new discovery. The implications were huge, although, maybe not that important, or new, to the rest of humanity... and alienity.

While the awe from the recent insight was slowly wearing down, he decided to bother those duck obsessed lunatics, residing on the Dink network with it... But then, just as wireless network established connection, she suddenly came in, naked. Her breasts


Ok, enough with the 'esteemed bookwriter fantasy'...

I've accidentally discovered that 'IF' statement only checks the first true expression, and feeds the rest to the dead dragon's carcass... carcass. This isn't the question about DinkC alone, but about coding in general.

Suppose I have three booleans [boo1, boo2, boo3] with 3 possible outcomes: true/false/undefined. I know this isn't a clean boolean, but bear with me. All of 'em are independent from each other, but are generated at the same time, randomly.
What I must do, is to make sure that none of them returns true, but I must also keep the possibility of them coming out true. To avoid contradiction, if one or more comes out 'true' it's OK to tweak them to false or undefined, but I must not tweak those who turned out false/undefined.

To paint a better picture, I'll write some imaginary code:
boo1 = random(true, false, undefined);
boo2 = random(true, false, undefined);
boo3 = random(true, false, undefined);

if (boo1 == true) {
    boo1 = random(false, undefined);
    }

else if (boo2 == true) {
    boo2 = random(false, undefined);
    }

else if (boo3 ==true) {
    boo3 = random(false, undefined);
    }

else {
    //nothing else, thank you.
    }


So here is the catch. If statement will only execute as far as first condition is met. So, for an example, if boo1 and boo2 come out 'true', this code above will fix the boo1 state, but it will completely disregard boo2, and boo3.

Any ideas? And feel free to ask me for more information if you need it.
February 12th, 12:43 AM
wizardg.gif
LeprochaUn
Peasant Male Japan xbox steam bloop
Responsible for making things not look like ass 
If statement will only execute as far as first condition is met. So, for an example, if boo1 and boo2 come out 'true', this code above will fix the boo1 state, but it will completely disregard boo2, and boo3.

That's because you wrote "else if"

Just do if() instead of else if() and it should check all three instead of just one.

Else will only run if none of the other if() conditions are met. As soon as one of them is met it will disregard the else() checks.
February 12th, 07:39 AM
anon.gif
Toof
Ghost
 
I always thought that writing 'if' instead of 'else if' is just being plain lazy. Never realized that it has such significant difference.

It's strange how long we can dwell in the dark, because of some dumb reason (or reasoning)

Thank ya!