Author Topic: ※ Danmakufu Q&A/Problem thread 3 ※  (Read 468916 times)

Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #750 on: July 24, 2017, 01:16:22 AM »
Greetings fellow scripters and aspiring scripters! I'm KIND of new to Danmakufu and I'm using Sparen's Danmakufu Tutorial website in order to learn Ph3. However, I'm stuck in this one question and no matter how much I read Part 3 of Lesson 5, it doesn't seem to get into my head. Now I love answering the questions with a little explanation so I can put it in my notes for future reference, but I'm not able to do that since I can't make heads or tails of this question.

Image link to the question: https://ibb.co/gi6R4k

Now it tells me that the answer is B. Now do any one of you know why? I would really appreciate a nice juicy answer from you guys and I thought it would be best to ask this question in the Danmakufu Q&A~

Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #751 on: July 24, 2017, 06:37:01 AM »
Greetings fellow scripters and aspiring scripters! I'm KIND of new to Danmakufu and I'm using Sparen's Danmakufu Tutorial website in order to learn Ph3. However, I'm stuck in this one question and no matter how much I read Part 3 of Lesson 5, it doesn't seem to get into my head. Now I love answering the questions with a little explanation so I can put it in my notes for future reference, but I'm not able to do that since I can't make heads or tails of this question.

Image link to the question: https://ibb.co/gi6R4k

Now it tells me that the answer is B. Now do any one of you know why? I would really appreciate a nice juicy answer from you guys and I thought it would be best to ask this question in the Danmakufu Q&A~

   It is because ascent loop doesn't actually reach 23, but stops at 23-1, so x = i / 22.

Sparen

  • Danmakufu Artist
  • Git ready, git set, PUUSH!
    • AFCDTech
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #752 on: July 24, 2017, 06:53:58 AM »
Greetings fellow scripters and aspiring scripters! I'm KIND of new to Danmakufu and I'm using Sparen's Danmakufu Tutorial website in order to learn Ph3. However, I'm stuck in this one question and no matter how much I read Part 3 of Lesson 5, it doesn't seem to get into my head. Now I love answering the questions with a little explanation so I can put it in my notes for future reference, but I'm not able to do that since I can't make heads or tails of this question.

It was supposed to say Part 4, which covers loop based control statements. The typo has been fixed. I apologize for the confusion.

Drake

  • *
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #753 on: July 24, 2017, 08:02:00 AM »
Now it tells me that the answer is B. Now do any one of you know why? I would really appreciate a nice juicy answer from you guys and I thought it would be best to ask this question in the Danmakufu Q&A~
The minimum value you give ascent/descent is inclusive, while the maximum value is exclusive. The first time the loop runs i = 6, and the last time has i = 22.

I'm wondering if there's a ph3 thread for useful code snippets, and/or a library of extra functions to make life easier?
Not exactly. There are a lot more people scripting now and there are a lot of people rolling their own various systems. At this point you just kind of have to communicate with people and find scripts with useful snippets or bigger libraries that allow reuse.

stuff
Right off the bat: Please, please write and test your code in smaller chunks. Part of why it's difficult to respond to this is because there isn't just one problem to point at; you've written a lot at once and now instead of a simple answer there are a bunch of things to look at.

- The main problem is the line while(ObjMove_GetY(n) < x){yield;}. You want the star to travel along until the value of x passes the star, and then it spawns the bullets, so the correct line is the while(ObjMove_GetY(n) > x){yield;}. What happens here is that when x starts below the stars, the first while condition is true (ObjMove_GetY(n) > x). Then maybe at some point x passes the star, so that breaks the while loop and then next one starts, but that one is (ObjMove_GetY(n) < x) which is now true, so it will continue to wait. Once x hits the end of the screen and resets, the loop then breaks because the condition is suddenly false, and the explosion happens. But it's like this for every star so they just all explode at the same time.

- The reason why your added line "fixes" the problem is the same as why things are spawning in the corner. When things start spawning in the corner, that typically means something is referencing an object that has already been deleted. Using something like ObjMove_GetX on a deleted object will return 0. What your if(x > GetStgFrameHeight - 200){wait(180);} line does is check if x is low enough on the screen and then wait three seconds. When this happens, the star bullets are probably going to fly off the screen and be deleted before that time is up, so ObjMove_GetX(n) returns 0. Eventually x will be below 0 (like -30) and later above 0, and after both of these the explosion will trigger. But this is completely different to what you actually want, so it only "looks" like it fixes the problem.

