The Daily Click ::. Forums ::. Klik Coding Help ::. Create Object
 

Post Reply  Post Oekaki 
 

Posted By Message

\/\/olf

Creative Genius

Registered
  06/08/2005
Points
  76

VIP Member
17th November, 2007 at 06:23:23 -

Hey, I was wondering if there was anyway to create an object and setting its position using 'retreive from expression' command? i know the object's position can set manually by using set x and set y commands but im gonna have multiple copies of the same object. And that means if i use set x and y, every one of the objects will be set to the same position. and even the position will vary, depending on the user's preference.

so is there anyway to create an object and setting its position using 'retreive from expression' command? cause that will make everything so much simpler than having to use spread value. and im not very good at that.

 
Image

www.OldMansTale.net
Sign the Petition! Go go Go!!

alastair john jack

BANNED

Registered
  01/10/2004
Points
  294

GOTW WINNER CUP 1!GOTW WINNER CUP 2!GOTW WINNER CUP 3!VIP MemberMushroomI am an April Fool
17th November, 2007 at 06:43:46 -

But if you order them, they won't all go to the same place. I think..

 
lol

viva/volt

Awesome Sauce

Registered
  26/08/2006
Points
  1694

Game of the Week WinnerSilverNova MemberKlikCast StarVIP Member
17th November, 2007 at 06:50:55 -

Yea, if you do:

Create object

Set X object to 1000*10034
Set Y objectto 453/235

then it will be instance specific if it's in the same event

 
Image
http://bfollington.tumblr.com

\/\/olf

Creative Genius

Registered
  06/08/2005
Points
  76

VIP Member
17th November, 2007 at 06:56:08 -

ahhh, well, i thought i had thought up of a solution.

here's wt i did. i made two variables, x and y. now these variables determine where the newly created object should go. and they work just fine. also, since theres no way, apparently, to use a get expression command when creating an object, i had to make a 'Positioner' object and set its position to var x and y, always.

then whenever i create an object, i set its x and y relative to 'Positioner' object. Now, the problem is, that var x and y changes every 20th of a second and the bloody program only creates the new objects 2 times. i tried changing the timer to 50th of a second but to no avail. it only works the first two times.

i tried using fastloop but it crashed the app. help, anyone??

 
Image

www.OldMansTale.net
Sign the Petition! Go go Go!!

\/\/olf

Creative Genius

Registered
  06/08/2005
Points
  76

VIP Member
17th November, 2007 at 07:03:11 -

didnt know it would be instance specific that way. thanks, but it still doesnt solve my current problem. read the above post. it only works 2 times

Image Edited by the Author.

 
Image

www.OldMansTale.net
Sign the Petition! Go go Go!!

\/\/olf

Creative Genius

Registered
  06/08/2005
Points
  76

VIP Member
17th November, 2007 at 07:09:51 -

OMG, i figured it out. i deleted one object from the level to see if it was becasue mmf has some memory limitation and it worked 3 times! i deleted another object and it worked 4 times. wt the hell? is there anyway to increase the max no. of objects? or will i have to resort to deleting my objects? cause i need maximum 10 of these 'newly' created objects.

 
Image

www.OldMansTale.net
Sign the Petition! Go go Go!!

viva/volt

Awesome Sauce

Registered
  26/08/2006
Points
  1694

Game of the Week WinnerSilverNova MemberKlikCast StarVIP Member
17th November, 2007 at 07:38:24 -

Click on your frame in the application list (above properties) and there is an object limit box that should read 500. set it anywhere from 0 - 20000.

 
Image
http://bfollington.tumblr.com

Pixelthief

Dedicated klik scientist

Registered
  02/01/2002
Points
  3419

Game of the Week WinnerWeekly Picture Me This Winner!You've Been Circy'd!VIP MemberI like Aliens!Evil klikerThe SpinsterI donated an open source project
17th November, 2007 at 09:55:50 -

MMF runs by narrowing down the selection of objects via the events on the left hand side of the list, and then applying actions to them as specified inside the grid/array. HOWEVER, some actions, such as "Create Object", will specify its control again. So whenever a create object order is issued, every action after that action that references that kind of object will ONLY reference that object. Meanwhile, any action put on the event list BEFORE the create object action, will effect all objects specified by the left-hand events.

So if you have a generic "user hits space bar" event, that doesn't specify any of your active objects, you could have these two nearly identical pieces of code:

+Upon hitting space
-Create an Object
-Object: Set X to 1000
-Object: Set Y to 1000

OR

+Upon hitting space
-Object: Set X to 1000
-Object: Set Y to 1000
-Create an Object

The first piece of code will do what you want; create 1 object and set only that instance of it to (1000,1000)
The second code, will set ALL objects already in the field to (1000,1000), then create the new object wherever.



If you want to create more then 1 instance of an object in a single piece of code, and set them to different positions according to the X/Y expressions, that may not be altogether possible. I'm not sure, but you might be able to order events in MMF2 in the event list so that you could have 1 create object command, then 1 set position, then another create object, ect. Thats not possible in TGF, as all actions from a single grid location in the queue are given the same precedence, albeit with their own mini-queue.

The best workaround, otherwise, would be to either copy/paste your piece of code several times, changing the position in each one (and making it so they all trigger in the same read/eval/print loop), OR simply putting it into a fastloop, and having the different positions be according to a mathematical equation, based upon the loop index.

 
Gridquest V2.00 is out!!
http://www.create-games.com/download.asp?id=7456

\/\/olf

Creative Genius

Registered
  06/08/2005
Points
  76

VIP Member
17th November, 2007 at 15:32:36 -

Thank you all. By applying what Mr. Benta Claus told me, everything worked out just fine.

 
Image

www.OldMansTale.net
Sign the Petition! Go go Go!!
   

Post Reply



 



Advertisement

Worth A Click