Author Topic: Danmakufu Q&A/Problem Thread v3  (Read 213425 times)

Fujiwara no Mokou

  • Hourai Incarnate
  • Oh, so this trial of guts is for ME?
    • Profile
Re: Danmakufu Q&A/Problem Thread v3
« Reply #570 on: April 15, 2010, 09:46:27 PM »
Aaaah, so the function I'm looking for is 'ToString'.
But would an array work if I were to just plug it in? Or would I have to use the function 'ToString' each time?
For example,

Code: [Select]
let v=5;

LoadGraphic(image[v]);

Would it ignore the array and load the picture named 'image[v]' because it doesn't recognize the array because there's no 'ToString' function? By the sound of it, I'm going to have to use ToString everytime I want to deal with variables and strings.

By the way, would LoadGraphic(image~ToString(v)) work? Or, will I have to use "" to label what's the string, so LoadGraphic("image"~ToString(v));
Also, what if I want to use "" in my string?  lets say the variable is I'm using is "v" .   Could I just go on and plug in LoadGraphic("image"~ToString("v")); ?

Iryan

  • Ph?nglui mglw?nafh
  • Cat R?lyeh wgah?nagl fhtagn.
Re: Danmakufu Q&A/Problem Thread v3
« Reply #571 on: April 15, 2010, 10:01:13 PM »
In theory, if your array image is an array that stores the paths of your image files as strings, image[n] will output the path of the respective image in form of a string. In that case LoadGraphic(image[n]); should work.

About the other stuff I have no clue.
Old Danmakufu stuff can be found here!

"As the size of an explosion increases, the numbers of social situations it is incapable of solving approaches zero."

Fujiwara no Mokou

  • Hourai Incarnate
  • Oh, so this trial of guts is for ME?
    • Profile
Re: Danmakufu Q&A/Problem Thread v3
« Reply #572 on: April 15, 2010, 10:17:23 PM »
I guess I'll never know that one.
Alright, one last thing before I get back to work.
What do I do if I want a number in a number of specified digits? Lets say...4
So a function that normally return 5 will return 0005, or if it would return .05 to return 0.005
I want to avoid getting number that would normally return 15 return 00015. I would want that same function to return 0015 instead.
« Last Edit: April 15, 2010, 10:22:07 PM by Fujiwara no Mokou »

Iryan

  • Ph?nglui mglw?nafh
  • Cat R?lyeh wgah?nagl fhtagn.
Re: Danmakufu Q&A/Problem Thread v3
« Reply #573 on: April 15, 2010, 10:24:31 PM »
I guess I'll never know that one.
Alright, one last thing before I get back to work.
What do I do if I want a number in a number of specified digits? Lets say...4
So a function that normally return 5 will return 0005, or if it would return .05 to return 0.005
I want to avoid getting number that would normally return 15 return 00015. I would want that same function to return 0015 instead.

Useful Miscellaneous Code Snippets, first post.  ;)
Old Danmakufu stuff can be found here!

"As the size of an explosion increases, the numbers of social situations it is incapable of solving approaches zero."

Re: Danmakufu Q&A/Problem Thread v3
« Reply #574 on: April 15, 2010, 10:27:30 PM »
@Fujiwara No Mokou:

You can't name a variable with quotes in it, and even if you could, don't. ToString converts any other data type to a String. If you put quotes around anything, Danmakufu treats that (appropriately) as a String.

Code: [Select]
let v=5;
LoadGraphic(image[v]);

Would it ignore the array and load the picture named 'image[v]' because it doesn't recognize the array because there's no 'ToString' function? By the sound of it, I'm going to have to use ToString everytime I want to deal with variables and strings.

If the array "image" holds Strings in it, then you won't have to use ToString. For example:

let image = ["sound1.wav", "sound2.wav", "sound3.wav", "sound4.wav", "sound5.wav", "sound6.wav"];
let v = 5;
LoadGraphic(image[v]);

Will tell Danmakufu to load the graphic represented by the String in the 6th place of the array called image.

If the array held anything other than Strings, like numbers for example:

let image = [1, 2, 3, 4, 5, 6];
let v = 5;
LoadGraphic(image[v]);

This would error, because it's trying to load a number as a graphic (the 6th place in the array image is a number), which isn't possible. So you'd need to convert that number to a String so it would be read properly:

