GetInput to create & name a new object?
sparksjay
21 Aug 2019, 07:23What string/expression do I use to manipulate the newly created and user-named object?
mrangel
21 Aug 2019, 07:37If you're using a user-supplied string as an object name, you'd probably want something like:
get input {
if (GetObject(result) = null) {
create (result)
obj = GetObject (result)
if (obj = null) {
msg ("Not a valid object name")
}
else {
// code here to do stuff with 'obj'
}
}
else {
msg ("There's already an object with that name.")
}
}
However, I can't see any case in which letting the player name an object is a good idea. Normally you'd pick a name for an object that you can use in the code, and let the player pick an alias.
sparksjay
21 Aug 2019, 07:50That's a really valid point, and I hadn't considered the ramifications of that. Thanks.
Very new and diving in over my head, but loving it so far. Thank you for the quick response.
hegemonkhan
22 Aug 2019, 01:23like mrangel said:
use the built-in 'alias' String Attribute for the in-game name of an Object (that's what it's there for, has the coding system already built-in for it to work properly for you too), while you set/input the actual names of the Objects for your own/code use (you really should never let the user name their own Objects, for reducing error and exception handling, and also for security/corruption-of-code-prevention)
Possibly, one reason, is if you want a 'crafting' system, with the user being able to input/choose/select their own custom name (again,via the built-in 'alias' String Attribute) for the Object that they 'craft' (create)