Then in the script, you can query the "text" argument to see what they typed
<command name="drag_command">
<pattern>drag #text1# to #text2#</pattern>
<script>
drag_function (text1,text2)
</script>
</command>
<function name="drag_function" parameters="text1,text2">
drag_target_object = GetObject (text1)
drag_target_destination_room = GetObject (text2)
if (drag_target_object = null) {
foreach (obj1,GetAllChildObjects(game.pov.parent)) {
if (obj1.alias=text1) {
drag_target_object = obj1
} else {
msg ("There seemingly is no " + text1 + " in the vicinity.")
}
}
}
if (drag_target_destination_room = null) {
foreach (obj2,AllObjects()) {
if (obj2.alias=text2) {
drag_target_destination_room = obj2
} else {
msg (text2 + "seemingly doesn't exist.")
}
}
}
if (not drag_target_object.dragable) {
msg ("You can't drag " + drag_target_object + ", as it's too big and heavy!")
} else if (not drag_target_destination_room.dragable) {
msg ("You can't drag " + drag_target_object + ", as it can't fit in the " + drag_target_destination_room +"!")
} else if (not drag_target_destination_room.visited) {
msg ("You seemingly can't drag " + drag_target_object + " to " + drag_target_destination_room +".")
} else if (not drag_target_object, "ScopeReachable") {
msg ("There seemingly is no " + drag_target_object + " in the vicinity.")
} else {
msg ("You drag " + drag_target_object + " to " + drag_target_destination_room +".")
game.pov.parent = drag_target_destination_room
drag_target_object.parent = drag_target_destination_room
}
</function>jaynabonne wrote:I don't think using an object for the room will work, because the room will not be visible in *this* room, and so it won't be found.
<command name="drag">
<pattern>drag #objecttodrag# to #objectdestination#</pattern>
<script>
if (HasAttribute(objecttodrag, "draggable")) {
msg ("Can be dragged")
if (HasAttribute(objectdestination, "canbedraggedto")) {
msg ("Can be dragged to this location")
MoveObject (player, Study)
MoveObject (objecttodrag, Study)
}
else {
msg ("Cannot be dragged to this location")
}
}
else {
msg ("Cannot be dragged")
}
</script>
</command>
And Studydummy has an attribute called "canbedraggedto", whereas Bathroomdummy does not.
And Box has an attribute called "draggable", whereas Wall does not.It does seem to work although I had to hardwire in the name "Study" in the MoveObject code because what I wanted to do was put in a Switch/Case to move to different options based on objectdestination
<object name="ShadowStudy">
<alias>study</alias>
<realroom type="object">Study</realroom>
</object>realroom = objectdestination.realroom
MoveObject (player, realroom)
MoveObject (objecttodrag, realroom)
HegemonKhan wrote:a quick mistake that I think exists (lol as in I'm not sure if it's wrong on not) in your code....
either:
change HasAttribute to GetAttribute
~OR~
use: if (HasAttribute (the_object,"it's_attribute") = true) {
IF HasAttribute: needs to be set = to true/false, and if it matches your setup, then it continues ~it does the additional nested script
IF GetAttribute: simply checks if you've got the attribute or not (if you do, then it continues ~ it does the additional nested script)
HK wrote:msg ("You drag " + drag_target_object + " to " + drag_target_destination_room +".")
msg ("You drag " + GetDisplayAlias(drag_target_object) + " to " + GetDisplayAlias(drag_target_destination_room) +".")