let image = [1, 2, 3, 4, 5, 6];
let v = 5;
LoadGraphic(ToString(image[v]));

Now this probably wouldn't do anything because you're trying to load a file called "6.000000" in your root directory, which probably doesn't exist. So in my example, I added GetCurrentScriptDirectory to add a larger pathname to the file, and I also added ".png" to the end of the string to make sure it knows what file to load, specifically. ~ concatenates Strings.

Quote
By the way, would LoadGraphic(image~ToString(v)) work? Or, will I have to use "" to label what's the string, so LoadGraphic("image"~ToString(v));

No, neither would work. if image is a String:

let image = "effect";

Then you would have the following in the first example:

let v = 5;
let image = "effect";
LoadGraphic(image~ToString(v));

Loading a graphic called "effect5.000000". All numbers are stored as the long data type in danmakufu, so converting any number to a string shows all the decimal places. In my previous example, I added in code that shaves off all those needless decimal places.

For your second example, LoadGraphic("image"~ToString(v)); will load an image called "image5.000000", which is more wrong than the first example, heh. Again, Danmakufu treats everything inside quotes as a String, and it ignores any similarities the String may have with an existing variable.

Quote
Also, what if I want to use "" in my string?  lets say the variable is I'm using is "v" .   Could I just go on and plug in LoadGraphic("image"~ToString("v")); ?

Well, you can't start a variable name with a quote, so that's not possible. Disregarding the error I just mentioned regarding "image" being taken as a String instead of a variable, you'd still have to fix those quotes inside the strig by indicating to Danmakufu that those quotes do not end the String. There is a special character \ which indicates to Danmakufu that some letter near it is meant to be treated as part of the String and not as it's special character identity. I'd explain how to use it, but Danmakufu fucks it up so hard that I honestly am not sure if it treats the next letter as a String, or the letter before it (it should be the one after it, but fuck some example I've seen).

For example:

Say you want to display

Awesome Sign "You Are Screwed"

as a spellcard name. You'd need to have the following code in your CutIn:

CutIn(YOUMU, "Awesome Sign "\""You Are Screwed"\", "", 0, 0, 0, 0);
//the last five parameters are for the image, so ignore them

Now it looks like the \ character is correctly indicating that the character after it is to be displayed properly, but by that logic the string ends at

"Awesome Sign "

Which is no good. Going the other way, if the \ character indicates the letter before it is to be left in the String, the String should end at

"Awesome Sign ""

Which is even more >: |

So I ask this to more experienced programmers than I, how does this escape character work!?

What do I do if I want a number in a number of specified digits? Lets say...4
So a function that normally return 5 will return 0005, or a if it would return .05 to return 0.005
I want to avoid getting number that would normally return 15 return 00015. I would want that same function to return 0015 instead.

To display 00015, you would need to have it as a String. Numbers will automatically shave off all zeros before any non-zero number. So then you could just add zeros...:

let number = "000" ~ "15";

//number is now "00015"

Going the other way, you'd still need to convert the number to a String to prevent Danmakufu from displaying all six decimal places:

let number = 0.5;
let string = ToString(number);
//string is now equal to "0.500000"

loop(3){
   string = erase(string, length(string)-1);
}

//string now equals "0.500"

Useful Miscellaneous Code Snippets, first post.  ;)

Drake's code adds commas and useless shit :V

EDITs: fixed my speedtypin' errors
« Last Edit: April 15, 2010, 10:35:59 PM by Naut »

Fujiwara no Mokou

  • Hourai Incarnate
  • Oh, so this trial of guts is for ME?
    • Profile
Re: Danmakufu Q&A/Problem Thread v3
« Reply #575 on: April 15, 2010, 10:51:59 PM »
I'm not looking for comas in place of decimals.
Actually, scratch what I asked. How do I get the number of digits in a given number? Is there even a function for that?
I'm looking at function int() and trunc() but I'm not sure what they do.

Re: Danmakufu Q&A/Problem Thread v3
« Reply #576 on: April 15, 2010, 10:59:26 PM »
I'm not looking for comas in place of decimals.
Read my post >: |

Actually, scratch what I asked. How do I get the number of digits in a given number? Is there even a function for that?
I'm looking at function int() and trunc() but I'm not sure what they do.

