Author Topic: ※ Dnh Q&A/Problem ※ for Danmakufu ph3 (locked)  (Read 316279 times)

fondue

  • excuse me
Re: ※ Dnh Q&A/Problem ※ ONLY for NEWEST engine (ph3 beta)
« Reply #630 on: June 02, 2013, 04:43:39 PM »
Use .ogg files. They're really small and sound just as good as .wav's. The only problem is that they can be only pretty much opened with Audacity.

Imosa

  • Any sufficiently advanced technology
  • is indistinguishable from magic
Re: ※ Dnh Q&A/Problem ※ ONLY for NEWEST engine (ph3 beta)
« Reply #631 on: June 10, 2013, 06:18:18 AM »
I'm working with 2d arrays right and can't find any examples of how to use them.
I've become very comfortable with doing something like this:
Code: [Select]
let b = [];
ascent (i in 0 .. 10) {
    b = [CreateShotA1(0, 0, 0, 0, DS_BALL_S_RED, 40)] ~ b;
    ObjShot_SetAutoDelete(b[0],false);
}
After this I expect to have an array of 10 bullets.

Now I'd like to do something similar with a 2D array but the logic doesn't extend like I expect it too. I tried something like this:
Code: [Select]
let b = [[]];
let c = [];
ascent (i in 0 .. 10) {
    c = [CreateShotA1(0, 0, 0, 0, DS_BALL_S_RED, 40)] ~ c;
    ObjShot_SetAutoDelete(c[0],false);
}
b = c ~ b;
After which I'd like to have an 1 by 10 array of bullets, but I got an error on the last line which said this: "型が一致しません".

Any ideas on this? I'll take example code too.
« Last Edit: June 10, 2013, 06:21:13 AM by Imosa »

Re: ※ Dnh Q&A/Problem ※ ONLY for NEWEST engine (ph3 beta)
« Reply #632 on: June 10, 2013, 07:18:07 AM »
I plugged it into Google Translate and it said type mismatch. Not entirely sure if I'm interpreting your post correctly, but I think you are unable to use multidimensional arrays in Danmakufu...I hope someone else can explain this in further detail, because while I would like to be more knowledgeable in the inner workings of Danmakufu, I am afraid I have been working with Doom for too long for that.

Drake

  • *
Re: ※ Dnh Q&A/Problem ※ ONLY for NEWEST engine (ph3 beta)
« Reply #633 on: June 10, 2013, 07:44:24 AM »
The problem is just that you're concatenating a 1d array with a 2d array. All that needs to be changed is b = [c] ~ b; since then it's concatenating [[bullet,bullet,...]] and [[]].
[[a,b,c],[d,e,f]] ~ [[1,2,3],[4,5,6]] -> [[a,b,c],[d,e,f],[1,2,3],[4,5,6]] and so on.

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

Imosa

  • Any sufficiently advanced technology
  • is indistinguishable from magic
Re: ※ Dnh Q&A/Problem ※ ONLY for NEWEST engine (ph3 beta)
« Reply #634 on: June 10, 2013, 12:04:21 PM »
I tried Drake's solution and it didn't work. I got the "type mismatch" error again.

Update:
I tried changing the first line to "let b = [[CreateShotA1(0, 0, 0, 0, DS_BALL_S_RED, 40)]];", thinking that if it was an array of bullets to begin with it would accept new bullets. This does fix the type mismatch but now I'm having problems in other parts of my code. So this won't do (nor should it).
How do people trace code in this program? Is there some kind of console output?
« Last Edit: June 10, 2013, 12:53:15 PM by Imosa »

Drake

  • *
Re: ※ Dnh Q&A/Problem ※ ONLY for NEWEST engine (ph3 beta)
« Reply #635 on: June 10, 2013, 10:44:55 PM »
Wow, that sucks. For whatever reason the empty array is a type mismatch. The above works fine when the other array dimension isn't empty (and is of the same type).
In order to work it deeper than one dimension, you have to reconstruct the 1d array instead with b[0] = c ~ b[0]. In that case you can eliminate the use of the c array entirely, but I assume you have a reason for constructing the array like this.