- Your laser task creates a new laser every three frames. It creates a laser, then waits one frame, then deletes it, waits another frame, and then loops. This is definitely not what you want; by the sound of it you want to just create one laser, and just have it continually move down and then teleport back to the top. Getting rid of the Obj_Delete(obj) will fix this. You also shouldn't need the outer loop with the boss life check at all.

- Minor note: You should move the stuff controlling the x variable into its own task rather than putting it in the MainLoop, or even move it into the laser task. Partially because it's cleaner, but also because you can then control when it begins and ends.

- Minor note: The line if(ObjMove_GetY(obj3) > GetStgFrameHeight){Obj_IsDeleted(obj3)} (also the obj2 one) won't do anything. You want Obj_Delete(obj3) instead.

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

CrestedPeak9

  • Fangame Advocate
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #754 on: July 24, 2017, 01:59:09 PM »
   Well, I guess no one's going to help me like that so let's be more specific: When I fix this problem, I have some random stars popping out from the top left corner of my screen. I tried all sort of things like cancel the function that make my stars explode when the laser teleport to the top, or deleting all explosion outside from the screen thinking that the small stars were stacking outside from the screen and reappearing at the top left corner, and trying out other things. The conclusion to this would be that all the stars that explode from hitting the delay laser stack for reappearing later, but I didn't ask for this, I don't get it, can someone help me?
    This is a recurrent problem since in my other scripts, I have the same problem with random stuff popping out from the top left corner of my screen. I thought it was because danmakufu could't interpret functions outside from the screen so to fix that it would make them happen at X=0 and Y=0 but now I am lost.

Check this: http://sparen.github.io/ph3tutorials/ph3u2l16.html
Lunatic 1cc: EoSD, PCB, IN, MoF, TD, DDC, LoLK, HSiFS, WBaWC

Helepolis

  • Charisma!
  • *
  • O-ojousama!?
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #755 on: July 25, 2017, 05:53:23 AM »
Axyo, Crested might have posted the link to Sparen's tutorial to solve his specific scenario, but it doesn't explain the underlying problem. In the summary however it does report something important: "Avoid spawning bullets from nonexistent or deleted enemies". Not just enemies, objects more specifically as enemies are objects. Stuff spawning at 0,0 (top left corner) is 99,99% of the time a programming error.

First you should know is that Danmakufu is perfectly capable of spawning things beyond the visible playing field. Regular bullets however will be auto-deleted if they exceed the auto-delete boundaries for bullets. Objects on the other hand, just like in 0.12m, will ignore this.

The underlying problem I explained here answering ombsik33's problem which is similar issue just different scenario: https://www.shrinemaiden.org/forum/index.php/topic,19249.msg1298751.html#msg1298751


Edit:
Your mention about all stars exploding when hitting your delay laser might be due to all stars being "linked" to the same laser or sharing the same object or variable reference for each bullet. Doesn't seem to sound as if each star bullet object has individual behaviour.

Edit2:
I've checked your SP2.cs script and I can see that it doesn't. What you need to do is create an object bullet (star) and put in the behaviour that if the star interacts with the laser, then it will explode itself. Right now you're referencing each new CreateShotA1 to the same variable and passing that to explosion(n) task. You need something like this:

Code: [Select]
task starBullet(x,y,velocity,angle,bulletType,delay) {
let obj = ...

while(!Obj_IsDeleted) {
if(I interact with the laser complicated statement code) {
explosion(obj);
Obj_Delete(obj);  // <--  if explosion is a task and not a tunction then 0,0 spawning issue might occur.
}
}
}

function explosion(obj) {
// do whatever new explosion stars you want to create here using CreateShotA1
}

Now each starBullet you spawn has its own individual behaviour and will only delete/explode itself when the statement is true.

There is one important thing to keep in mind here. If you intend to delay creation of new bullets in explosion(obj) then don't delete the starBullet in its own while loop but at the end of the function. Why? Because the next line of code is Obj_Delete. Which will delete the starBullet. So any new bullets being spawned after deletion will result in spawning at 0,0. You could merge the explosion behaviour within the while loop and safely delete the object afterwards. You could move the Obj_Delete to the function as well. That is all up to you.

