x


words for a variable definition

is there a possible way to define variables as words instead of boolean, objects, numbers, etc.

more ▼

asked Mar 03 '12 at 11:09 AM

Gamer2470 gravatar image

Gamer2470
11 1 3

Yes, it is indeed possible.

In Monodevelop or your preferred scripting program, simply type in what you would like a variable to do and the compiler will interpret this for you. For example, you could write this:

I would like my variable to increase every second frame, and to change from true to false whenever I come into contact with collider with tag "foo". Oh, and I would also love it if it could specify my object with the name "foobar" and move it to my player's transform.position. If you could do all that compiler and name my variable "bar", then I'd be super happy.

I think that should work, if not then I think the only way you can typecast is by actually typecasting per se.

Hope this helps, Klep

Mar 11 '12 at 01:07 AM Kleptomaniac
(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

Yes, you can use something called an enumeration...

i.e

public enum PowerUps { HealthPowerUp, SpeedPowerUp, JumpBooster };

if (pickupType == PowerUps.HealthPowerUp)
            health += 20;
more ▼

answered Mar 03 '12 at 11:12 AM

Meltdown gravatar image

Meltdown
5.6k 18 25 49

that is not what i ment >:|

Mar 10 '12 at 11:55 PM Gamer2470

@Gamer2470: then maybe you should be more clear when writing your question. Because right now it doesn't really make any sense.

Mar 11 '12 at 01:11 AM Eric5h5
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x344
x8

asked: Mar 03 '12 at 11:09 AM

Seen: 254 times

Last Updated: Mar 11 '12 at 01:11 AM