|
Hi guys, I have a few doors and few keys to open specific doors. what I am trying to do is to create a function so that i can reuse them. The problem that i encounter is converting a series of string to boolean. Can't use parseBoolean(); Don't even know that it is the correct way to do it or is there a better way? Please assist and thanks in advance!
Rdgs, James Ser
(comments are locked)
|
|
you should use bool.Parse to convert a string to it's logical boolean representation. This may be a better link for it: http://msdn.microsoft.com/en-us/library/system.boolean.parse.aspx
Jun 01 '10 at 02:34 AM
Cyclops
Thanks for your suggestion. But it doesn't work. It says unknown identifier: 'bool'
Jun 01 '10 at 02:51 AM
James Ser
in C# the class name is bool. in js you might need to use another name like boolean. i don't know. i can create a C# class that exposes this method for you. tell me if you need and i'll edit the answer.
Jun 01 '10 at 09:01 AM
Ashkan_gc
bool.Parse passes user input of true or false to a bool. What jamesser asks is to have a series of bool , like doorIsOpenFloor01 = false, doorIsOpenFloor02 =false, and a var currentfloor: int ...etc and in your script to call them as "if so and so doorIsOpen0(currentFloor) = false
Aug 13 '10 at 03:37 PM
alexnode
In UnityScript (javascript) it's boolean.Parse() like Ashkan thought for anyone reading this later.
May 04 '11 at 11:25 PM
NewfieJoe
(comments are locked)
|
|
You can create a hashtable and store the values in it then read it from there if you absolutely need to reference them this way. Easier would be to use boolean arrays. The key is that if you have 8 doors, you need to declare 8 booleans for isOpen and 8 bools for accessGranted. The only good way to do that is with arrays.
May 05 '11 at 02:14 AM
Owen Reynolds
Yeah, that's why I thought they'd be best. You could have hundreds and it will be fine.
May 05 '11 at 05:18 AM
NewfieJoe
(comments are locked)
|

i was thinking about the same thing, it can be really handy really.