Author Topic: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)  (Read 153714 times)

Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #900 on: February 12, 2012, 02:21:33 PM »
Hi... Well I'm new here D:. I've known this forum for long time since, but never registered until now. First, english is not my principal language so if you see some errors, sorry D:.

Wel... I'm here because I'm making a stage, so I made it, I'm at the boss part and I wanted to make a dialogue. I made it, but it crashes... I've tried everything so I hope you can help me t.t. Here is the dialogue code. It crashes just when it ends...

http://pastebin.com/BaMdLe6b

So what am I doing bad?

Welcome to the forum, also please use pastebin when posting big code. --Hele
« Last Edit: February 13, 2012, 09:45:46 AM by Helepolis »

Ozzy

  • Veteran Danmakufu Scripter
  • Currently working on a full Touhou fangame!
Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #901 on: February 12, 2012, 05:41:30 PM »
Hi... Well I'm new here D:. I've known this forum for long time since, but never registered until now. First, english is not my principal language so if you see some errors, sorry D:.

Wel... I'm here because I'm making a stage, so I made it, I'm at the boss part and I wanted to make a dialogue. I made it, but it crashes... I've tried everything so I hope you can help me t.t. Here is the dialogue code. It crashes just when it ends...

So what am I doing bad?

Well first off, I suggest putting large blocks of code like that into pastebin links in the future. It's kind of a rule here.

As for your problem, I believe it's caused by the fact that your script calls GetEventStep while an event isn't running, which causes a crash immediately for some reason. Doing something like this for when you call it should fix the problem:

Code: [Select]
if(OnEvent == true) {
if(GetEventStep == 1) { DoStuff; }
}

With this, the program should only call GetEventStep when it's ok to do so.

MMX

  • In Soviet Gensokyo...
  • ...bullets dodge you.
    • LiveJournal blog
Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #902 on: February 14, 2012, 05:21:32 PM »
I want to track if two moving straight lasers intersect, and if they do - get the coordinates of intersection. I know that it could be easily calculated cause object lasers always offer coordinates of both endpoints. The problem is how to organize laser per laser comparsion when there are a lot of them at the same time, as every laser "lives on it's own" by an instance of the same task ??? Do i need to store a dynamic array containing coordinates of all lasers present at the moment or something?
My danmakufu thread Most recent - "Kappa Mechanics" (Nitori fight)   My youtube channel Latest update - EoSD extra no bombs clear


Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #903 on: February 14, 2012, 05:26:07 PM »
either that or create your objects outside your task.

MMX

  • In Soviet Gensokyo...
  • ...bullets dodge you.
    • LiveJournal blog
Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #904 on: February 14, 2012, 05:32:14 PM »
either that or create your objects outside your task.
Hmm.. how do i manage them then? I always imagined that if i need some uncertain ammount of dynamic objects (that need some processing, not just creation) it should be done through calling every new object as an instance of a task. It's easy and flexible for all kind of objects from bullets to menus. And how could it be done without tasking? Through an array of objects? :wat:
My danmakufu thread Most recent - "Kappa Mechanics" (Nitori fight)   My youtube channel Latest update - EoSD extra no bombs clear


Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #905 on: February 14, 2012, 06:05:37 PM »
Either that or just be exhaustive. I dunno how many lasers at a time you need, though.

And just go to ph3, man.

MMX

  • In Soviet Gensokyo...
  • ...bullets dodge you.
    • LiveJournal blog
Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #906 on: February 14, 2012, 06:30:17 PM »
And just go to ph3, man.
I heard that in ph3 objects are objects and you can retreive any of their data when you want. But how a swarm of independent objects could be managed there?
My danmakufu thread Most recent - "Kappa Mechanics" (Nitori fight)   My youtube channel Latest update - EoSD extra no bombs clear


Blargel

  • RAWR!
  • I'M AN ANGRY LOLI!
Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #907 on: February 15, 2012, 01:30:22 AM »
Best answer I can give to that is arrays or a task per object.
<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.

Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #908 on: February 15, 2012, 03:45:51 PM »
Hey, I wanted to say thanks for the answer and sorry about the code I didnt know I had to use pastebin D:. Well it worked so thanks again ^^

