builtin context - boyism80/fb GitHub Wiki

Built-in Functions Documentation (Context)

This document describes global context functions available in the game environment.


seed

seed()

  • Description:
    Generates a random seed value for use in random number generation.
  • Parameters:
    • None
  • Return Value:
    • number: Random seed value
  • Example:
    -- This is a real usage example from game scripts
    local random_seed = seed()
    

sleep

sleep(milliseconds:number)

  • Description:
    Pauses script execution for the specified number of milliseconds.
  • Parameters:
    • milliseconds:number: Time to sleep in milliseconds
  • Return Value:
    • None
  • Example:
    -- This is a real usage example from game scripts
    sleep(1000)  -- Wait 1 second
    me:message("One second has passed")
    

name2mob

name2mob(name:string)

  • Description:
    Gets a mob model by name.
  • Parameters:
    • name:string: Name of the mob
  • Return Value:
    • fb.model.mob|nil: Mob model object or nil if not found
  • Example:
    -- This is a real usage example from game scripts
    local mob_model = name2mob("λ‹€λžŒμ₯")
    if mob_model then
        me:message("Found mob: " .. mob_model:name())
    end
    

name2spell

name2spell(name:string)

  • Description:
    Gets a spell model by name.
  • Parameters:
    • name:string: Name of the spell
  • Return Value:
    • fb.model.spell|nil: Spell model object or nil if not found
  • Example:
    -- This is a real usage example from game scripts
    local spell_model = name2spell("λΉ„μ˜μ‚¬μ²œλ¬Έ")
    if spell_model then
        me:message("Found spell: " .. spell_model:name())
    end
    

name2npc

name2npc(name:string)

  • Description:
    Gets an NPC model by name.
  • Parameters:
    • name:string: Name of the NPC
  • Return Value:
    • fb.model.npc|nil: NPC model object or nil if not found
  • Example:
    -- This is a real usage example from game scripts
    local npc_model = name2npc("λ‚™λž‘")
    if npc_model then
        me:message("Found NPC: " .. npc_model:name())
    end
    

name2map

name2map(name:string)

  • Description:
    Gets a map object by name.
  • Parameters:
    • name:string: Name of the map
  • Return Value:
    • fb.game.map|nil: Map object or nil if not found
  • Example:
    -- This is a real usage example from game scripts
    local target_map = name2map("κ΅­λ‚΄μ„±")
    if target_map then
        me:message("Found map: " .. target_map:model():name())
    end
    

name2ch

name2ch(name:string)

  • Description:
    Gets a character object by name.
  • Parameters:
    • name:string: Name of the character
  • Return Value:
    • fb.game.character|nil: Character object or nil if not found
  • Example:
    -- This is a real usage example from game scripts
    local target_char = name2ch("운영자")
    if target_char then
        me:message("Found character: " .. target_char:name())
    end
    

name2item

name2item(name:string)

  • Description:
    Gets an item model by name.
  • Parameters:
    • name:string: Name of the item
  • Return Value:
    • fb.model.item|nil: Item model object or nil if not found
  • Example:
    -- This is a real usage example from game scripts
    local item_model = name2item("도토리")
    if item_model then
        me:message("Found item: " .. item_model:name())
    end
    

pursuit_sell

pursuit_sell(pursuit_id:number)

  • Description:
    Gets the list of items that can be sold for a specific pursuit/profession.
  • Parameters:
    • pursuit_id:number: Pursuit/profession ID (nil for all)
  • Return Value:
    • table: Table containing sellable items for the pursuit
  • Example:
    -- This is a real usage example from game scripts
    for _, pair in pairs(pursuit_sell(sell)) do
        me:message("Can sell: " .. pair.name)
    end
    

pursuit_buy

