AINE: Accelerated Interactive Narrator Engine
  • Download
  • References
  • Games
  • Wiki
  • Facebook Twitter
  • Name

    foreach

  • Examples

    Object: allItems
    {
    items: [item1, item2, item3, item4]
    }

    Item: item1
    Item: item2
    Item: item3
    Item: item4

    Player: {

    Event: "Give Item" {
    // Loops through all items in the items list of allItems
    // If the player does not have the current item in the loop,
    // gives the item to the player, and breaks the loop,
    // so the player is only given one item instead of all

    foreach(Item in allItems.items as item){
    if (!hasItem(item)){
    giveItem(item)
    break;
    }
    }
    }
    }
  • Description

    Loops through all entries in a list. If an object type is specified for the foreach it will ignore all entries not of that type. This can be used to avoid errors when using object specific methods of entries, or when searching for a specific object type in a list.

    The identifier is used in calling to the current entry in the loop.
  • Syntax

    • foreach(List as identifier){}
    • foreach(Object in List as identifier){}
  • Related

    • break

    • for

    • while

  • Contact
  • Terms of Use
  • GitHub
  • Drakkashi.com

The copyright of all images rendered by me goes to their respective owners.
© 2008 Daniel Svejstrup Christensen