Edit3:
So many edits. I have to correct my statement about Obj_Delete. In case of functions, it is not a parallel event. If I am not mistaking, even if you delay the code in the function, Obj_Delete won't be executed until the function has finished all its own code. Only if this were to be a task, then Obj_Delete would be executed as tasks are executed parallel, hence the whole "multi tasking/threading". I've used strike through to edit out the text, but it is in my opinion still valuable knowledge.
« Last Edit: July 25, 2017, 09:11:12 AM by Helepolis »

Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #756 on: July 25, 2017, 04:10:48 PM »
   First of all, thanks to everyone who answered to my problem, I didn't expect anyone to do it x). You are all great!

< snip >

   I always check if my code works after adding few lines, but when I am facing problem like this one,  I happen to try a bunch of things but indeed, I've let all those things stack up unecessarily so it may looks like I don't often try my code.

    - If I get rid of while(ObjMove_GetY(n) < x){yield}", the problem will just be worst as the stars will directly explode when they spawn. What this line does is it prevents the stars to explode directly, because I want my stars to only explode when they reach x. But, I think you are kinda wrong in your reasoning without willing to be pretentious, because what my line does is see if the stars are above x, and then only if it becomes false see if the stars and under x and only then reading the next part of my task. The explosion doesn't occur as long as those 2 conditions aren't false. That's what I think anyway, I might be wrong as I am still new.
    - For if(x > GetStgFrameHeight - 200){wait(180);}, I couldn't think of another way to "solve" the problem because all my stars kept exploding at the same time when the laser was teleporting to the top, but now thanks to you I know the reason of why random stars pop at (0;0) so thanks :D (I still can't figure out how to solve my problems though.)
    - For my lasers, if I get rid of Obj_Delete(obj) it will be problematic, as the laser will eventually reach the end of its delay and spawn as enemy projectiles, and that's not what I want. I only want a delay laser. The first idea was to make interact the spawned laser with stars, but I couldn't find a way to do it so it ended only using my delay laser.
    - Well, for shifting my "x" to the laser's loop instead of keeping it in my mainloop, I don't see an efficient way to easily do it and I wanna limit the amount of occurring problems, so I won't do it for now. If I move it to laser's loop, it will make things harder as x won't progress independently from the task, so it will create new problems that I will probably struggle a lot to fix, that's the reason why it is not in the laser's loop.
    -For  if(ObjMove_GetY(obj3) > GetStgFrameHeight){Obj_IsDeleted(obj3)} (and with obj2), I have to agree with you, those lines are useless.


< snip >

   Ok, it took me a long time but I wrote back all the code for shooting my stars in your way. As conclusion to this, I've found that even if I've changed the behaviour of all my stars to make them independent through your method, it doesn't work (sorry, I tried my best but it still doesn't work). Here's my code:

https://pastebin.com/EXLvcTjZ

   As Drake mentionned it earlier, the problem resides in fact in my conditions line when my stars hit x. Indeed, my stars don't interact with my lasers but with x, because I couldn't figure out how to make them interact. The problem is right here:
while(ObjMove_GetY(obj2) > x){yield;}
while(ObjMove_GetY(obj2) < x){yield;}

   I can't find a way to write it as an "if" condition, so I end up with those two "while". With your method, the problem is only shifted from the "explosion" function to the task "starBullet" :/. There are few things that I didn't understand in what you said:
   -The behaviour of the bullet has to be independent for each bullet. What will this do? In my way to right things, I decided to do this in my ascent and descent loops by deleting them, so when each star reach x they delete.
   - Even if I use "explosion" as a function, stars keep popping out from (0;0), so I don't know anymore x).

edit: I guess I am still not good enough to make things like this, I probably should give up for now and come back later when I'll have more materials to work with. I am out of idea for this :/
« Last Edit: July 26, 2017, 05:53:15 AM by Helepolis »

Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #757 on: July 25, 2017, 04:59:57 PM »
Hi guys,

how do I change the colour of the bullet when it goes through a moving laser?

!!Do not approve. I think I have found solution!!
« Last Edit: July 25, 2017, 07:19:21 PM by RyanPrice »

Drake

  • *
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #758 on: July 26, 2017, 04:00:58 AM »
I was trying to lead you to the right idea because you're like 90% of the way to the answer. Here's a picture showing from spawn to explosion:



This should illustrate why writing those conditions in that order will not work as you intend.