There is no real trace function, but generally with explicit errors it gives you the line number where something screwed up. 0.12 had a sort of console but it was cumbersome to use, and now I don't think there is one for ph3. For 0.12 I've recently been using the debug functions I wrote here rather than the console, so I could probably whip up something similar for ph3. Really debugging here is just "write stuff all over the screen and remember what common errors are from experience".
« Last Edit: June 10, 2013, 10:54:26 PM by Drake »

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

Imosa

  • Any sufficiently advanced technology
  • is indistinguishable from magic
Re: ※ Dnh Q&A/Problem ※ ONLY for NEWEST engine (ph3 beta)
« Reply #636 on: June 11, 2013, 03:23:25 AM »
So I got a great solution. After I declared+instantiated the 2d array with a junk bullet, I deleted the location in the array. At this point it was an empty array again but I figured it had already held a bullet so now it might hold more, and it did. Bullets can now be added without issues. Also, I placed the junk bullet at -100,-100 so I assume the auto-delete took care of it.

Drake

  • *
Re: ※ Dnh Q&A/Problem ※ ONLY for NEWEST engine (ph3 beta)
« Reply #637 on: June 11, 2013, 05:10:04 AM »
danmakufu is as crazy as ever
i don't particularly like that solution but at least it works

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

Ozzy

  • Veteran Danmakufu Scripter
  • Currently working on a full Touhou fangame!
Re: ※ Dnh Q&A/Problem ※ ONLY for NEWEST engine (ph3 beta)
« Reply #638 on: June 11, 2013, 06:36:15 AM »
0.12 had a sort of console but it was cumbersome to use, and now I don't think there is one for ph3.
Actually there IS a log window for later versions of Ph3 which can be enabled from the config. It gives some debug information as well as takes a log of certain events as they happen. The value of common data within common data areas can be found as well as the number of script tasks that are running, the number of enemies existing, and the number of objects currently existing can be found there just to name a few. The function WriteLog can also be used in scripts to write certain text to the log. This can be helpful to figure out what part of a script is causing a crash.

Imosa

  • Any sufficiently advanced technology
  • is indistinguishable from magic
Re: ※ Dnh Q&A/Problem ※ ONLY for NEWEST engine (ph3 beta)
« Reply #639 on: June 11, 2013, 12:13:21 PM »
Actually there IS a log window for later versions of Ph3 which can be enabled from the config. It gives some debug information as well as takes a log of certain events as they happen. The value of common data within common data areas can be found as well as the number of script tasks that are running, the number of enemies existing, and the number of objects currently existing can be found there just to name a few. The function WriteLog can also be used in scripts to write certain text to the log. This can be helpful to figure out what part of a script is causing a crash.
Oh god, I found the write log function and I've been looking everywhere for a log to be written to. It doesn't seem to display the text that I write to it though. I only see Moon Runes.

The common data fields might work better.
« Last Edit: June 11, 2013, 12:26:20 PM by Imosa »

Ozzy

  • Veteran Danmakufu Scripter
  • Currently working on a full Touhou fangame!
Re: ※ Dnh Q&A/Problem ※ ONLY for NEWEST engine (ph3 beta)
« Reply #640 on: June 11, 2013, 04:32:48 PM »
Oh god, I found the write log function and I've been looking everywhere for a log to be written to. It doesn't seem to display the text that I write to it though. I only see Moon Runes.

The common data fields might work better.
I can confirm that it does indeed write the exact text put into WriteLog, it just also writes a ton of other things that are in unintelligible in Japanese.

Imosa

  • Any sufficiently advanced technology
  • is indistinguishable from magic
