(12-20-2012, 08:29 PM)dnalange Wrote: PS... is it possible to have 2 controlpanels in map?
Trying but not working here... hmmmsssss
If not possible i will do somethng else { alrdy build an alternative tho }
It is possible, for both my and
Apjjm's code, but you have to be careful when making the modifications.
Actually, if the pass-code functionality was implemented using
a class, (what most people here refer to as "object stuff"), it would be fairly easy to have as many control panels as you'd like.
However, although the script engine supports this to some extent, classes and object-oriented programing are somewhat more advanced concepts, so without going down that road, you would have to
duplicate certain functions in the script file (although this can maybe be avoided to a degree by using some if-statements), and then make some changes to the duplicated code (to match the new set of script areas / entities).
This approach is tedious and error prone (and duplicating code is not a good practice), but it can be done if you're careful. You'd have to know exactly what functions need to be copied, and where exactly the tweaks need to be made - so you must, at least on a basic level, understand
how the script does what it does.
In my script, for example, you would make an additional version of OnButtonPress(), OnAccept(), OnCancel() and ResetUserCodeVars() functions (of course, they cannot have the exact same names as the originals), you'd need a second set of the userEntry, numPresses and secret pass code variables. You would also need to make modifications to OnEnter() function (to hook up the second control panel), as well as to the GetDigitFromButton() function (to make it work with the second control panel).
This can potentially result in a huge mess, so if you decide to try it, take it slow, and one step at a time.