As for the delay laser, I just didn't realize you wanted it to be like that. This is way more easily done either by:
Code: [Select]
let b = CreateStraightLaserA1(200, 100, 90, 512, 2, 0, SHOT_RING_RED, 10000);or
Code: [Select]
let b = CreateStraightLaserA1(200, 100, 90, 512, 2, 10000, SHOT_RING_RED, 0);
ObjShot_SetIntersectionEnable(b, false);
And maybe making it resistant to bullet cancels or something if you need to.

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

Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #759 on: July 26, 2017, 10:08:08 AM »
stuff

   Okay, I now fully understand what's wrong in my way of thinking. I thought the 2 while had to be false at the same time for the script to continue to read what's next.
   But, even if I try to write it as while(ObjMove_GetY(obj2) ==  x ){stuff} or while(ObjMove_GetY(obj2) != x){yield;} nothing happens. The only explanation I see to this is because this never happens as the stars can't detect 1pixel of height, to experimment if it's true or not I don't know how to transform x to an interval (ex: x = [x - 1 ; x + 1]). Another explanation would be that if I set the speed of the stars to 3, they move 3 pixels by 3  so they have 33% chance to touch x if they move perpendicularly compared to x, but it's kinda dumb as nothing explode (even if I set the speed to 0.5).
   I tried if(ObjMove_GetY(obj2) == x){stuff} too but it's the same each time, nothing seams to happen when the stars pass through x.
« Last Edit: July 26, 2017, 10:17:04 AM by Axyo »

Drake

  • *
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #760 on: July 26, 2017, 11:10:06 AM »
The only explanation I see to this is because this never happens as the stars can't detect 1pixel of height
Well, basically. That will only work if the two numbers are actually equal, which is probably not going to ever happen when you're using random angles and velocities that will cause the bullet's y-position to rarely be exact integers. In general you shouldn't be looking for exact equality with something like this because of how unpredictable the numbers are.

It's good that you're considering "being inside of a range" because that's also a good approach. I'll just give you the solutions here because you're close enough.

If you swapped the two while conditions, i.e.
Code: [Select]
while(ObjMove_GetY(obj2) < x){yield;}
while(ObjMove_GetY(obj2) > x){yield;}
it would work as intended. If you look at the picture I posted and work out what would happen when the conditions are swapped, you would find that for the same reason the current way fails (the second condition only checks once you finish the first one), this way would succeed.

As for the range check approach, this is essentially a kind of distance calculation.
Code: [Select]
if( (|ObjMove_GetY(obj2) - x|) < 4){ explode(); }Where 4 here is just the range, and the (| |) are for taking the absolute value. For example, if the bullet's y-position is 200, and x is 198, then |200 - 198| = 2, which is less than 4. And if x were 203, then |200 - 203| = 3. So this way would also work fine.
« Last Edit: July 26, 2017, 11:11:39 AM by Drake »

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

Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #761 on: July 26, 2017, 11:31:25 AM »
stuff
   Oh my god, I completely forgot that danmakufu doesn't only read integer numbers but can also read infinitesimal numbers, so indeed, the odds to have the same numbers is null. And for if( (|ObjMove_GetY(obj2) - x|) < 4){ explode(); }, I would never have thought of this, it's quite clever. For the "while" solution, I feel dumb too x)
  Anyway, thanks a lot for taking the time to explain everything to me and make me work on it!
« Last Edit: July 26, 2017, 11:46:52 AM by Axyo »

Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #762 on: August 06, 2017, 01:21:03 PM »
https://pastebin.com/3cAWuCQ2
Sorry for breaking the silence, but this is the problem i wanted to solve very much and a very long time ago...

I wanted to make this magic circle so I replicated some and observed it , it can run, but a few seconds later this happened.
*some of them are added on my desire

Variables of different types are being compared
(型が違う値同士を比較しようとしました)
I:/th_dnh_ph3/script/test MC/test.txt
test.txt line(行)=74


   if(type==true){
   ObjRender_SetScaleXYZ(obj,size+0.2*sin(spin),size+0.2*sin(spin),2);
   }
   ObjMove_SetPosition(obj,ObjMove_GetX(objBoss), ObjMove_GetY(objBoss));
   yield;
   }
   Obj_Delete(obj);
   }

