ZFGC

Resources => Coding => Topic started by: Mewgull on December 08, 2007, 01:49:27 pm

Title: [Help]What am I doing wrong with this code?!!?!
Post by: Mewgull on December 08, 2007, 01:49:27 pm
What am I doing wrong with this code?
Code: [Select]
object_set_solid(self,1)
object_set_parent(self, objFloor)

I put the "ind" as self, because its for the current object that the code is in.
I put 1 in as the solid, because  I want it to be solid, and I put objFloor as it's parent.
But nothing's working!!
What wrong

-Mewgull

PS: What does "ind" mean anyways? and what should I put ind as for future referance?
Title: Re: [Help]What am I doing wrong with this code?!!?!
Post by: hawthorneluke on December 08, 2007, 03:03:44 pm
this is how i go about such problems

find what you want (in this case, object_set_solid)
go to the help, search for "object_set_solid"

object_set_solid(ind,solid) Sets whether instances created of the object must default be solid (true or false).

ok, quite obvious, but it says nothing about the arguments, so lets look up a bit at the other generic ones

object_set_sprite(ind,spr) Sets the sprite of the object with the given index. Use -1 to remove the current sprite from the object.

so ind must mean the object

and so, you're using it correctly.

but, there are alternatives

"solid=1"
is what i've always used. never even knew "object_set_solid" existed.

but you see, object_set_solid probably sets the OBJECT to be a solid one, not just that instance (so you can object the general object properties whenever.)
self refers to that INSTANCE of the object. so that wont work

solid=1 will be fine though.

again, the same goes for "object_set_parent"

but thats something special. you wouldnt really want to change that on the fly O_o

but if you really do :S then you need to change the parent for all instances of that object it seems and so:
"object_set_parent(objWhatever,objFloor)"

objWhatever being the object you want to alter.
like i said, "self" applies to that instance and that just wont work in this case. as these are to change the actual object properties.
Title: Re: [Help]What am I doing wrong with this code?!!?!
Post by: Mewgull on December 08, 2007, 04:50:04 pm
Thanks, you cleared up a lot for me :)
It works now. I just had to do it from a different object and not in the "step" event
Title: Re: [Help]What am I doing wrong with this code?!!?!
Post by: mit on December 08, 2007, 05:23:38 pm
Yeah, the object_set_ functions are for changing the 'master' values, that an object will have when it's created.

To set something to an object that exists already, use 'solid' or 'object0.solid'

Contact Us | Legal | Advertise Here
2013 © ZFGC, All Rights Reserved