Pertex' Code (I was helped too with this same thing, though it was~is for my combat system coding, hehe):
(just replace the stuff as needed to match what you're doing in your game~coding)
enemy = GetObject (text)
if (enemy = null) {
foreach (obj,AllObjects()) {
if (obj.alias=text) {
enemy = obj
} else {
msg ("There seemingly is no " + text + "here.")
}
}
}
// the rest~continuation of the code, being able to use ' enemy ' now for it
as the ' GetObject (text) ' searches for the NAME while if you use an ALIAS, which is what is seen by the game player~user and not the NAME, then you'll end up with quest not finding the object, ' enemy=null ' , as the game player~user types in the ALIAS. To get around this, Pertex sets up a way to search all objects in the game, ' if (enemy=null) { foreach (obj,AllObjects()) { ' , looking to see if those objects' ALIASES match the ALIAS that the game player~user typed in, ' if (obj.alias=text) ' , and if there's a match, then that variable name~label for the GetObject (text) is set to~as that searched object who's aliases matches the ALIAS that was typed in by the game player~user, ' enemy=obj ' . If there's no match, then there's a message saying it, ' msg ("There seemingly is no " + text + "here.") ' . Also, the~this code is ready to be continued for that match and now set up variable name~label with what ever coding you want, ' // the rest~continuation of the code, being able to use ' enemy ' now for it ' .
-------
here's an example of the first part of my combat system, so you can see how you can then continue the code using that variable name~label (in my case, it is ' enemy '):
<command name="fight_command">
<pattern>fight #text#</pattern>
<script>
fight_function (game.pov,text)
</script>
</command>
<function name="fight_function" parameters="self,text">
enemy=GetObject(text)
if (enemy=null) {
foreach (obj,AllObjects()) {
if (obj.alias=text) {
enemy=obj
} else {
msg ("There seemingly is no " + text + " here.")
}
}
} else if (not check_reachable_function (enemy) = true) {
msg ("There seemingly is no " + enemy.alias + " here.")
} else if (not DoesInherit (enemy,"character_object_type")) {
msg (enemy.alias + "is seemingly not something that you can battle.")
} else if (GetBoolean (enemy,"hostile") = false) {
msg (enemy.alias + " is seemingly not something that you can battle.")
} else if (GetBoolean (enemy,"dead") = true) {
msg (enemy.alias + " is already dead.")
} else {
battle_sequence_function (self,enemy)
}
</function>
You could put your script into the COMMAND's script, I chose to put the script into a separate function, which is " called upon " (activated) by the COMMAND's script (in code, it's simple the name of the function (and its parameters), ' fight_function (game.pov,text) '. In the GUI~Editor, it is the: Add a~new script -> Scripts -> Call function