Dynamic Object Names
Tonyhapprox
19 Nov 2013, 11:25Ok can anyone suggest a way for me to create dynamic object names.
Hypothetically say I want 100 rooms each with a safe and I want a function called OpenSafe to which I send as a parameter the room number and which allows me to set safe#room number#.locked=false (where #room number# is whatever one was sent as parameter).
Is that possible?
I've got a vague idea that there is an 'off-wiki' function called objectproperty that uses dynamic object names but I'm unsure it would solve this or not...
Any expert advice much appreciated.
Hypothetically say I want 100 rooms each with a safe and I want a function called OpenSafe to which I send as a parameter the room number and which allows me to set safe#room number#.locked=false (where #room number# is whatever one was sent as parameter).
Is that possible?
I've got a vague idea that there is an 'off-wiki' function called objectproperty that uses dynamic object names but I'm unsure it would solve this or not...
Any expert advice much appreciated.
The Pixie
19 Nov 2013, 11:37I would set it up so each room is room_1, room_2, etc., and each safe is safe_1, safe_2, etc. (in fact I would create a start script to generate the rooms).
Say room_no is the number of the room sent to the function, you can grab the safe object using the GetObject function, then do what you like with it.
Say room_no is the number of the room sent to the function, you can grab the safe object using the GetObject function, then do what you like with it.
safe = GetObject ("safe_" + room_no)
safe.locked = false
Tonyhapprox
19 Nov 2013, 14:08Thanks Pixie - you've solved my problem. Much appreciated.