MMX

  • In Soviet Gensokyo...
  • ...bullets dodge you.
    • LiveJournal blog
Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #909 on: February 15, 2012, 06:58:04 PM »
Ok. I'll try to do it with array of coordinates. But i've got another question. If i use erase command to remove a certain entry from array, does that mean all entries after it will get their indexes decreased? This totally breaks the plan, cause task must keep the correct index of an array cell it refers to. The only other way to manage an uncertain "cloud" of objects that comes in mind is common data, wich is ridiculous, but might work (it works well for processing power items, but that was in case of necessity of data exchange between the scripts).
My danmakufu thread Most recent - "Kappa Mechanics" (Nitori fight)   My youtube channel Latest update - EoSD extra no bombs clear


Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #910 on: February 15, 2012, 07:13:36 PM »
Uh well instead of erasing that entry, just overwrite it then ...

MMX

  • In Soviet Gensokyo...
  • ...bullets dodge you.
    • LiveJournal blog
Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #911 on: February 15, 2012, 07:18:49 PM »
Uh well instead of erasing that entry, just overwrite it then ...
Wat? U seem not getting the process i want to perform. Imagine i have a bunch of lasers flying and an array containing coordinates of all their endpoints. Each laser refers to a certain cell of that array and it's task updates the value until laser is gone. What do i need to do when laser is gone and it's cell is not in use? How could i overwrite it, or i mean how new instances of task for new lasers spawned could know about any unused cells? That sounds too complicated for such an easy goal. I think i'll try to use common data for it...Wait a minute... there will be the some problems too, cause that power items routine i made does just the opposite i want here. But screw it, i'll try anyway :colonveeplusalpha:
« Last Edit: February 15, 2012, 07:27:05 PM by MMX »
My danmakufu thread Most recent - "Kappa Mechanics" (Nitori fight)   My youtube channel Latest update - EoSD extra no bombs clear


Drake

  • *
Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #912 on: February 15, 2012, 07:28:38 PM »
Use null/default values. I did this exact technique in the pixel contest, and although my entry was awful, it's basically what you're trying to do.

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

Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #913 on: February 15, 2012, 07:36:28 PM »
Like Drake says, overwrite it with an arbitrary default value, like (-1000), and check if your value is (-1000) before doing your stuff.

MMX

  • In Soviet Gensokyo...
  • ...bullets dodge you.
    • LiveJournal blog
Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #914 on: February 15, 2012, 07:37:04 PM »
Use null/default values. I did this exact technique in the pixel contest, and although my entry was awful, it's basically what you're trying to do.
Hmm.. You mean just "forget" those unused cells so array will grow with every new entry no matter of how many of them actually are? I think it will work since there will be not very much lasers spawned during the spellcard i'm working on, though it's such a waste.

Also, speaking of danmakufu contests. Will there be any new ones? Noone happened since i've joined MoTK but i want to participate so much :3
My danmakufu thread Most recent - "Kappa Mechanics" (Nitori fight)   My youtube channel Latest update - EoSD extra no bombs clear


Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #915 on: February 15, 2012, 08:31:37 PM »
Uh well no you don't *have to* always expand your array, you can just overwrite the unused indexes, especially if you know the maximal number of array at a time.

MMX

  • In Soviet Gensokyo...
  • ...bullets dodge you.
    • LiveJournal blog
Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #916 on: February 15, 2012, 09:20:36 PM »
Uh well no you don't *have to* always expand your array, you can just overwrite the unused indexes,
But to find if there is any unused cell i have to parse the array from the beginning? Well it's not a big problem when array isnt really big. Thanks for advices, though, as i said before, i'll try "fake common data indexing" first, cause deleting an entry from CD doesnt affect the rest. It only will return "No data" on next parse.

especially if you know the maximal number of array at a time.
Do you mean length function?
My danmakufu thread Most recent - "Kappa Mechanics" (Nitori fight)   My youtube channel Latest update - EoSD extra no bombs clear


Blargel

  • RAWR!
  • I'M AN ANGRY LOLI!
Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #917 on: February 15, 2012, 09:38:11 PM »
Instead of storing the coordinates in the array, store the object ids. You can grab the coordinates from the object ids. That way you don't need to constantly update the array, nor do you need to worry about which index belongs to what object. You can then use the erase function without worrying about the indexes.
<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.

MMX

  • In Soviet Gensokyo...
  • ...bullets dodge you.
    • LiveJournal blog
Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #918 on: February 15, 2012, 09:48:01 PM »
Instead of storing the coordinates in the array, store the object ids. You can grab the coordinates from the object ids. That way you don't need to constantly update the array, nor do you need to worry about which index belongs to what object. You can then use the erase function without worrying about the indexes.
Oh geez! Why havent i thought about it? So an object can actually "put" itself into array? like
Code: [Select]
array=array~[obj];

How do i need to define the array first then? like
Code: [Select]
let tmp=Obj_Create(OBJ_LASER);
let array=[tmp];

