Skip to content

builtin model

boyism80 edited this page Jun 19, 2025 · 15 revisions

Built-in Functions Documentation (Model)

This document describes functions available to various model type objects.

fb.model.spell

type

type()

  • Description:
    Returns the type of the spell.
  • Parameters:
    • None
  • Return Value:
    • number: Spell type value
  • Example:
    -- This is a real usage example from game scripts
    local spell_model = name2spell("비영사천문")
    local spell_type = spell_model:type()
    me:message("Spell type: " .. spell_type)

name

name()

  • Description:
    Returns the name of the spell.
  • Parameters:
    • None
  • Return Value:
    • string: Spell name
  • Example:
    -- This is a real usage example from game scripts
    local spell_model = name2spell("비영사천문")
    local spell_name = spell_model:name()
    me:message("Spell name: " .. spell_name)

message

message()

  • Description:
    Returns the message associated with the spell.
  • Parameters:
    • None
  • Return Value:
    • string: Spell message
  • Example:
    -- This is a real usage example from game scripts
    local spell_model = name2spell("비영사천문")
    local spell_message = spell_model:message()
    me:message("Spell message: " .. spell_message)

fb.model.map

id

id()

  • Description:
    Returns the unique ID of the map.
  • Parameters:
    • None
  • Return Value:
    • number: Map ID
  • Example:
    -- This is a real usage example from game scripts
    local map_model = me:map():model()
    local map_id = map_model:id()
    me:message("Map ID: " .. map_id)

name

name()

  • Description:
    Returns the name of the map.
  • Parameters:
    • None
  • Return Value:
    • string: Map name
  • Example:
    -- This is a real usage example from game scripts
    local map_model = me:map():model()
    local map_name = map_model:name()
    me:message("Map name: " .. map_name)

root

root()

  • Description:
    Returns the root position of the map.
  • Parameters:
    • None
  • Return Value:
    • table: Root position coordinates
  • Example:
    -- This is a real usage example from game scripts
    local map_model = me:map():model()
    local root_pos = map_model:root()
    me:message("Root position: " .. root_pos.x .. ", " .. root_pos.y)

cardinal

cardinal()

  • Description:
    Returns the cardinal direction information of the map.
  • Parameters:
    • None
  • Return Value:
    • number: Cardinal direction value
  • Example:
    -- This is a real usage example from game scripts
    local map_model = me:map():model()
    local cardinal = map_model:cardinal()
    me:message("Cardinal: " .. cardinal)

revive

revive()

  • Description:
    Returns the revive position for the map.
  • Parameters:
    • None
  • Return Value:
    • table: Revive position coordinates
  • Example:
    -- This is a real usage example from game scripts
    local map_model = me:map():model()
    local revive_pos = map_model:revive()
    me:message("Revive position: " .. revive_pos.x .. ", " .. revive_pos.y)

option

option()

  • Description:
    Returns the option flags for the map.
  • Parameters:
    • None
  • Return Value:
    • number: Map option flags
  • Example:
    -- This is a real usage example from game scripts
    local map_model = me:map():model()
    local option = map_model:option()
    local pk_enabled = (option & MAP_OPTION.ENABLE_PK) == MAP_OPTION.ENABLE_PK
    me:message("PK enabled: " .. tostring(pk_enabled))

fb.model.object

name

name()

  • Description:
    Returns the name of the object.
  • Parameters:
    • None
  • Return Value:
    • string: Object name
  • Example:
    -- This is a real usage example from game scripts
    local obj_model = me:model()
    local obj_name = obj_model:name()
    me:message("Object name: " .. obj_name)

look

look()

  • Description:
    Returns the look/appearance ID of the object.
  • Parameters:
    • None
  • Return Value:
    • number: Look ID
  • Example:
    -- This is a real usage example from game scripts
    local obj_model = me:model()
    local look_id = obj_model:look()
    me:message("Object look: " .. look_id)

color

color()

  • Description:
    Returns the color value of the object.
  • Parameters:
    • None
  • Return Value:
    • number: Color value
  • Example:
    -- This is a real usage example from game scripts
    local obj_model = me:model()
    local color_val = obj_model:color()
    me:message("Object color: " .. color_val)

fb.model.mob

speed

speed()

  • Description:
    Returns the movement speed of the mob.
  • Parameters:
    • None
  • Return Value:
    • number: Movement speed
  • Example:
    -- This is a real usage example from game scripts
    local mob_model = name2mob("다람쥐")
    local mob_speed = mob_model:speed()
    me:message("Mob speed: " .. mob_speed)

size