Re: ※ Dnh Q&A/Problem ※ ONLY for NEWEST engine (ph3 beta)
« Reply #641 on: June 11, 2013, 11:36:07 PM »
I can confirm that it does indeed write the exact text put into WriteLog, it just also writes a ton of other things that are in unintelligible in Japanese.
Weird because I'm only getting unintelligible Japanese. Although, I'm also getting some stuff that isn't Japanese. It's making me think there's some kind of encoding error or something.

Re: ※ Dnh Q&A/Problem ※ ONLY for NEWEST engine (ph3 beta)
« Reply #642 on: June 15, 2013, 04:58:08 AM »
All rigiht, back with a trickier question! I'm messing with the provided sample script (SampleE02.txt) that renders a circular distortion circle around the boss, in order to alter it for my own uses. However, when used with my own background, the visuals aren't working correctly.

Using the default "Ice Mountain" background:


Using my 2D background:


Plain as day, there's a square border visible around the distortion effect. Enabling or disabling different parts of the effect reveals that the border is being created by the part of the effect that renders the outside corner space between the circular edge of the distortion and the square border of the effect area. Has anyone messed with ph3's daunting render-to-texture functionality enough to have a clue what would cause that? Looking at the code for my background and Ice Mountain, the only thing that seems substantially different between them is that I'm using 2D rendering instead of 3D...

EDIT: A classic case of post-and-solve! Adjusting the coordinates of the outside part of the texture by 0.5 pixels removed the frame.
« Last Edit: June 15, 2013, 05:06:13 AM by professor_scissors »

Nimono

  • wat
Re: ※ Dnh Q&A/Problem ※ ONLY for NEWEST engine (ph3 beta)
« Reply #643 on: June 15, 2013, 03:31:32 PM »
I'm having a severe issue with one of my player scripts. Here. I'm trying to spawn Enemy objects (referred to as "Shell" from here on) into an array so I can make sure I can limit the amount of Shells on the screen at a single time, but it's not working correctly. When a Shell is spawned, the border turns black, and after some time, the player and its hitbox turns into a shell, moves like the Shells, and then eventually, even the boss does it, too! THEN the actual shells spawn later on. Yes, I'm sure just putting it into another task within the ShellManage task would work, lowering the Shells variable every time one is destroyed, but I'd like to know why my array setup is working in case in the future, I might need this for something else...

gtbot

  • Master of ScreenSplit
Re: ※ Dnh Q&A/Problem ※ ONLY for NEWEST engine (ph3 beta)
« Reply #644 on: June 15, 2013, 09:44:30 PM »
Browser crashed and lost my reply  :X

Basically, in the ascent at line 278, you are manipulating objects with the value of i rather than the objects inside of the array. Because of this, everything else gets manipulated until the shells appear (since at some point it will eventually reach the ID that the shells are). To fix this, just change all the references that use i as an object to ShellCount[‎i], which I've done for you. Also, the Shells variable is kind of unnecessary, since you can just use length(ShellCount) in its place.

Nimono

  • wat
Re: ※ Dnh Q&A/Problem ※ ONLY for NEWEST engine (ph3 beta)
« Reply #645 on: June 15, 2013, 10:00:17 PM »
Browser crashed and lost my reply  :X