pursuit_buy(pursuit_id:number)

  • Description:
    Gets the list of items that can be bought for a specific pursuit/profession.
  • Parameters:
    • pursuit_id:number: Pursuit/profession ID (nil for all)
  • Return Value:
    • table: Table containing buyable items for the pursuit
  • Example:
    -- This is a real usage example from game scripts
    for _, pair in pairs(pursuit_buy(npc:model():buy())) do
        me:message("Can buy: " .. pair.name)
    end
    

sell

sell(item_name:string)

  • Description:
    Gets selling information for a specific item.
  • Parameters:
    • item_name:string: Name of the item
  • Return Value:
    • table|nil: Selling information or nil if not sellable
  • Example:
    -- This is a real usage example from game scripts
    local sell_info = sell("도토리")
    if sell_info then
        me:message("Sell price: " .. sell_info.price)
    end
    

buy

buy(item_name:string)

  • Description:
    Gets buying information for a specific item.
  • Parameters:
    • item_name:string: Name of the item
  • Return Value:
    • table|nil: Buying information or nil if not buyable
  • Example:
    -- This is a real usage example from game scripts
    local buy_info = buy("도토리")
    if buy_info then
        me:message("Buy price: " .. buy_info.price)
    end
    

spell2model

spell2model(spell_name:string)

  • Description:
    Converts a spell name to its model object (alias for name2spell).
  • Parameters:
    • spell_name:string: Name of the spell
  • Return Value:
    • fb.model.spell|nil: Spell model object or nil if not found
  • Example:
    -- This is a real usage example from game scripts
    local spell_model = spell2model("λΉ„μ˜μ‚¬μ²œλ¬Έ")
    if spell_model then
        me:message("Spell model: " .. spell_model:name())
    end
    

item2model

item2model(item_name:string)

  • Description:
    Converts an item name to its model object (alias for name2item).
  • Parameters:
    • item_name:string: Name of the item
  • Return Value:
    • fb.model.item|nil: Item model object or nil if not found
  • Example:
    -- This is a real usage example from game scripts
    local item_model = item2model("도토리")
    if item_model then
        me:message("Item model: " .. item_model:name())
    end
    

mob2model

mob2model(mob_name:string)

  • Description:
    Converts a mob name to its model object (alias for name2mob).
  • Parameters:
    • mob_name:string: Name of the mob
  • Return Value:
    • fb.model.mob|nil: Mob model object or nil if not found
  • Example:
    -- This is a real usage example from game scripts
    local mob_model = mob2model("λ‹€λžŒμ₯")
    if mob_model then
        me:message("Mob model: " .. mob_model:name())
    end
    

npc2model

npc2model(npc_name:string)

  • Description:
    Converts an NPC name to its model object (alias for name2npc).
  • Parameters:
    • npc_name:string: Name of the NPC
  • Return Value:
    • fb.model.npc|nil: NPC model object or nil if not found
  • Example:
    -- This is a real usage example from game scripts
    local npc_model = npc2model("λ‚™λž‘")
    if npc_model then
        me:message("NPC model: " .. npc_model:name())
    end
    

map2model

map2model(map_name:string)

  • Description:
    Converts a map name to its model object.
  • Parameters:
    • map_name:string: Name of the map
  • Return Value:
    • fb.model.map|nil: Map model object or nil if not found
  • Example:
    -- This is a real usage example from game scripts
    local map_model = map2model("κ΅­λ‚΄μ„±")
    if map_model then
        me:message("Map model: " .. map_model:name())
    end
    

broadcast

broadcast(message:string, message_type:number, broadcast_type:number)

  • Description:
    Broadcasts a message to all players or specific groups.
  • Parameters:
    • message:string: Message to broadcast
    • message_type:number: Message type (MESSAGE_TYPE enum)
    • broadcast_type:number: Broadcast scope (BROADCAST_TYPE enum)
  • Return Value:
    • None
  • Example:
    -- This is a real usage example from game scripts
    broadcast("Server maintenance in 10 minutes", MESSAGE_TYPE_NOTICE, BROADCAST_TYPE_ALL)