size()

  • Description:
    Returns the size of the mob.
  • Parameters:
    • None
  • Return Value:
    • number: Mob size
  • Example:
    -- This is a real usage example from game scripts
    local mob_model = name2mob("다람쥐")
    local mob_size = mob_model:size()
    me:message("Mob size: " .. mob_size)

damage

damage()

  • Description:
    Returns the damage range of the mob.
  • Parameters:
    • None
  • Return Value:
    • number, number: Minimum and maximum damage
  • Example:
    -- This is a real usage example from game scripts
    local mob_model = name2mob("다람쥐")
    local min_dmg, max_dmg = mob_model:damage()
    me:message("Mob damage: " .. min_dmg .. "-" .. max_dmg)

drop

drop()

  • Description:
    Returns the drop table for the mob.
  • Parameters:
    • None
  • Return Value:
    • table: Drop information table
  • Example:
    -- This is a real usage example from game scripts
    local mob_model = name2mob("다람쥐")
    local drop_table = mob_model:drop()
    for _, drop_item in pairs(drop_table) do
        me:message("Drops: " .. drop_item.name)
    end

fb.model.npc

sell

sell()

  • Description:
    Returns the list of items that the NPC sells.
  • Parameters:
    • None
  • Return Value:
    • table: Table of sellable items
  • Example:
    -- This is a real usage example from game scripts
    local npc_model = name2npc("낙랑")
    for _, sell_item in pairs(npc_model:sell()) do
        me:message("NPC sells: " .. sell_item.name)
    end

sell_price

sell_price(item_name:string)

  • Description:
    Returns the selling price of a specific item.
  • Parameters:
    • item_name:string: Name of the item
  • Return Value:
    • number|nil: Selling price or nil if not sold
  • Example:
    -- This is a real usage example from game scripts
    local npc_model = name2npc("낙랑")
    local price = npc_model:sell_price("도토리")
    if price then
        me:message("Sell price: " .. price)
    end

buy

buy()

  • Description:
    Returns the list of items that the NPC buys.
  • Parameters:
    • None
  • Return Value:
    • table: Table of buyable items
  • Example:
    -- This is a real usage example from game scripts
    local npc_model = name2npc("낙랑")
    for _, buy_item in pairs(npc_model:buy()) do
        me:message("NPC buys: " .. buy_item.name)
    end

buy_price

buy_price(item_name:string)

  • Description:
    Returns the buying price of a specific item.
  • Parameters:
    • item_name:string: Name of the item
  • Return Value:
    • number|nil: Buying price or nil if not bought
  • Example:
    -- This is a real usage example from game scripts
    local npc_model = name2npc("낙랑")
    local price = npc_model:buy_price("도토리")
    if price then
        me:message("Buy price: " .. price)
    end

fb.model.life

hp

hp()

  • Description:
    Returns the base HP of the life model.
  • Parameters:
    • None
  • Return Value:
    • number: Base HP value
  • Example:
    -- This is a real usage example from game scripts
    local life_model = me:model()
    local base_hp = life_model:hp()
    me:message("Base HP: " .. base_hp)

mp

mp()

  • Description:
    Returns the base MP of the life model.
  • Parameters:
    • None
  • Return Value:
    • number: Base MP value
  • Example:
    -- This is a real usage example from game scripts
    local life_model = me:model()
    local base_mp = life_model:mp()
    me:message("Base MP: " .. base_mp)

fb.model.item

make

make()

  • Description:
    Returns the crafting requirements for the item.
  • Parameters:
    • None
  • Return Value:
    • table: Crafting requirements table
  • Example:
    -- This is a real usage example from game scripts
    local item_model = name2item("목검")
    local make_info = item_model:make()
    for _, requirement in pairs(make_info) do
        me:message("Requires: " .. requirement.name .. " x" .. requirement.count)
    end

attr

attr(attribute:number)

  • Description:
    Checks if the item has a specific attribute.
  • Parameters:
    • attribute:number: Attribute flag to check
  • Return Value:
    • boolean: True if item has the attribute, false otherwise
  • Example:
    -- This is a real usage example from game scripts
    local item_model = name2item("목검")
    if item_model:attr(ITEM_ATTRIBUTE.WEAPON) then
        me:message("This is a weapon")
    end

capacity

capacity()

  • Description:
    Returns the capacity/stack size of the item.
  • Parameters:
    • None
  • Return Value:
    • number: Item capacity
  • Example:
    -- This is a real usage example from game scripts
    local item_model = name2item("도토리")
    local capacity = item_model:capacity()
    me:message("Item capacity: " .. capacity)

durability

