kts.AddStuff

Name

kts.AddStuff – add initial items ("stuff") to the dungeon

Synopsis

kts.AddStuff(stuff_list)

where: stuff_list is a list of {tile_category, probability, item_function} triple(s).

Description

This function adds the starting items to the dungeon. It should be called exactly once during the setup of a new game.

The function takes one parameter which is an array of "stuff entries". Each "stuff entry" is itself a "triple" of the form: {tile_category, probability, item_function}, in which:

See below for an example.

Return Value

No value is returned.

Errors

Errors may be generated if the input values do not have the expected types.

Examples

The following is a simplified example of how kts.AddStuff might be called.

function chest_item_generator()
    local choice = kts.RandomRange(1, 12)
    if choice == 1 then
        return i_poison_trap
    elseif choice == 2 then
        return i_blade_trap
    elseif choice <= 6 then
        return i_potion
    elseif choice <= 10 then
        return i_scroll
    else
        return i_dagger, kts.RandomRange(2, 4)
    end
end

function floor_item_generator()
    local choice = kts.RandomRange(1, 3)
    if choice == 1 then
        return i_axe
    elseif choice == 2 then
        return i_hammer
    else
        return i_staff
    end
end

kts.AddStuff({ {"chest", 0.8, chest_item_generator},
               {"floor", 0.1, floor_item_generator} })

The above means that each tile of category "chest" will have an 80% probability of containing an item, and if it does, then the item will be chosen by a call to the function chest_item_generator. Therefore, chests will contain a mixture of poison traps, blade traps, potions, scrolls and daggers; in the latter case, the number of daggers will be between 2 and 4. Also, each tile of category "floor" has a 10% chance of containing an item, and in this case the item will be equally likely to be an axe, hammer or staff.

In the "real" config files (in folder knights_data/server/classic) a more complicated system is used, where the probabilities depend on the "Amount of Stuff" setting in the menus.

See Also

kts.AddItem

kts.ItemType

kts.Tile