The Daily Click ::. Forums ::. Klik Coding Help ::. How to add a variable to the name of an object when you call one of it's alterables values ?
 

Post Reply  Post Oekaki 
 

Posted By Message

Spitznagl

Cabinetmaker

Registered
  06/12/2008
Points
  4260

The SpinsterVIP MemberHas Donated, Thank You!Picture Me This Round 29 Winner!Picture Me This Round 31 Winner!Picture Me This Round 36 Winner!
25th January, 2009 at 20:43:07 -

I'm wondering how you can add a numeric variable to the name of an object in the Expression Editor. I'm pretty sure it can be done, since I remember something similar from when I started learning Cplus a while ago(I abandoned). I just don't know how it is done in MMF.

SO...
Instead creating events for:
Value("heart1")
Value("heart2")
Value("heart3")
...

I'd like to do something like:
Value("heart" value(FilledHearts))

FilledHearts would set from 1 to 16 indepently.
This way I could write a single line of code for all 16 objects.

I searched in the help file, but didn't find a thing.
Many thanks to my futur savior!

 
...

aphant



Registered
  18/05/2008
Points
  1242
25th January, 2009 at 21:02:05 -

I'm not sure what you're talking about, but it should be possible using an alterable value.

 

Jon Lambert

Administrator
Vaporware Master

Registered
  19/12/2004
Points
  8235

VIP MemberWii OwnerTDC Chat Super UserI am an April FoolSSBB 3265-4741-0937ACCF 3051-1173-8012360 Owner
25th January, 2009 at 21:15:19 -

I wouldn't know how to do it, I don't think it can be done, because you can't mix names and values. To clarify the problem, what spitznagl wants is a way to refer to multiple objects whose names differ only by a number in the name.

Instead of events for "Heart1" "Heart2" "Heart3", spitznagl wants one event to say "Heart(value Counter(Hearts))" but you can't do that because it assumes that everything in quotations is part of the name, and will not accept terms outside of quotations.

 
Sandwich Time!Whoo!

JoyCheck & KeyCheck Widgets
For easy implementation of customizable joystick and keyboard controls.
http://www.create-games.com/download.asp?id=8364

Spitznagl

Cabinetmaker

Registered
  06/12/2008
Points
  4260

The SpinsterVIP MemberHas Donated, Thank You!Picture Me This Round 29 Winner!Picture Me This Round 31 Winner!Picture Me This Round 36 Winner!
25th January, 2009 at 21:48:27 -

It's exactly what I meant.
Thanks Jon!

It tought it was because of punctuation or some other human(me)mistakes, but from what you say, I just can't do it.

So if I understand, only text goes between the cotation, and evererything outside of those stupids"" is refused.

But what about two pairs of "" the second one being an alterable string or some text based thingy wich I don't yet know? There must be a way!

All I know is that it'd be SUPERefficient.

 
...

Klikmaster

Master of all things Klik

Registered
  08/07/2002
Points
  2599

Has Donated, Thank You!You've Been Circy'd!VIP MemberPS3 Owner
25th January, 2009 at 21:52:54 -

What you want to do is possible, just not the way you're trying to do it.

Instead give your objects an ID by using an alterable value and check against that value.

 
n/a

Jon Lambert

Administrator
Vaporware Master

Registered
  19/12/2004
Points
  8235

VIP MemberWii OwnerTDC Chat Super UserI am an April FoolSSBB 3265-4741-0937ACCF 3051-1173-8012360 Owner
25th January, 2009 at 21:59:50 -

The way spitznagl has it though, is that each different named one is a seperate object. To do what you say then, Klikmaster, spitznagl would have to put them in a group together using a qualifier, or make them all the same object and then do what you say. Are you using these objects for a heart counter? Because if you are, it might be easier to make an animated counter as opposed to representing them with different objects.

 
Sandwich Time!Whoo!

JoyCheck & KeyCheck Widgets
For easy implementation of customizable joystick and keyboard controls.
http://www.create-games.com/download.asp?id=8364

-MacAdaM-

Megaman Fosho

Registered
  12/02/2008
Points
  560
25th January, 2009 at 22:07:18 -

Couldn't you just put all the objects in the same group?
Then just use the group in the event editor?

Or am I mis-understanding the question?


EDIT:
Sorry, I diddn't see your post Jon Lambert.

Edited by -MacAdaM-

 
Your just jealous that you're not as awesome as me.
(And my megaman avatar )