Basically, in the ascent at line 278, you are manipulating objects with the value of i rather than the objects inside of the array. Because of this, everything else gets manipulated until the shells appear (since at some point it will eventually reach the ID that the shells are). To fix this, just change all the references that use i as an object to ShellCount[‎i], which I've done for you. Also, the Shells variable is kind of unnecessary, since you can just use length(ShellCount) in its place.
Oh, derp. Thanks! The reason I used the "Shells" variable was in case it was the use of length(ShellCount) that did it. (It wasn't.)

Well, I have a new issue now. I decided to go with a task-based approach to handling the shells (much simpler XD) and have gotten to the point of having the shells stun the player. It was working fine up until I added some code to stop the player from moving. Now, every time the player gets hit by a shell, the game freezes and an error box shortly appears, saying only "bad allocation". I don't know what's wrong. Updated stuff is here

gtbot

  • Master of ScreenSplit
Re: ※ Dnh Q&A/Problem ※ ONLY for NEWEST engine (ph3 beta)
« Reply #646 on: June 15, 2013, 10:50:28 PM »
You are setting GetPlayerX and GetPlayerY to a value, which is what is causing the error (they shouldn't be modified except by Danmakufu). You should be setting StunX/Y = GetPlayerX/Y instead.

Nimono

  • wat
Re: ※ Dnh Q&A/Problem ※ ONLY for NEWEST engine (ph3 beta)
« Reply #647 on: June 15, 2013, 10:53:49 PM »
You are setting GetPlayerX and GetPlayerY to a value, which is what is causing the error (they shouldn't be modified except by Danmakufu). You should be setting StunX/Y = GetPlayerX/Y instead.
rugh34ujg3h

this is what happens when i haven't used danmakufu for a while

thank you

Shadow

  • Forever waiting for tomorrow
  • ...
Re: ※ Dnh Q&A/Problem ※ ONLY for NEWEST engine (ph3 beta)
« Reply #648 on: June 19, 2013, 03:59:17 AM »
Is there an animation-handling library of some sort for ph3? I am seriously inept when it comes to manually handling animations and graphics... ^^;

gtbot

  • Master of ScreenSplit
Re: ※ Dnh Q&A/Problem ※ ONLY for NEWEST engine (ph3 beta)
« Reply #649 on: June 19, 2013, 10:30:36 AM »
There is this one from Lucas,

Shadow

  • Forever waiting for tomorrow
  • ...
Re: ※ Dnh Q&A/Problem ※ ONLY for NEWEST engine (ph3 beta)
« Reply #650 on: June 20, 2013, 12:17:09 AM »
Ah, thank you. However, upon trying to use it, the second animation function gives me an error regarding arrays, and moreover, it has Danmakufu automatically crash when it transitions from one script to another in plurals. I might have to resort doing this manually...

Re: ※ Dnh Q&A/Problem ※ ONLY for NEWEST engine (ph3 beta)
« Reply #651 on: June 20, 2013, 02:51:17 PM »
Are you using an .mp3 file? I've had trouble when working with mp3s, but .wavs work fine.

edit: oops, i didn't check that i was actually using .ogg instead of .wav; fondue is right, .ogg is the one with no problems

Got a .ogg file, and it still doesnt work right. I say "PlayBGM(music1A, 10, 20);", and instead of looping back to 0:10 at the 0:20 mark, it just plays and loops the entire song. The effect is the same, no matter what I set the last two parameters to.

gtbot

  • Master of ScreenSplit
Re: ※ Dnh Q&A/Problem ※ ONLY for NEWEST engine (ph3 beta)
« Reply #652 on: June 20, 2013, 03:18:16 PM »
Ah, thank you. However, upon trying to use it, the second animation function gives me an error regarding arrays, and moreover, it has Danmakufu automatically crash when it transitions from one script to another in plurals. I might have to resort doing this manually...
Ah, I see. In this case, I'll make a basic animation library for you. It'll be done rather soon.

Got a .ogg file, and it still doesnt work right. I say "PlayBGM(music1A, 10, 20);", and instead of looping back to 0:10 at the 0:20 mark, it just plays and loops the entire song. The effect is the same, no matter what I set the last two parameters to.
It might be related to the file itself and the way Danmakufu processes the sounds. That happens to me too on some files I've used (except instead they repeatedly played 2 seconds and were disconnected from any sound objects), and I'm not entirely sure as to why it happens.  ???

Try making the audio a sound object and see if it'll loop correctly then.

Re: ※ Dnh Q&A/Problem ※ ONLY for NEWEST engine (ph3 beta)
« Reply #653 on: June 20, 2013, 03:56:53 PM »
Try making the audio a sound object and see if it'll loop correctly then.

Yes! Loading a Sound Object was the thing to do. It works perfectly now, thanks!

gtbot

  • Master of ScreenSplit
Re: ※ Dnh Q&A/Problem ※ ONLY for NEWEST engine (ph3 beta)
« Reply #654 on: June 21, 2013, 12:08:36 AM »
Yes! Loading a Sound Object was the thing to do. It works perfectly now, thanks!
Oh, that's great :)
I'll make a basic animation library for you. It'll be done rather soon.
finished it

Shadow

  • Forever waiting for tomorrow
  • ...
Re: ※ Dnh Q&A/Problem ※ ONLY for NEWEST engine (ph3 beta)
« Reply #655 on: June 21, 2013, 01:44:01 AM »
finished it

I can't thank you enough--it works wonderfully~

Ozzy

  • Veteran Danmakufu Scripter
  • Currently working on a full Touhou fangame!
Re: ※ Dnh Q&A/Problem ※ ONLY for NEWEST engine (ph3 beta)
« Reply #656 on: June 24, 2013, 03:06:40 PM »
Does anyone here know how user events work? I'm trying to read up on EV_USER on the official documentation but Google Translate makes it very unclear.

Nimono

  • wat
Re: ※ Dnh Q&A/Problem ※ ONLY for NEWEST engine (ph3 beta)
« Reply #657 on: June 28, 2013, 02:30:11 AM »
Hi, another player script problem.

https://dl.dropboxusercontent.com/u/26851686/MarisaD3.txt

In the section of the Option task that sets relativeX and relativeY,  relativeX & Y are supposed to point to the closest enemy (or the boss) if one exists, thus causing the options to home in on the boss. There's just one problem: they never do, and the check for if a boss exists causes an error if no boss exists. I suspect I might be using GetAllEnemyID incorrectly, but...the wiki is no help whatsoever. It only offers the most basic info that tells me absolutely nothing. "Gets the ID of every enemy present on the screen, and returns them in an array." Then how do I access them? What value corresponds to what? D: Please help!

Imosa

  • Any sufficiently advanced technology
  • is indistinguishable from magic
Re: ※ Dnh Q&A/Problem ※ ONLY for NEWEST engine (ph3 beta)
« Reply #658 on: June 28, 2013, 05:01:03 AM »
Hi, another player script problem.

https://dl.dropboxusercontent.com/u/26851686/MarisaD3.txt

In the section of the Option task that sets relativeX and relativeY,  relativeX & Y are supposed to point to the closest enemy (or the boss) if one exists, thus causing the options to home in on the boss. There's just one problem: they never do, and the check for if a boss exists causes an error if no boss exists. I suspect I might be using GetAllEnemyID incorrectly, but...the wiki is no help whatsoever. It only offers the most basic info that tells me absolutely nothing. "Gets the ID of every enemy present on the screen, and returns them in an array." Then how do I access them? What value corresponds to what? D: Please help!
Well for starters, you don't have parenthesis behind GetAllEnemyID in your GetClosestEnemyID function to indicate it's a function. I guess, yeah, your using it incorrectly.

I notice you have a tree of if statements in that same function. Does ph3 not have early escape functionality, i.e. if I write
Code: [Select]
if(a == b && c==d) {
a = "blah"
}
and a==b evaluates to false, will c==d even been evaluated seeing as the entire if statement already has no hope of being true?
« Last Edit: June 28, 2013, 05:07:28 AM by Imosa »

Nimono

  • wat
Re: ※ Dnh Q&A/Problem ※ ONLY for NEWEST engine (ph3 beta)
« Reply #659 on: June 28, 2013, 01:49:22 PM »
There's no parentheses behind it because my experience is, functions work without them unless they have parameters, and GetAllEnemyID doesn't. GetPlayerX/Y are functions, but they don't need parentheses because they don't have parameters. (why would they? XD)

Also as for tree of ifs, it's because CK Crash told me to do that because "less resource intensive, and there's no reason to check enemy data until you verify the enemy exists". :/ He says that if a==b results to false, c==d will still be checked. My experience...I'd say that's true.