The Dink Network

Variable question

January 26th 2008, 10:38 PM
sob_scorpy.gif
DinkDude95
Peasant He/Him Australia
The guy with the cute D-Mod. 
Is it possible to do something like this:

&var = Hello

So if you do something like this:

say_stop("&var!", 1);

It will appear something like this:

Dink: Hello!
January 26th 2008, 11:24 PM
fairy.gif
Someone
Peasant He/Him Australia
 
Yes, but not like that
January 27th 2008, 04:40 AM
slimeg.gif
metatarasal
Bard He/Him Netherlands
I object 
See my post here on how to store a string in an integer.
January 28th 2008, 03:36 AM
sob_scorpy.gif
DinkDude95
Peasant He/Him Australia
The guy with the cute D-Mod. 
So, if I do this:

int &txt1 = H
int &txt2 = e
int &txt3 = l
int &txt4 = o

say_stop("&txt1&txt2&txt3&txt3&txt4!", 1);

Dink will say "Hello!"?
January 28th 2008, 04:34 AM
custom_magicman.gif
magicman
Peasant They/Them Netherlands duck
Mmmm, pizza. 
The short answer: No, you can't. Variables only store numbers.

The long answer: No, you can't. You can store strings in variables by encoding them as numbers (a = 1, b = 2, c = 3, etc...), but there's no way to get back to the string.

If it were possible to store strings in variables, and use them as strings, then I'd like to hear about it. Especially if they'd be usable in things like external(), because that'd rock.
January 28th 2008, 06:19 PM
sob_scorpy.gif
DinkDude95
Peasant He/Him Australia
The guy with the cute D-Mod. 
Oh well. See, I was thinking about having a D-Mod where you can have your own customizable character, with a customizable name, and the name would be stored in &name or something. But it doesn't matter. Too much effort, anyway.
January 29th 2008, 02:37 AM
fairy.gif
Someone
Peasant He/Him Australia
 
It's very possible to get them back to strings. You just need to display one character at a time. So it's easier with a font where very character is the same width.

Make an exteral("something","say_str_xy",var,x,y) type function like this:

int &x = &arg2;
int &ntimes = 0;

loop:
//extract next letter from &arg1
if (&letter == 0) say_xy("A",&x,&arg3);
//etc
&x += <width of chars>;
&ntimes += 1;
if (&ntimes <= 6)
goto loop;

Because you can't pass strings in an external() nor determine the number of characters in a string you need to work out the x and y's if you wanted to have text on each side of the string (e.g. "Hi there, &name! How are you? is possible with an say_xy for "Hi there, " and one for "! How are you?" but you need to calculate the x/y yourself which isn't too hard but annoying if you want to do it a lot)