Convert it to a string, use length(String);

let number = 84368907;

let temp = "";

temp = ToString(number);

let digits = length(temp);

//digits is now equal to the length of temp, or 8.

int() does the same thing as trunc() and truncate(), which just elimates all the decimal places and converts them to zeroes. so:

int(5.2319);
trunc(5.2987);
truncate(5.21037);

All equal 5.000000.

I assume there was plans to include the int data type in Danmakufu, but instead mkm just decided to use all longs? Or does the int data type actually pop up anywhere? Nowhere I've seen, anyway.
« Last Edit: April 15, 2010, 11:03:16 PM by Naut »

Fujiwara no Mokou

  • Hourai Incarnate
  • Oh, so this trial of guts is for ME?
    • Profile
Re: Danmakufu Q&A/Problem Thread v3
« Reply #577 on: April 15, 2010, 11:06:38 PM »
I thought function length() only works for arrays? It works for digits too? That's a surprise.

Re: Danmakufu Q&A/Problem Thread v3
« Reply #578 on: April 15, 2010, 11:13:09 PM »
Err, well it doesn't work for numbers. It does work for Strings and arrays, since to Danmakufu, they are the same thing. A String is just an array of characters.

Fujiwara no Mokou

  • Hourai Incarnate
  • Oh, so this trial of guts is for ME?
    • Profile
Re: Danmakufu Q&A/Problem Thread v3
« Reply #579 on: April 15, 2010, 11:30:26 PM »
Would that mean

let arr=[t,e,s,t];
return arr
be the same as
return "test"  ?
« Last Edit: April 15, 2010, 11:32:01 PM by Fujiwara no Mokou »

Re: Danmakufu Q&A/Problem Thread v3
« Reply #580 on: April 15, 2010, 11:38:38 PM »
Would that mean

let arr=['t','e','s','t'];
return arr
be the same as
return "test"  ?

Fixed your notation, and yes, it would.

Fujiwara no Mokou

  • Hourai Incarnate
  • Oh, so this trial of guts is for ME?
    • Profile
Re: Danmakufu Q&A/Problem Thread v3
« Reply #581 on: April 16, 2010, 01:05:38 AM »
Alright. I'll put this on pause for a while. Back to what I was trying to do-
your function earlier...
ascent(i in 1..21){
      let string = "" ~ ToString(i);
      let number = 0;
      let result = "";
      while(number < length(string) && string[number] != '.'){
             result = result ~ ToString(string[number]);
             number++;
      }
      LoadGraphic(GetCurrentScriptDirectory~"effect"~result~".png");
      LoadGraphic(GetCurrentScriptDirectory~"sound"~result~".wav");
}

Loads effect1.png to effect20.png and sound1.wav to sound20.wav.

look at dem colors
Spoiler:
LoadGraphic doesn't load sounds
Where as this helps me load the files, I can't actually call them in DrawLoop.
Instead of writing SetTexture(GetCurrentScriptDirectory~"effect"~result~".png") I'd like to write SetTexture(effect1)
I try to use variables whenever I load stuff to make things easier for myself.

Problem, though, is,
Code: [Select]
ascent(i in 1..21){
let effect~i=GetCurrentScriptDirectory~"effect"~ToString(i)~".png";

  }
won't work. I need to find a way to attach numbers to the end of variables. Know a way to do that?

Azure Lazuline

  • Looooove!!
  • PM me for free huggles and love!
    • Entanma Project - indie game development
Re: Danmakufu Q&A/Problem Thread v3
« Reply #582 on: April 16, 2010, 01:12:03 AM »
He told you everything you need to. If it's not working, then you need to give more details rather than saying "it doesn't work."

Fujiwara no Mokou

  • Hourai Incarnate
  • Oh, so this trial of guts is for ME?
    • Profile
Re: Danmakufu Q&A/Problem Thread v3
« Reply #583 on: April 16, 2010, 01:17:21 AM »
He told you everything you need to. If it's not working, then you need to give more details rather than saying "it doesn't work."

you didn't read my post. I said what I was looking for. Did you look above the code, rather than just reading what was on the bottom?

Azure Lazuline

  • Looooove!!
  • PM me for free huggles and love!
    • Entanma Project - indie game development