Oh shi-- tried just now and it works! Thanks a lot, that was the best idea ever  :*



So now my task looks like that
Code: [Select]
task Laser(x,y,aim){
let obj=Obj_Create(OBJ_LASER);
lasers=lasers~[obj];
let laserid=length(lasers)-1;

  *  *  *

Obj_Delete(obj);
erase(lasers,laserid);
}

Hmm.. But calling erase function doesnt affect array length for some reason :wat:
« Last Edit: February 15, 2012, 10:04:18 PM by MMX »
My danmakufu thread Most recent - "Kappa Mechanics" (Nitori fight)   My youtube channel Latest update - EoSD extra no bombs clear


Azure Lazuline

  • Looooove!!
  • PM me for free huggles and love!
    • Entanma Project - indie game development
Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #919 on: February 15, 2012, 10:18:38 PM »
lasers = erase(lasers, laserid)

MMX

  • In Soviet Gensokyo...
  • ...bullets dodge you.
    • LiveJournal blog
Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #920 on: February 15, 2012, 10:23:42 PM »
lasers = erase(lasers, laserid)
Yeah already fixed this :facepalm: It works now, but causes an error sometimes and crashes danmakufu. I smell erase decreases length of an array causing other later erases go out of bounds :qq:

Oh well. I've got it. Looks like i dont need to erase an array entry from the task, but while parsing it for laser data comparsion. Just one question: what will array cell contain when i call Obj_Delete in task? NULL? Screw this. I forgot about  Obj_BeDeleted function.

But damn again it causes error 126 and crashes danmakufu. Here's the task testing this
Code: [Select]
task ParseLasers{
let num=0;
loop{
num=length(lasers);
if (num>1){
ascent(i in 1..num){
if(Obj_BeDeleted(lasers[i])){
lasers=erase(lasers,i);
num--;
}
}
}
yield;
}
}
I'm curious, does decreasing of num affect ascent, or should i use while?
UPD: Just as planned! Replacing ascent (i in 1..num) with while (i<num) fixes the problem. Maaan, make another note on danmakufu weird bugs list
Oh and it's so fun to answer own questions in the thread yourself :D
« Last Edit: February 15, 2012, 11:42:20 PM by MMX »
My danmakufu thread Most recent - "Kappa Mechanics" (Nitori fight)   My youtube channel Latest update - EoSD extra no bombs clear


Drake

  • *
Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #921 on: February 15, 2012, 11:38:03 PM »
Why did you not actually look at my entry like I advised instead of asking all these questions that would have been answered by looking at my entry.

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

Blargel

  • RAWR!
  • I'M AN ANGRY LOLI!
Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #922 on: February 15, 2012, 11:39:13 PM »
Yeah already fixed this :facepalm: It works now, but causes an error sometimes and crashes danmakufu. I smell erase decreases length of an array causing other later erases go out of bounds :qq:

Oh well. I've got it. Looks like i dont need to erase an array entry from the task, but while parsing it for laser data comparsion. Just one question: what will array cell contain when i call Obj_Delete in task? NULL?

It will be unaffected. You aren't storing the object in the array, you're storing a number that identifies the object, thus why I refer to it as an object id. When the object is deleted, the id is still stored in the array. Any attempt to use that id won't cause any errors, but won't return any meaningful information either. Instead of using erase(lasers,laserid); at the end of your task, which actually causes major problems, you can call Obj_BeDeleted on each element in the array before grabbing the coordinates. If it has been deleted, go ahead and erase it.

As a sidebar, if you do plan to erase elements in an array, make sure you are iterating through the array with descent instead of ascent. If you want to know why, imagine this scenario.

Code: [Select]
array = [0, 1, 2, 3, 4 ,5]
ascent(i in 0..length(array)){
    if(i == 3){
        array = erase(array, i);
    }
    let blah = i;
}

This would raise an error. Why? Because when i goes from 0 to 5 in order, array[5] no longer exists by the time it gets to the last iteration of the ascent loop. Incidentally, this also causes it to skip over an element in the array. However, if you replace ascent with descent, it'll start with the last element first, which definitely will not be deleted already. It also will not skip over anything anymore.
<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.

MMX

  • In Soviet Gensokyo...
  • ...bullets dodge you.
    • LiveJournal blog
Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #923 on: February 15, 2012, 11:44:48 PM »
Why did you not actually look at my entry like I advised instead of asking all these questions that would have been answered by looking at my entry.
Because Blargel posted a more interesting idea. Thanks for your advice too ;)
Well guys'n'gals. Seems like it works like it should for now so i wont flood the thread until some new shit happens.