Spitznagl

Cabinetmaker

Registered
  06/12/2008
Points
  4260

The SpinsterVIP MemberHas Donated, Thank You!Picture Me This Round 29 Winner!Picture Me This Round 31 Winner!Picture Me This Round 36 Winner!
25th January, 2009 at 22:19:00 -

It is indeed for a heart counter, and while it is true that I could do a 64 images animated counter, wich would be long (and probably tale more memory because of the spaces), I'd still like to know how to do it the other way. It might be more useful later on!

If you have the time, could you quikly explain me what you meant by objects ID, or how "putting them in a group together using a qualifier" would help me. I'm a starter, and this seems hard to figure by myself without much explenations.

Thanks to all of you!

 
...

Spitznagl

Cabinetmaker

Registered
  06/12/2008
Points
  4260

The SpinsterVIP MemberHas Donated, Thank You!Picture Me This Round 29 Winner!Picture Me This Round 31 Winner!Picture Me This Round 36 Winner!
25th January, 2009 at 22:24:45 -

Also now that I think of it, an animated counter reprensenting every hearts is impossible. Like a la Zelda, I want to start with 3 hearts, gain more containers later on, but when you lose life, I want to see an outer frame, on thoses which are empty.

 
...

aphant



Registered
  18/05/2008
Points
  1242
25th January, 2009 at 22:41:43 -

I think I know how to implement what you want. I'm going to try it out before I suggest it, though.

 

Spitznagl

Cabinetmaker

Registered
  06/12/2008
Points
  4260

The SpinsterVIP MemberHas Donated, Thank You!Picture Me This Round 29 Winner!Picture Me This Round 31 Winner!Picture Me This Round 36 Winner!
25th January, 2009 at 22:50:19 -

The way I had it planned, is something like what follows:

Heart8 = 0
->
Set HeartFilled to 7
Make Heart8 invisible
--------------------------------------------
flag 1 on (when taking damage)
If HeartFilled = 7
->
Set life to (life - damage)
Set Heart7 to (life-((heartFilled-1)*4))
--------------------------------------------

It would work way better if I could do it with a handfull of lines.
And thanks to all for your time. Hope I can help back one day.

 
...

aphant



Registered
  18/05/2008
Points
  1242
25th January, 2009 at 23:25:19 -

You could use two overlapping animated counters. One for the maximum number of hearts, to show how many containers you have. The second, to show the amount of life left the player has.

The only problem with this is that counters are very stubborn in which one is "on top."

 

Spitznagl

Cabinetmaker

Registered
  06/12/2008
Points
  4260

The SpinsterVIP MemberHas Donated, Thank You!Picture Me This Round 29 Winner!Picture Me This Round 31 Winner!Picture Me This Round 36 Winner!
25th January, 2009 at 23:37:42 -

I guess if all the hearts are stacked closed, it would be alright. One animated counter would have 64 imges, while the other only 13 (since you start at 3 hearts).
That is definitly a reserve solution.

I'm definitly still eager to learn how to do it my way though.

 
...

aphant



Registered
  18/05/2008
Points
  1242
25th January, 2009 at 23:49:18 -

I made an example: http://www.pfordee.com/psychophan7/hearts.mfa
Press up/down to alter hearts, left/right to alter containers. Press escape to close.

This bit of code:
- Current frame of "heart" > Image("container")+1
= heart: Force animation to frame Image("heart")-1

Makes it so that you can never have more hearts than containers. The container+1 bit exists because there are 7 frames for the red hearts, from 0 to 6, while there are 6 frames for containers 1 to 6 (you can't have 0 containers, after all!) To make it track quarter segments instead of wholes, you could change the condition to:

- Current frame of "heart" > (Image("container")+1)/4
(At least, I think this should work.)

 

Spitznagl

Cabinetmaker

Registered
  06/12/2008
Points
  4260

The SpinsterVIP MemberHas Donated, Thank You!Picture Me This Round 29 Winner!Picture Me This Round 31 Winner!Picture Me This Round 36 Winner!
26th January, 2009 at 02:35:28 -

Thanks alot for your time Adam. It works wonderfully.
I'll just add one more condition (numb of container > numb of heart) instead of deleting one heart. Other than that it's perfect!

And for what I was searching at first, I guess It could be done in a pure Language like C plus, but it doesn't matter, since I've got a solution.

Thanks again to everybody.

 
...
   

Post Reply



 



Advertisement

Worth A Click