Blueprints and total elements

  • I know that blueprints costing resources will be some time off, but in the meantime if I can create something via the API then I can allow players to use BPs on MR.


    I'm thinking something like...


    sudocode:


    Code
    Item item;
    if item is of type(blueprint)
    {
        Blueprint bp = item;
        int elements = bp.getTotalElements();
    } else break;
    if (elements >= 100) event.setCancelled(true)
    else ...
  • It just so happens that the next update will provide a proper Item API in general :) This means it will distinguish between different item types (unlike the old API, which used different "Attribute" types for an item - that term was a bit confusing). So with the next update, it would look like this:


    These item subclasses will also provide specific access (e.g. to get the definition file etc). In case of blueprint items, you will be able to access various information about the blueprint (like number of construction elements it contains, creator name etc) ;)


    -----


    However, if you're working with the PlayerPlaceBlueprintEvent, you can already check the amount of elements the blueprint contains: It provides the methods "getConstructionCount()" (to get the number of construction elements in the blueprint), "getObjectCount()" (to get the number of objects like furniture) and "getPlantCount()" (the number of vegetation). If these values exceed your threshold, you can cancel the event ^^

Participate now!

Don’t have an account yet? Create a new account now and be part of our community!