durability()

  • Description:
    Returns the maximum durability of the item.
  • Parameters:
    • None
  • Return Value:
    • number: Maximum durability
  • Example:
    -- This is a real usage example from game scripts
    local item_model = name2item("목검")
    local max_durability = item_model:durability()
    me:message("Max durability: " .. max_durability)

price

price()

  • Description:
    Returns the base price of the item.
  • Parameters:
    • None
  • Return Value:
    • number: Item price
  • Example:
    -- This is a real usage example from game scripts
    local item_model = name2item("도토리")
    local item_price = item_model:price()
    me:message("Item price: " .. item_price)

repair_price

repair_price()

  • Description:
    Returns the repair cost of the item.
  • Parameters:
    • None
  • Return Value:
    • number: Repair price
  • Example:
    -- This is a real usage example from game scripts
    local item_model = name2item("목검")
    local repair_cost = item_model:repair_price()
    me:message("Repair cost: " .. repair_cost)

rename_price

rename_price()

  • Description:
    Returns the cost to rename the item.
  • Parameters:
    • None
  • Return Value:
    • number: Rename price
  • Example:
    -- This is a real usage example from game scripts
    local item_model = name2item("목검")
    local rename_cost = item_model:rename_price()
    me:message("Rename cost: " .. rename_cost)

storage_fee

storage_fee()

  • Description:
    Returns the storage fee for the item.
  • Parameters:
    • None
  • Return Value:
    • number: Storage fee
  • Example:
    -- This is a real usage example from game scripts
    local item_model = name2item("목검")
    local storage_fee = item_model:storage_fee()
    me:message("Storage fee: " .. storage_fee)

fb.model.weapon

damage_small

damage_small()

  • Description:
    Returns the damage against small targets.
  • Parameters:
    • None
  • Return Value:
    • number, number: Minimum and maximum damage against small targets
  • Example:
    -- This is a real usage example from game scripts
    local weapon_model = name2item("목검")
    local min_dmg, max_dmg = weapon_model:damage_small()
    me:message("Small damage: " .. min_dmg .. "-" .. max_dmg)

damage_large

damage_large()

  • Description:
    Returns the damage against large targets.
  • Parameters:
    • None
  • Return Value:
    • number, number: Minimum and maximum damage against large targets
  • Example:
    -- This is a real usage example from game scripts
    local weapon_model = name2item("목검")
    local min_dmg, max_dmg = weapon_model:damage_large()
    me:message("Large damage: " .. min_dmg .. "-" .. max_dmg)

sound

sound()

  • Description:
    Returns the sound effect ID for the weapon.
  • Parameters:
    • None
  • Return Value:
    • number: Sound effect ID
  • Example:
    -- This is a real usage example from game scripts
    local weapon_model = me:weapon():model()
    local weapon_sound = weapon_model:sound()
    me:sound(weapon_sound)

type

type()

  • Description:
    Returns the weapon type.
  • Parameters:
    • None
  • Return Value:
    • number: Weapon type value
  • Example:
    -- This is a real usage example from game scripts
    local weapon_model = me:weapon():model()
    local weapon_type = weapon_model:type()
    local is_bow = (weapon_type == WEAPON_TYPE_BOW)
    me:message("Is bow: " .. tostring(is_bow))

fb.model.achievement

id

id()

  • Description:
    Returns the unique ID of the achievement.
  • Parameters:
    • None
  • Return Value:
    • number: Achievement ID
  • Example:
    -- This is a real usage example from game scripts
    local achievement_model = me:achievement('첫번째업적'):model()
    local achievement_id = achievement_model:id()
    me:message("Achievement ID: " .. achievement_id)

look

look()

  • Description:
    Returns the look/appearance ID of the achievement.
  • Parameters:
    • None
  • Return Value:
    • number: Look ID
  • Example:
    -- This is a real usage example from game scripts
    local achievement_model = me:achievement('첫번째업적'):model()
    local look_id = achievement_model:look()
    me:message("Achievement look: " .. look_id)

color

color()

  • Description:
    Returns the color value of the achievement.
  • Parameters:
    • None
  • Return Value:
    • number: Color value
  • Example:
    -- This is a real usage example from game scripts
    local achievement_model = me:achievement('첫번째업적'):model()
    local color_val = achievement_model:color()
    me:message("Achievement color: " .. color_val)

text

text()

  • Description:
    Returns the description text of the achievement.
  • Parameters:
    • None
  • Return Value:
    • string: Achievement description
  • Example:
    -- This is a real usage example from game scripts
    local achievement_model = me:achievement('첫번째업적'):model()
    local achievement_text = achievement_model:text()
    me:message("Achievement: " .. achievement_text)

Clone this wiki locally