Toribash
thank you.
Oh and i tried draw_quad. It can draw horizontal and vertical lines.
Last edited by CanCan_old; Oct 24, 2007 at 03:05 PM.
You can just draw a ton of one pixel quads for diagonals, also.
Radioactive torso's description should be, "You have cancer like wow."
Can lua control/detect how much momentum?
Last edited by zzbob; Dec 20, 2007 at 08:37 PM.
local pos_x, pos_y, pos_z = 100, 100, 100

local function keypress(key)
        if(key == 274) then
            pos_z = poz_z -1
        elseif(key == 273) then
            pos_z = pos_z +1
        elseif(key == 275) then
            pos_x = pos_x +1
        elseif(key == 276) then
            pos_x = pos_x -1
        end
    end
    
local function CamMove()
    set_camera_pos (pos_x, pos_y, pos_z)
end



add_hook("key_down","FreeRoam", keypress)
add_hook("draw3D","FreeRoam", CamMove)
I think you can see what it does, well not does because it doesnt work. Halp?
Last edited by Blam; Jan 3, 2008 at 07:36 PM.
:D
I was unable to find any real explanation of what you can actually do with lua scripts elsewhere, so I guess I'll ask here:

How do they work with MP? Can you create a normal MP server/game/room which runs some particular lua script just like it runs a particular mod with particular settings? Or would the server be able to run only the mod, and each player would then have to manually run the correct lua script as well, or would even that not work?

Obviously you can do a lot of stuff with lua that you can't do with normal modding, so is there any way to create a mod+script combo that can be used in MP just as (or almost as) conveniently as a normal mod?
server side LUA has not been implemented yet.
:D
Rather, it has. It's just that the server hasn't been implemented yet.
Squad Squad Squad lead?
The standardization of Toribash Squad roles may have gone too far!
well yeah..
local Camx = 0
local Camy = 0
local Camz = 0
local CamMinusX, CamPlusX, CamMinusZ, CamPlusZ = 0,0,0,0

local function keypress(key)
        if(key == 274) then
            CamMinusZ = 1
        elseif(key == 273) then
            CamPlusZ = 1
        elseif(key == 275) then
            CamMinusX = 1
        elseif(key == 276) then
            CamPlusX = 1
        end
        
        while (CamMinusX == 1) do
            Camx = Camx -1
        end
        while (CamPlusX == 1) do
            Camx = Camx +1
        end
        while (CamMinusZ == 1) do
            Camz = Camz -1
        end
        while (CamPlusZ == 1) do
            Camz = Camz +1
        end
    end
    
local function keyrelease(key)
        if(key == 274) then
            CamMinusZ = 0
        elseif(key == 273) then
            CamPlusZ = 0
        elseif(key == 275) then
            CamMinusX = 0
        elseif(key == 276) then
            CamPlusX = 0
        end
    end

local function camera()
    set_camera_pos(Camx, Camy, Camz)
end

local function cameramove()
    set_camera_pos(Camx, Camy, Camz)
end

add_hook("key_down","FreeRoam", keypress)
add_hook("key_up","FreeRoam", keyrelease)
add_hook("draw3d","FreeRoam", camera)
add_hook("camera","FreeRoam", cameramove)
--back = 274
--forward = 273
--right = 275
--left = 276

I think it does an infinite loop and crashes TB...
Can someone tell me how to do a better "while key is down"
:D
Just don't do it like that...

Use ifs there. Whiles are just loops that stop the rest of the program until they're done. Which isn't what you want. Just have a key down and a key up so that while it's down a value is true, and when it's released it becomes false. You can use booleans, you know. (Booleans: "true" or "false")
Squad Squad Squad lead?
The standardization of Toribash Squad roles may have gone too far!
Yeah Dafe said to use if...

anyway...
I thought I would add some saving/loading functions to you know learn how to do them anyway...
how would i execute the load and save functions.


local Camx = 0
local Camy = 0
local Camz = 0
local CamMinusX, CamPlusX, CamMinusZ, CamPlusZ = 0,0,0,0

local function keypress(key)
        if(key == 274) then
            CamMinusZ = 1
        elseif(key == 273) then
            CamPlusZ = 1
        elseif(key == 275) then
            CamMinusX = 1
        elseif(key == 276) then
            CamPlusX = 1
        end
        
        if(CamMinusX == 1) then
            Camx = Camx -1
        end
        if(CamPlusX == 1) then
            Camx = Camx +1
        end
        if(CamMinusZ == 1) then
            Camz = Camz -1
        end
        if(CamPlusZ == 1) then
            Camz = Camz +1
        end
        
        if key == string.byte('X') then SavePos() end
        if key == string.byte('Z') then LoadPos() end
    end
    
function SavePos()
    echo("X: " .. Camx)
    echo("Z: " .. Camz)
    SaveSettings = io.open("Settings.cam","w")
    SaveSettings:write(Camx, "/n")
    SaveSettings:write(Camy, "/n")
    SaveSettings:write(Camz, "/n")
    echo("Saved as: " .. input)
end
function LoadPos()
    LoadSettings = io.open("Settings.cam","r")
    XX = modin:read("1")
    YY = modin:read("2")
    XX = modin:read("3")
    echo(XX.. "," .. YY .. "," .. ZZ)
    Camx = XX
    Camz = ZZ
    Camy = YY
end
    
    
local function keyrelease(key)
        if(key == 274) then
            CamMinusZ = 0
        elseif(key == 273) then
            CamPlusZ = 0
        elseif(key == 275) then
            CamMinusX = 0
        elseif(key == 276) then
            CamPlusX = 0
        end
    end

local function camera()
    set_camera_pos(Camx, Camy, Camz)
end

local function cameramove()
    return 1
end

add_hook("key_down","FreeRoam", keypress)
add_hook("key_up","FreeRoam", keyrelease)
add_hook("draw3d","FreeRoam", camera)
add_hook("camera","FreeRoam", cameramove)
--back = 274
--forward = 273
--right = 275
--left = 276
Last edited by Blam; Jan 19, 2008 at 04:47 PM.
:D