File: preload.lua

package info (click to toggle)
cataclysm-dda 0.C%2Bgit20190228.faafa3a-2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 181,636 kB
  • sloc: cpp: 256,609; python: 2,621; makefile: 862; sh: 495; perl: 37; xml: 33
file content (27 lines) | stat: -rw-r--r-- 794 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
function message(...)
    local s = string.format(...)
    game.add_msg(s)
end

function iuse_test_bionics_list()
    local num = player:num_bionics()
    if num == 0 then
        message("You installed no bionics.")
    else
        local i = 0
        while i < num do
            -- Get bionic reference
            local bio = player:bionic_at_index(i)
            -- Get bionic_data reference (use obj() function of bionic_id class)
            local bio_data = bio.id:obj()
            local color = "white"
            if bio_data.activated then
                color = "green"
            end
            message("bionics[%d]: <color_%s>%s</color>", i, color, bio_data.name)
            i = i + 1
        end
    end
end

game.register_iuse("TEST_BIONICS_LIST", iuse_test_bionics_list)