Re: Danmakufu Q&A/Problem Thread v3
« Reply #584 on: April 16, 2010, 01:23:01 AM »
To attach numbers to the end of variables, you use that function he gave you again. The problem is that by default DMF loads numbers with 6 decimal places. Here's a modified version of that code:
Code: [Select]
function IntString(number){
   let str = ToString(number);
   let str2 = "";
   let i = 0;
   while (str[i] != '.')
   {
      str2 = str2 ~ [str[i]];
      i++;
   }
   return(str2);
}
Then just use IntString(number) in place of everywhere you use ToString. If you don't want to write
SetTexture(GetCurrentScriptDirectory~"effect"~IntString(var)~".png"); every time, just write a function for it:

Code: [Select]
function SetTextureNew(num){
SetTexture(GetCurrentScriptDirectory~"effect"~IntString(num)~".png");
}

Fujiwara no Mokou

  • Hourai Incarnate
  • Oh, so this trial of guts is for ME?
    • Profile
Re: Danmakufu Q&A/Problem Thread v3
« Reply #585 on: April 16, 2010, 02:56:51 AM »
I finally got Naut's function to work now.
This was useful too. But it wasn't really what I was looking for -when I said "attach numbers to variables".
My goal is, to be able to put in SetTexture(effect1); SetTexture(effect2);, or even have a function that can do that for me.
The actual string itself is represented by a variable. I'm looking for a way to easily define these variables as strings without having to put in tons of lines of code, and easily manipulate the variables themselves.

