Ranking
Original Post
Shouldn't this work?
font_type = FONTS.SMALL

function mytestmess(str, pos)
    draw_centered_text(str, pos, font_type)
end

add_hook ("new_game", "test", mytestmess("Kool-Aid man says: Oooh Yeah!", 100))
add_hook ("joint_select", "test", mytestmess("You like selecting joints?", 100))
add_hook ("enter_frame", "test", mytestmess("Next frame, please!", 100))
Shouldn't the above code work? I don't get any errors, but no text appears. Also, I can't find the stderr.txt anywhere...
add_hook() takes three arguments. You can find it in startup.lua in your scripts directory.

The third argument is a function reference, and you're passing it nil, because mytestmess() doesn't return anything.

If you want, you can use a function literal like:
add_hook ("new_game", "test", function() mytestmess("Kool-Aid man says: Oooh Yeah!", 100) end )
Radioactive torso's description should be, "You have cancer like wow."
The 'stderr.txt' should appear on the Toribash main folder.
Use 'echo' for debugging, as in

function mytestmess(str, pos)
    draw_centered_text(str, pos, font_type)
    echo(str)
    echo(pos)
    echo(font_type)
end
I don't know about the draw_centered_text function.
You might have to set the text color beforehand, i.e.
set_color(0,0,0,1)
before calling your function.

Good Luck
Stderr.txt still doesn't show up: Also, the echo's return the correct information (or so I think), it just looks like draw_centered_text isn't working...
you can only draw stuff in a draw2d hook.
:D
If so, then the solution could be the run_cmd and "cp" commands, ins't it?
function display(str)
    run_cmd("cp "..str)
end
Warning: i can't check if it works at the present time, so IDK if the sintax is ok.
center print != draw_centered_text
Works:
Message = ""
Pos = 0
Colour = {r = 0, g = 0, b = 0, a = 1}
font_type = FONTS.SMALL

function mytestmess(str, pos,r,g,b)
    Message = str
    Pos = pos
    Colour.r = r
    Colour.g = g
    Colour.b = b
end

function draw2d()
    if(Message ~= "") then
        set_color(Colour.r,Colour.g,Colour.b,Colour.a)
        draw_centered_text(Message, Pos, font_type)
    end
end

add_hook("draw2d","moo",draw2d)
add_hook ("new_game", "test", function() mytestmess("Kool-Aid man says: Oooh Yeah!", 100,1,0,0)end)
add_hook ("joint_select", "test", function() mytestmess("You like selecting joints?", 100,0,1,0)end)
add_hook ("enter_frame", "test", function() mytestmess("Next frame, please!", 100,0,0,1)end)
Last edited by Blam; Aug 30, 2008 at 11:44 AM.
:D