1

The map.getObjectTypeAt function returns 'empty' at a robot location, why is this?

enter image description here

1

That method will return static objects I believe whereas robots are dynamic objects. "Empty" is a specific object type so it is not saying "nothing found" but "I found an object and it is of type "Empty".

I don't know of a good way to get dynamic objects at a specific place apart from by looping through all dynamic objects and checking their XY coordinates.

The getObjectTypeAt method is defined as this:

this.getObjectTypeAt = function (x, y) {
    return __grid[x][y].type;
}

The placeObject function is defined as:

this.placeObject = function (x, y, type) {
    if (!__objectDefinitions[type]) {
        throw "There is no type of object named " + type + "!";
    }

    if (typeof(__grid[x]) === 'undefined' || typeof(__grid[x][y]) === 'undefined') {
        return;
        // throw "Not a valid location to place an object!";
    }

    if (__objectDefinitions[type].type === 'dynamic') {
        // dynamic object
        __dynamicObjects.push(new DynamicObject(this, type, x, y));
    } else {
        // static object
        if (__grid[x][y].type === 'empty' || __grid[x][y].type === type || __allowOverwrite) {
            __grid[x][y].type = type;
        } else {
            throw "There is already an object at (" + x + ", " + y + ")!";
        }
    }
};

AS you can see dynamic objects aren't placed in the __grid variable which is where getObjectTypeAt looks for things so it will only pick up static objects.

  • map.getObjectTypeAt(x, y) Returns the type of the object at the given coordinates (or "empty" if there is no object there). object.type Can be "item", "dynamic", or none. If "dynamic", then this object can move on turns that run each time that the player moves. If "item", then this object can be picked up. =====> Judging by the API references here, a robot is 'dynamic'. But the allowed types are dynamic, item and none. Empty means there is no object there according to the API. – Apostle Apr 11 '14 at 15:17
  • I'm not sure where you are quoting that bit about it returning "item", "dynamic" or none but its not correct. I've edited the question to include relevant code statements. My API docs just says Returns the type of the object at the given coordinates (or "empty" if there is no object there)., none of the stuff you quoted after. – Chris Apr 11 '14 at 15:41
  • Oh, I see. You seem to be looking at the definition for object.Type which is not the same thing as is returned as the type. It is actually the same as the first parameter passed to map.defineObject. – Chris Apr 11 '14 at 15:46
  • right, thanks for the code snippet. I understand now why it doesn't return the object. it would be worth mentioning this in the API :) sorry for the confusion with the object type, i made newlines in the comment but didn't expect it all to get clumped together. – Apostle Apr 13 '14 at 20:30
  • @Apostle: No problem. I believe the place to give feedback is github.com/AlexNisnevich/untrusted/issues though in some ways working out the API is I think part of the game. Later on you will be able to view the scripts which is where I got the above code from. – Chris Apr 14 '14 at 8:21
0

But maybe you are giving the wrong location. Define collision the right way to solve this. The hint was to mess with the drone's programming.

What does the hint ask of you? To mess with the robot's programming.

You are given three spaces. At the Attack drone, re-inforcement drone and defense drone.

The defense drone will not help you. And the attack drone and re-inforcement drones will kill you.

I am going to give you a hint. Define collision for all of them, and do not let them kill the player.

I could spell it out for you. But since you reached this far...

Else I can post my solution.

  • 1
    I already found several ways to beat the level, I just didn't understand why the FindObjectAt didn't behave as I expected. Thanks for your suggestion anyway, I hadn't yet considered overwriting the collission behavior :) – Apostle Apr 13 '14 at 20:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.