But first I want to know how Naut's function works.
What's really pondering me is what '.' means.
These two lines of code hard to follow.
while(number < length(string) && string[number] != '.'){
             result = result ~ ToString(string[number]);

What does '.' mean, and why does string[number] have to have the function ToString() when you have both string and number as arrays? I thought you can multiply those and end up with an array, and it wouldn't make a difference since arrays and strings are essentially the same thing.

Like you said, problem is that by default DMF loads numbers with 6 decimal places. But I can hardly even see how this is getting rid of those.

Re: Danmakufu Q&A/Problem Thread v3
« Reply #586 on: April 16, 2010, 03:08:52 AM »
I finally got Naut's function to work now.
This was useful too. But it wasn't really what I was looking for -when I said "attach numbers to variables".
My goal is, to be able to put in SetTexture(effect1); SetTexture(effect2);, or even have a function that can do that for me.
The actual string itself is represented by a variable. I'm looking for a way to easily define these variables as strings without having to put in tons of lines of code, and easily manipulate the variables themselves.

You can't loop the declaration of different variables.

But first I want to know how Naut's function works.
What's really pondering me is what '.' means.
These two lines of code hard to follow.
while(number < length(string) && string[number] != '.'){
             result = result ~ ToString(string[number]);

What does '.' mean, and why does string[number] have to have the function ToString() when you have both string and number as arrays? I thought you can multiply those and end up with an array, and it wouldn't make a difference since arrays and strings are essentially the same thing.

Like you said, problem is that by default DMF loads numbers with 6 decimal places. But I can hardly even see how this is getting rid of those.

"Blah" indicates a string, 'B' indicates a character. When you use brackets to get one letter out of a String, Danmakufu has that letter delcared as a char (represeneted by single quotes). The code I posted (which is Nuclear Cheese's, originally) will start at the very end of the number String, and keep deleting the last character until it hits a decimal (!= '.'), and will then return the String with everything after the decimal removed. I have to use ToString(string[number]) because it's returning me a char data type, when I want it to be a String so I can concatenate it to the String I want returned.

'b' != "b"

Fujiwara no Mokou

  • Hourai Incarnate
  • Oh, so this trial of guts is for ME?
    • Profile
Re: Danmakufu Q&A/Problem Thread v3
« Reply #587 on: April 16, 2010, 03:37:37 AM »
You can't loop the declaration of different variables.

"Blah" indicates a string, 'B' indicates a character.

"" Indicates strings and '' indicates characters.
Okay, so I get this part. By the way, how do you find out this stuff? It seams like you know hidden info.  Things like '' "" % += I don't really know where to find them anywhere.

Anyway, here's the part I don't get.
The code I posted will start at the very end of the number String, and keep deleting the last character until it hits a decimal (!= '.'), and will then return the String with everything after the decimal removed.

But where in the code is it doing that?
I don't see where it's saying "start at the beginning of the number string" either (is there a way to make it start at the end of the number string and add or erase characters there?), and I thought the function erase() deletes characters in arrays. I don't see that anywhere.

Forgive me if I'm being blind, but I have a hard time following this. If in the given ascent loop, variable 'i' is 1.00000, and number is 0.00000, what happens from there?
« Last Edit: April 16, 2010, 03:48:38 AM by Fujiwara no Mokou »

Re: Danmakufu Q&A/Problem Thread v3
« Reply #588 on: April 16, 2010, 03:39:39 AM »
Er, my mistake, the code starts at the beginning of the string and copies them to another one, until it hits a decimal (effectively deleting all the post decimal contents).

Here's a trace:

  let string = "" ~ ToString(i);
      let number = 0;
      let result = "";
      while(number < length(string) && string[number] != '.'){
             result = result ~ ToString(string[number]);
             number++;
      }

First iteration of the while loop,
number = 0;
result = "";
so we'll copy a value to result from string, which is string[number] (or string[0]), which equals 1:
result = result ~ ToString(string[number]);
result = "" ~ ToString(string[number]);
result = "" ~ ToString(string[0]);
result = "" ~ ToString('1');
result = "" ~ "1";
result = "1"

Next iteration of the while loop,
number = 1;
result = "1";

string[number]=='.' now, so the loop stops here.

If there was more than one digit before the decimal, the code would keep concatenating characters to the end of result until it hits the decimal.
« Last Edit: April 16, 2010, 03:51:36 AM by Naut »

Fujiwara no Mokou

  • Hourai Incarnate
  • Oh, so this trial of guts is for ME?
    • Profile
Re: Danmakufu Q&A/Problem Thread v3
« Reply #589 on: April 16, 2010, 03:47:45 AM »
Edited my question and added another one.

Nobu

  • Serendipitous Youkai
  • *
  • i post while naked
    • My Tumblr
Re: Danmakufu Q&A/Problem Thread v3
« Reply #590 on: April 16, 2010, 03:51:00 AM »
Okay, so I get this part. By the way, how do you find out this stuff? It seams like you know hidden info.  Things like '' "" % += I don't really know where to find them anywhere.

Danmakufu is a programming language with syntax based on C(++), so you can find that sort of hidden info by learning how to program.
Tumblr (sometimes NSFW) | PM for Facebook

Re: Danmakufu Q&A/Problem Thread v3
« Reply #591 on: April 16, 2010, 03:54:51 AM »
Added a trace.

Quoted from my above post...


Here's a trace:

  let string = "" ~ ToString(i);
      let number = 0;
      let result = "";
      while(number < length(string) && string[number] != '.'){
             result = result ~ ToString(string[number]);
             number++;
      }


First iteration of the while loop,
number = 0;
result = "";

All while checks are true, number is less than the length of string and string[number]!='.'.
So we'll copy a value to result from string, which is string[number] (or string[0]), which equals 1:
result = result ~ ToString(string[number]);
result = "" ~ ToString(string[number]);
result = "" ~ ToString(string[0]);
result = "" ~ ToString('1');
result = "" ~ "1";
result = "1"


Next iteration of the while loop,
number = 1;
result = "1";


string[number]=='.' now, so the loop stops here.

If there was more than one digit before the decimal, the code would keep concatenating characters to the end of result until it hits the decimal.

Fujiwara no Mokou

  • Hourai Incarnate
  • Oh, so this trial of guts is for ME?
    • Profile
Re: Danmakufu Q&A/Problem Thread v3
« Reply #592 on: April 16, 2010, 04:57:41 AM »
Oh, I get it. So basically, it's copying the character digits from string A , which has a value with unwanted digits to string B, which holds no value in it  "", until it hits the character ' . ' which happens to be a decimal.
Clever. And I didn't know multiplying a string by array will give you the value of a character of the defined array.  "3"[1]= '3'.  Would this mean "3"[2] give you an error, since there is no second character?
I didn't know      "" ~ ToString('1');  =    "" ~ ToString(1);     either.   I thought it would it would be   "'1'" and "1" , because there would be a difference in putting in ''
Or am I messing up somewhere?
« Last Edit: April 16, 2010, 05:05:16 AM by Fujiwara no Mokou »

Drake

  • *
Re: Danmakufu Q&A/Problem Thread v3
« Reply #593 on: April 16, 2010, 05:12:37 AM »
"3"[1] would error. "3"[0] would give '3'.

Note that this isn't multiplying. It's standard array notation. Strings by definition are arrays of characters accessible as a bundle.

array = ['a',1,2,87,'b'];
array[0] gets the entry at location 0, which is 'a'.
array[3] gets the entry at location 3, which is 87.

string = "derp";
string[0] gets the entry at location 0, which is 'd'.

array = [[0,1],[2,3],[4,5]];
array[2][0] gets the entry at location 0 of the entry at location 2, which is 4.

array = ["okay","asdasd","derp"];
array[1][3] gets 'a'. array[2][2] gets 'r'.

A Colorful Calculating Creative and Cuddly Crafty Callipygous Clever Commander
- original art by Aiけん | ウサホリ -

Blargel

  • RAWR!
  • I'M AN ANGRY LOLI!
Re: Danmakufu Q&A/Problem Thread v3
« Reply #594 on: April 16, 2010, 05:13:58 AM »
And I didn't know multiplying a string by array will give you the value of a character of the defined array.
Uhhh, there's so much wrong with that statement I don't even know where to begin. You seem to have a fundamental misunderstanding about array notation. You aren't multiplying an array with an array to get the data out, you're just indicating which index to look at when you put a number in square brackets after an array. For example:

let array = [1, 2, 3, 4, 5];
let newVariable = array[0];


newVariable would contain the number 1 now. Note that, array[0] is NOT the same as array*[0]. The latter would give an error. Now, on the same line of thought, a string is just an array of characters and so you can still put a number in square brackets to get the character out. As a side note, and I'm sure this has already been mentioned previously, Danmakufu considers the use of double quotes ( " ) as an indication that the characters between them is a string. If you use single quotes ( ' ), then it is a character (and obviously cannot be longer than one character long). This means that "a" does not equal 'a'.

Quote
"3"[1]= '3'.  Would this mean "3"[2] give you an error, since there is no second character?
Or am I messing up somewhere?

Following what I was saying earlier, "3"[1] would actually raise an error because the first element in an array is actually [0], not [1]. "3"[ 0 ] would equal '3' and any other number besides 0 would raise an error because the array is not that long.

Quote
I didn't know      "" ~ ToString('1');  =    "" ~ ToString(1);     either.   I thought it would it would be   "'1'" and "1" , because there would be a difference in putting in ''

Because Danmakufu treats single quotes as a keyword indicating a character, putting '1' into a function will result in Danmakufu interpreting it as a character, not as a string storing '1'. You forget that outside of double quotes, nothing is considered a string, just keywords and data.
« Last Edit: April 16, 2010, 05:19:54 AM by Blargel »
<WorkingKeine> when i get home i just go to the ps3 and beat people up in blazblue with a loli
<Azure> Keine: Danmakufu helper by day, violent loli by night.

Fujiwara no Mokou

  • Hourai Incarnate
  • Oh, so this trial of guts is for ME?
    • Profile
Re: Danmakufu Q&A/Problem Thread v3
« Reply #595 on: April 16, 2010, 05:38:22 AM »
I see. So it actually starts at 0.
Sorry, I didn't know how arrays worked.
So, thinking logically, "text"=['t','e','x','t']
That would explain a lot.

Quote from: Drake
array = ["okay","asdasd","derp"];
array[1][3] gets 'a'. array[2][2] gets 'r'.

This confuses me. Where's the math in that?

EDIT: Oh, wait, nevermind. I see what you did there.
« Last Edit: April 16, 2010, 05:44:34 AM by Fujiwara no Mokou »

Blargel

  • RAWR!
  • I'M AN ANGRY LOLI!
Re: Danmakufu Q&A/Problem Thread v3
« Reply #596 on: April 16, 2010, 06:01:55 AM »
Sounds like you got it. Just for the sake of completeness,

array = ["okay","asdasd","derp"];
array[1][3] == "asdasd"[3] == 'a'
array[2][2] == "derp"[2] == 'r'


Oh I just noticed this:
array = ['a',1,2,87,'b'];
array[0] gets the entry at location 0, which is 'a'.
array[3] gets the entry at location 3, which is 87.
Although this array is legal in some languages, Danmakufu will not allow numbers and strings to be stored in the same array. There are a lot of rules governing arrays inside arrays as well in Danmakufu but that's a bit more advanced.

EDIT: Oh wait those are characters, not strings. Strangely Danmakufu stores characters as numbers so that's fine in an array I guess... I haven't tested that.  :ohdear:
« Last Edit: April 16, 2010, 06:18:20 AM by Blargel »
<WorkingKeine> when i get home i just go to the ps3 and beat people up in blazblue with a loli
<Azure> Keine: Danmakufu helper by day, violent loli by night.

Blargel

  • RAWR!
  • I'M AN ANGRY LOLI!
Re: Danmakufu Q&A/Problem Thread v3
« Reply #597 on: April 16, 2010, 08:15:32 AM »
Double posting 'cause it's not really related to my previous post.

Hey I figured this out. Now you can have mixed value arrays. Only problem is that since you have to use these functions, you're gonna need some extra processing power. I don't think it'll be very much though. Basically you turn the strings into arrays of numbers representing the ascii code and then turn them back when you need the strings again. Because the strings get converted into arrays of numbers, you can't directly store the converted strings in with other numbers. Instead you'll have to put the numbers in an array on their own and stick that array in with the converted strings. When you need the strings back, just convert them back with the other function.

I don't think anyone will ever actually use this, but whatever.

 
  function StringToNumberArray(string){
    let array = [];
    ascent(i in 0..length(string)){
      array = array ~ [CharacterToNumber(string[i])];
    }
    return array;
  }
 
  function NumberArrayToString(array){
    let string = "";
    ascent(i in 0..length(array)){
      string = string ~ [NumberToCharacter(array[i])];
    }
    return string;
  }
 
  function CharacterToNumber(char){
    return floor(char);
  }
 
  function NumberToCharacter(num){
    let chars = [' ', '!', '"', '#', '$', '%', '&', "'"[0], '(', ')', '*', '+', ',', '-', '.', '/',
                 '0', '1', '2', '3', '4', '5', '6', '7'   , '8', '9', ':', ';', '<', '=', '>', '?',
                 '@', 'A', 'B', 'C', 'D', 'E', 'F', 'G'   , 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O',
                 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W'   , 'X', 'Y', 'Z', '[', '\', ']', '^', '_',
                 '`', 'a', 'b', 'c', 'd', 'e', 'f', 'g'   , 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o',
                 'p', 'q', 'r', 's', 't', 'u', 'v', 'w'   , 'x', 'y', 'z', '{', '|', '}', '~'];
    return chars[num-32];
  }


Yes I could've stored the characters in a string instead of an array (same thing), but I couldn't remember how to escape a double quote.
« Last Edit: April 16, 2010, 08:17:26 AM by Blargel »
<WorkingKeine> when i get home i just go to the ps3 and beat people up in blazblue with a loli
<Azure> Keine: Danmakufu helper by day, violent loli by night.

Elementoid

  • Having a heated affair with feux-familiars
Re: Danmakufu Q&A/Problem Thread v3
« Reply #598 on: April 19, 2010, 03:01:28 AM »
This sort of isn't a real question, but in my latest script, there seem to be some inherent problems with the math, the main one I've noticed being when you try to give it 5 "leaves," and it gets cut off.

I think the problem might be that it ends up dividing circlenum (which has a value of 72) by leaf (in this case 5, resulting in a non-integer) and this is messing things up? And if that's the case, is there really any way for me to try and fix it without permanently defining one of the variables?

I apologize for having such a petty problem. I'm still not really good at any of this stuff yet...

Hyouga Kazu

  • Legend Seekers, 0th Division Leader
Re: Danmakufu Q&A/Problem Thread v3
« Reply #599 on: April 19, 2010, 04:50:33 AM »
Danmakufu doesn't see the difference between integers and doubles, so dividing 72 by 5 would result in 14.4.
Maybe you could post your script here so we can check it for other errors, because sometimes it's just a small error you never expected to make.  ;)