task txt{
   let objText = ObjText_Create();
    O
~~~

Edit : Even this thread have answers, but post it here 1 more time if you all don't mind, it's like more notes to me

« Last Edit: August 06, 2017, 01:26:44 PM by BananaCupcakey »
Just keep it neutral :3

Sparen

  • Danmakufu Artist
  • Git ready, git set, PUUSH!
    • AFCDTech
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #763 on: August 06, 2017, 02:55:14 PM »
Variables of different types are being compared
(型が違う値同士を比較しようとしました)
I:/th_dnh_ph3/script/test MC/test.txt
test.txt line(行)=74


   if(type==true){

In your code (Line 13):
let type = 0;

0 cannot be compared to true in Danmakufu.

HumanReploidJP

  • The Scripter with Something of Common Sense
  • "Start the life of an idol! Let's get STAR~ted!"
    • HumanReploidJP's Youtube Channel
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #764 on: August 08, 2017, 12:27:06 PM »
Need help here!



As I have seen on Nezu Akitsu's |Hoshikami (Star Fox) "Akitsu Nebula"| from Tri Focuser, I might have a grasp difficulty while I'm thinking of creating a shaped laser in a radius like the one with a triangle picture spinning.

Anyone who have knowledge to do about spinning shape lasers? Please Respond!

I've been waiting till December for one of my first complete scripts to be done! :ohdear: :ohdear:
MiraikeiBudoukan (Futuristic Vineyard) Game Concepts (WIP)
(Non-Touhou, yet bullet-hell-Inspirable (Like JynX). Don't get serious.)

Helepolis

  • Charisma!
  • *
  • O-ojousama!?
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #765 on: August 08, 2017, 12:44:44 PM »
Need help here!



As I have seen on Nezu Akitsu's |Hoshikami (Star Fox) "Akitsu Nebula"| from Tri Focuser, I might have a grasp difficulty while I'm thinking of creating a shaped laser in a radius like the one with a triangle picture spinning.

Anyone who have knowledge to do about spinning shape lasers? Please Respond!

I've been waiting till December for one of my first complete scripts to be done! :ohdear: :ohdear:
What is exactly your question?

CrestedPeak9

  • Fangame Advocate
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #766 on: August 08, 2017, 12:51:48 PM »
I think he wants to know how to make a spinning shape made of lasers.

HumanReploidJP you're not a native speaker, are you?
Lunatic 1cc: EoSD, PCB, IN, MoF, TD, DDC, LoLK, HSiFS, WBaWC

Helepolis

  • Charisma!
  • *
  • O-ojousama!?
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #767 on: August 08, 2017, 12:58:30 PM »
I think he wants to know how to make a spinning shape made of lasers.

HumanReploidJP you're not a native speaker, are you?
I am aware what the user wishes/desires, but no specific question was stated. It doesn't really helps to increase font size, change colours and bold out things. Mark up is useful when used proper. Not like this.

HumanReploidJP

  • The Scripter with Something of Common Sense
  • "Start the life of an idol! Let's get STAR~ted!"
    • HumanReploidJP's Youtube Channel
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #768 on: August 15, 2017, 12:00:05 PM »
Oh. sorry about that. My bad.

I'll have to keep that in mind as usual for regular text, not the changed ones.

By the way, I'm not a speaker.
MiraikeiBudoukan (Futuristic Vineyard) Game Concepts (WIP)
(Non-Touhou, yet bullet-hell-Inspirable (Like JynX). Don't get serious.)

TheTeff007

  • Best Touhou 2015!
  • So much cuteness...!
    • Youtube Channel
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #769 on: August 17, 2017, 11:05:05 AM »
So I'm having a little issue with a code. Works, just not as I expected: https://pastebin.com/g9cXaTK4

The player will be filling that bar as they get the corresponding item. However, the bar graphic extends from both sides instead of from down-to-above, leading to this effect: (gauge effect purposefully put on the middle to show full effect, otherwise it will just show a half-full meter) http://imgur.com/a/JpUdB

Since I'm porting my code from an old 0.12m script of mine, the codes don't really translate well. How could I get around this?
Small Teaser of my upcoming project~

No need to call me Teff007. Teff will do just as well~

Drake

  • *
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #770 on: August 17, 2017, 12:18:46 PM »
If you use SetDestCenter on an object so it is always drawn centered, then keep making the object taller, what is going to happen?

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

TheTeff007

  • Best Touhou 2015!
  • So much cuteness...!
    • Youtube Channel
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #771 on: August 17, 2017, 11:49:01 PM »
So since the size of the image is: ObjSprite2D_SetSourceRect(obj1, 0, 0, 16, 111);

Then the solution is: ObjSprite2D_SetDestRect(obj1, -55, -8, 55, 8);

Or what should I do to fix it?
Small Teaser of my upcoming project~

No need to call me Teff007. Teff will do just as well~

Drake

  • *
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #772 on: August 18, 2017, 12:38:16 AM »
Say the object has a y-position of 400. If the rectangle is (-8, -50, 8, 50), the top of the graphic will be at y=350 and the bottom is at y=450. If you make the rectangle bigger on both ends it will keep stretching outwards on both ends; the object is still centered at 400. If you want the bottom of the rectangle to stay at 400 but have the top go up to 300, the box will have to be (-8, -100, 8, 0). To make the rectangle larger only in one direction you only need to make that one direction extend.
« Last Edit: August 18, 2017, 05:40:28 AM by Drake »

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

TheTeff007

  • Best Touhou 2015!
  • So much cuteness...!
    • Youtube Channel
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #773 on: August 18, 2017, 08:58:59 AM »
Worked as Intended. Thanks Drake!
Small Teaser of my upcoming project~

No need to call me Teff007. Teff will do just as well~

Trung0246

  • Gaming, coding, drawing, composing, ... for fun
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #774 on: August 26, 2017, 11:53:36 PM »
When I try
Code: [Select]
WriteLog((16.1 - 16) == 0.1); it return
Code: [Select]
false while
Code: [Select]
WriteLog(ator(16.1 - 16) == 0.1); return
Code: [Select]
trueAnyone know why?

I guess it some kind of memory related issue, as my current OS is Window 10 64 bit

It also did the same behavior with 15.1 - 15, 14.1 - 14, ...
My workbench & codedump
Gallery & album (WIP)

Drake

  • *
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #775 on: August 27, 2017, 01:42:02 AM »
http://en.wikipedia.org/wiki/Floating_point
http://stackoverflow.com/questions/588004/is-floating-point-math-broken
Also https://www.shrinemaiden.org/forum/index.php/topic,16584.msg1168873.html#msg1168873

It isn't a problem, it's just a natural consequence of how computers store numbers.

You shouldn't be relying on testing non-integer values for precise equality anyways (integer calculations work perfectly fine, though), especially if it's a number like a position or angle that's constantly changing, so really this whole thing should never be an issue anywhere to begin with.
« Last Edit: August 27, 2017, 01:49:16 AM by Drake »

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

Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #776 on: August 31, 2017, 07:14:02 AM »
Hi again from my very stupid questions
1. So I made a magic circle but I think it was unstable and it moves not in the center but pushing left and right ...
it looks weird so I ask it, this is the code:
task magiccircle(objBoss,size,type){
   let obj=ObjPrim_Create(OBJ_SPRITE_2D);
   let GCSD = GetCurrentScriptDirectory;
   let img=GCSD~"MG (2).png";
   let spin = 0;
   let s = 0;
   LoadTexture(img);
   ObjPrim_SetTexture(obj,img);
   ObjSprite2D_SetSourceRect(obj,0,0,256,256);
   ObjSprite2D_SetDestCenter(obj);
   ObjRender_SetScaleXYZ(obj,size,size,size);
   ObjRender_SetAlpha(obj,230);
   Obj_SetRenderPriority(obj,0.35);
   while(!Obj_IsDeleted(objBoss)){
   spin += 3;
   ObjRender_SetAngleXYZ(obj,0,0,-spin*1.5);
   ObjRender_SetPosition(obj,ObjMove_GetX(objBoss),ObjMove_GetY(objBoss),0);
   if(type==true){
   ObjRender_SetScaleXYZ(obj,size+0.2*sin(spin),size+0.2*sin(spin),0);
   }
   ObjMove_SetPosition(obj,ObjMove_GetX(objBoss), ObjMove_GetY(objBoss));
   yield;
   }
   Obj_Delete(obj);
}

2. I like scripting but i really suck at cut-in's, so if you all dont mind help me as well thanks so much :3 https://pastebin.com/BNQEF2VA
and i run the script  this happened  :ohdear: :ohdear:  (sorry for interruption but i suck doing these..)
Variables of different types are being compared
(型が違う値同士を比較しようとしました)
I:/th_dnh_ph3/script/function_cutin.txt
function_cutin.txt line(行)=67


   if(type == 0) { x = GetClipMaxX; y = GetCenterY+10; }
   if(type == 1) { x = GetClipMaxX+256; y = GetCenterY-120; }
   if(type == 2) { x = GetClipMinX-256; y = GetCenterY; }

   // handlers
   summontext;
   summonhexagon;
   cutinEffect_Alphret(obj,as,alphre
~~~
« Last Edit: August 31, 2017, 03:59:16 PM by BananaCupcakey »
Just keep it neutral :3

Helepolis

  • Charisma!
  • *
  • O-ojousama!?
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #777 on: August 31, 2017, 07:05:32 PM »
About #2, it seems you're trying to use my cutin script and I have no idea why that error shows up. It points at the function_cutin.txt script for some reason. Did you edit any thing in there?

ExPorygon

  • Veteran Danmakufu Scripter
  • Currently working on a full Touhou fangame!
    • Ephemeral Entertainment
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #778 on: August 31, 2017, 10:10:20 PM »
2. I like scripting but i really suck at cut-in's, so if you all dont mind help me as well thanks so much :3 https://pastebin.com/BNQEF2VA
and i run the script  this happened  :ohdear: :ohdear:  (sorry for interruption but i suck doing these..)
Variables of different types are being compared
(型が違う値同士を比較しようとしました)
I:/th_dnh_ph3/script/function_cutin.txt
function_cutin.txt line(行)=67


   if(type == 0) { x = GetClipMaxX; y = GetCenterY+10; }
   if(type == 1) { x = GetClipMaxX+256; y = GetCenterY-120; }
   if(type == 2) { x = GetClipMinX-256; y = GetCenterY; }

   // handlers
   summontext;
   summonhexagon;
   cutinEffect_Alphret(obj,as,alphre
~~~
You have the wrong number of arguments for the cutin function. It requires (type,spellcardname,cutinImg,left,top,right,bottom). You're missing the spell card name. I imagine that the error has resulted from argument 3, cutinImg, being a number instead of a file path string like it's supposed to be. Danmakufu's error messages are not always very good at pinpointing the precise location of the error.

Edit: Actually, if it was just the wrong number of arguments then Danmakufu would have complained about that (I think). There might be more wrong than there seem to be but that's definitely a problem nonetheless.
« Last Edit: August 31, 2017, 10:13:14 PM by ExPorygon »

Jimmy

  • Shameless spender
  • gaining big pounds
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #779 on: August 31, 2017, 10:43:19 PM »
Hi again from my very stupid questions
1. So I made a magic circle but I think it was unstable and it moves not in the center but pushing left and right ...
it looks weird so I ask it, this is the code:
task magiccircle(objBoss,size,type){
   let obj=ObjPrim_Create(OBJ_SPRITE_2D);
   let GCSD = GetCurrentScriptDirectory;
   let img=GCSD~"MG (2).png";
   let spin = 0;
   let s = 0;
   LoadTexture(img);
   ObjPrim_SetTexture(obj,img);
   ObjSprite2D_SetSourceRect(obj,0,0,256,256);
   ObjSprite2D_SetDestCenter(obj);
   ObjRender_SetScaleXYZ(obj,size,size,size);
   ObjRender_SetAlpha(obj,230);
   Obj_SetRenderPriority(obj,0.35);
   while(!Obj_IsDeleted(objBoss)){
   spin += 3;
   ObjRender_SetAngleXYZ(obj,0,0,-spin*1.5);
   ObjRender_SetPosition(obj,ObjMove_GetX(objBoss),ObjMove_GetY(objBoss),0);
   if(type==true){
   ObjRender_SetScaleXYZ(obj,size+0.2*sin(spin),size+0.2*sin(spin),0);
   }
   ObjMove_SetPosition(obj,ObjMove_GetX(objBoss), ObjMove_GetY(objBoss));
   yield;
   }
   Obj_Delete(obj);
}
Just tested your code out and it works actually perfectly fine. Perhaps the graphic you're using isn't precisely centered, causing the circle to behave strangely (as you've described).
Normal 1cc: EoSD, PCB, IN, PoFV, MoF, UFO, TD, DDC, LoLK Legacy, HSiFS, WBaWC
Hard 1cc: IN, DDC, HSiFS
Extra clears: MoF, DDC, HSiFS, WBaWC

Goals: Going Extra Hard!