Pages: 1
Author Topic: position_destroy()  (48,656 Views)
Offline (Unknown gender) Brother156

Member
Joined: Apr 2010
Posts: 1
View profile
Posted on: April 21, 2010, 11:07:41 PM
Hi, well I wanted to help out a little. I made a VERY simple gml code for position_destroy() as you don't have it in the list of done functions:

with (all) {
if (x > argument0 and x < argument2 and y > argument1 and y < argument3){
instance_destroy();}}


By the way, how can I add these to the ENIGMA R3 I downloaded?
Offline (Unknown gender) retep998

Member
Joined: Jan 2010
Posts: 248
View profile
Reply #1 Posted on: April 21, 2010, 11:29:34 PM

with (all) {
if (x==argument0 and y==argument1){
instance_destroy();
}
}

Go read the documentation on position_destroy's arguments before you try to code it.
Also, don't do anything for R3.
R4 is coming very soon, and it'll have a feature called whitespace where you can add your own functions.

If you really want to help, go learn advanced C++, check out a copy of the latest trunk revision, and ask Josh what you can work on.
Offline (Unknown gender) RetroX

Master of all things Linux
Contributor
Joined: Apr 2008
Posts: 1,055
View profile
Reply #2 Posted on: April 21, 2010, 11:42:30 PM
"Own functions" meaning C++, not GML.
Offline (Unknown gender) Josh @ Dreamland

Prince of all Goldfish
Developer
Joined: Feb 2008
Posts: 2,950
View profile
Reply #3 Posted on: April 22, 2010, 12:07:21 AM
Now now, retep, he can edit R3 if he likes.
In actuality, neither code is correct. If I recall correctly, position_destroy() operates based on collision, not based solely on a precise position. Meaning that it'd do a collision_point-style test to determine if the instance is to be destroyed.

However, I still appreciate the effort. If more people showed this incentive, ENIGMA would be done in no time.

As far as adding it to R3, you can't; R3's with() isn't set up in such a way that it can work in plain C++ code (R4's may yet be, though). Don't worry, though; as soon as the collision system is in (and the new instance system, for that matter), I will implement this function.
Offline (Unknown gender) retep998

Member
Joined: Jan 2010
Posts: 248
View profile
Reply #4 Posted on: April 22, 2010, 12:46:26 AM
with (all) {
   if (collision_point(argument0,argument1,self,true,false)){
      instance_destroy();
   }
}
Offline (Unknown gender) Josh @ Dreamland

Prince of all Goldfish
Developer
Joined: Feb 2008
Posts: 2,950
View profile
Reply #5 Posted on: April 22, 2010, 01:10:03 AM
Now if only that code was more of a function and less of a script. :P
Offline (Unknown gender) Micah

Resident Troll
Joined: Jun 2008
Posts: 128
View profile
Reply #6 Posted on: April 22, 2010, 01:13:55 AM
The dichotomy between the two is pretty stupid. Although it's nice that since scripts are resources, you have script passing.
Offline (Unknown gender) retep998

Member
Joined: Jan 2010
Posts: 248
View profile
Reply #7 Posted on: April 22, 2010, 01:44:15 AM

void position_destroy(int x,int y){
   with (all) {
      if (collision_point(x,y,self,true,false)){
         instance_destroy();
      }
   }
}
Offline (Unknown gender) Josh @ Dreamland

Prince of all Goldfish
Developer
Joined: Feb 2008
Posts: 2,950
View profile
Reply #8 Posted on: April 22, 2010, 02:31:24 AM
<_<"
Offline (Unknown gender) retep998

Member
Joined: Jan 2010
Posts: 248
View profile
Reply #9 Posted on: April 22, 2010, 03:27:41 AM
Does position_destroy return anything?
maybe a bool?
true if it deleted something
false otherwise
???
profit
Offline (Unknown gender) Josh @ Dreamland

Prince of all Goldfish
Developer
Joined: Feb 2008
Posts: 2,950
View profile
Reply #10 Posted on: April 22, 2010, 06:12:46 PM
I don't believe it does; and if that's the case, I'm not implementing that in ENIGMA. Functions that are used (especially heavily, which position_destroy may not be) in GM should seek to execute the exact functionality as quickly as possible. No one has made use of a return value for that function; adding one will only slow things down (if not by much). If it were truly useful, though, I'd consider it; I don't see how that's the case when int a = instance_count; position_destroy(); show_message(instance_count - a); is an option.
Pages: 1