And again big thanks for all suggestions and answers, it helped me a lot ;)
My danmakufu thread Most recent - "Kappa Mechanics" (Nitori fight)   My youtube channel Latest update - EoSD extra no bombs clear


MMX

  • In Soviet Gensokyo...
  • ...bullets dodge you.
    • LiveJournal blog
Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #924 on: February 15, 2012, 11:50:26 PM »
This would raise an error. Why? Because when i goes from 0 to 5 in order, array[5] no longer exists by the time it gets to the last iteration of the ascent loop. Incidentally, this also causes it to skip over an element in the array. However, if you replace ascent with descent, it'll start with the last element first, which definitely will not be deleted already. It also will not skip over anything anymore.
Not only on the last but on every iteration. Looks like ascent limits get fixed once it's called. So yeah, descent or while cycles are needed for this.

Fuck. Doublepost. Moderators, please merge or delete this nonsense :fail:
My danmakufu thread Most recent - "Kappa Mechanics" (Nitori fight)   My youtube channel Latest update - EoSD extra no bombs clear


Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #925 on: February 17, 2012, 12:57:04 PM »
I have a question for Danmakufu 0.12
Let's say I have a script for a Spellcard. I can run it, but only if I input either REIMU or MARISA in the #PLAYER selection stuff in the script. If I put FREE, Danmakufu suddenly shut down with no message. So in shorts, I cannot use custom player script. How do I fix these kind of problem? I guess that I haven't modify something yet in Danmakufu after I installed it but i don't know. And it's worse when I need to run a full-bossfight script. I cannot play it at all.
PS: Yes, the custom player script is still in the Player folder. So I think the problem came from
Sorry, it's hard to word all of these problems easily. English isn't really my native languege. Let's just say I cannot run bossfight-script at all since Danmakufu just suddenly shut down when I select the boss-script.
Thanks for replying.

MMX

  • In Soviet Gensokyo...
  • ...bullets dodge you.
    • LiveJournal blog
Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #926 on: February 17, 2012, 02:51:14 PM »
If I put FREE, Danmakufu suddenly shut down with no message.
That's weird. Try to reinstall danmakufu and be sure to run it through applocale.



Meanwhile: The script with intersecting lasers i was asking before is complete and works well. Though i've noticed one thing - it causes massive memory leak. Through method of exclusion i've found that it's caused by array concatenation
Code: [Select]
lasers=lasers~[obj];Even when i erase unused cells and reset array on every new wave it keeps eating megabytes like it's no thing. And dnh doesnt free them away after script ends, so it may cause some HUEG memory invasion after lots of restarts.
So i dunno, am i doing something wrong, or it's just common way danmakufu works with arrays?
« Last Edit: February 17, 2012, 11:34:57 PM by MMX »
My danmakufu thread Most recent - "Kappa Mechanics" (Nitori fight)   My youtube channel Latest update - EoSD extra no bombs clear


xForeverFanaticx

  • Bomb ALL the Spellcards!
Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #927 on: February 19, 2012, 04:14:52 PM »
How would one make a curvy laser-esque player shot? ._." If it's even possible.

MMX

  • In Soviet Gensokyo...
  • ...bullets dodge you.
    • LiveJournal blog
Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #928 on: February 19, 2012, 04:30:05 PM »
How would one make a curvy laser-esque player shot? ._." If it's even possible.
Yes, it's possible. Use Obj_Create(OBJ_SINUATE_LASER)and then process it with proper functions
« Last Edit: February 19, 2012, 04:32:07 PM by MMX »
My danmakufu thread Most recent - "Kappa Mechanics" (Nitori fight)   My youtube channel Latest update - EoSD extra no bombs clear


Drake

  • *
Re: ※ Q&A/Problem Thread 5 ※ for OLD Danmakufu version (0.12m)
« Reply #929 on: February 19, 2012, 09:08:15 PM »
I have a question for Danmakufu 0.12
Let's say I have a script for a Spellcard. I can run it, but only if I input either REIMU or MARISA in the #PLAYER selection stuff in the script. If I put FREE, Danmakufu suddenly shut down with no message. So in shorts, I cannot use custom player script. How do I fix these kind of problem? I guess that I haven't modify something yet in Danmakufu after I installed it but i don't know. And it's worse when I need to run a full-bossfight script. I cannot play it at all.
The problem is likely that you aren't running Danmakufu under Japanese locale, and it's trying to read japanese characters from the Rumia scripts, but it can't.

Please go through these steps.
http://www.shrinemaiden.org/forum/index.php/topic,4138.0.html

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