people playing: 37, servers online: 11, games played: 136,473,827 Top Player: noca

  Toribash Community » Toribash » Mods » Lua scripts
Register FAQ General Rules Community
Reply
 
Thread Tools Display Modes
Old Oct 24, 2007   #11
CanCan
Junior Member
 
White Belt
Join Date: Oct 2007



thank you.
Oh and i tried draw_quad. It can draw horizontal and vertical lines.

Last edited by CanCan; Oct 24, 2007 at 02:05 PM..
CanCan is offline   Reply With Quote
Old Oct 24, 2007   #12
Dafe
Serious Business
 
4th Dan Black Belt
Join Date: Jul 2006
Posts: 618
Clan: bncy



You can just draw a ton of one pixel quads for diagonals, also.
Radioactive torso's description should be, "You have cancer like wow."
Dafe is offline   Reply With Quote
Old Dec 20, 2007   #13
zzbob
Member
 
Brown Belt
Join Date: Dec 2007
Posts: 65



Can lua control/detect how much momentum?

Last edited by zzbob; Dec 20, 2007 at 07:37 PM..
zzbob is offline   Reply With Quote
Old Jan 2, 2008   #14
Blam
Now I know my abc's!
This user title is the property of SkulFuk.
 
4th Dan Black Belt
Join Date: Apr 2007
Posts: 5,507
Clan: bncy



Code:
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?
:D

Last edited by Blam; Jan 3, 2008 at 06:36 PM..
Blam is offline   Reply With Quote
Old Jan 17, 2008   #15
zookeeper
Member
 
3rd Dan Black Belt
Join Date: Oct 2007
Posts: 34



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?
zookeeper is offline   Reply With Quote
Old Jan 17, 2008   #16
Blam
Now I know my abc's!
This user title is the property of SkulFuk.
 
4th Dan Black Belt
Join Date: Apr 2007
Posts: 5,507
Clan: bncy



server side LUA has not been implemented yet.
:D
Blam is offline   Reply With Quote
Old Jan 18, 2008   #17
+suomynona
IRCIRCIRCIRCIRCIRCIRCIRCIRCIRC
 
Not a Belt
Join Date: Jan 2007
Posts: 5,736
Clan: spirit



Rather, it has. It's just that the server hasn't been implemented yet.
suomynona is offline   Reply With Quote
Old Jan 19, 2008   #18
Blam
Now I know my abc's!
This user title is the property of SkulFuk.
 
4th Dan Black Belt
Join Date: Apr 2007
Posts: 5,507
Clan: bncy



well yeah..
Code:
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
Blam is offline   Reply With Quote
Old Jan 19, 2008   #19
+suomynona
IRCIRCIRCIRCIRCIRCIRCIRCIRCIRC
 
Not a Belt
Join Date: Jan 2007
Posts: 5,736
Clan: spirit



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")
suomynona is offline   Reply With Quote
Old Jan 19, 2008   #20
Blam
Now I know my abc's!
This user title is the property of SkulFuk.
 
4th Dan Black Belt
Join Date: Apr 2007
Posts: 5,507
Clan: bncy



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.


Code:
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
:D

Last edited by Blam; Jan 19, 2008 at 03:47 PM..
Blam is offline   Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 09:02 AM.




Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
ragdoll fighting game physics fighting game ragdoll fighting physics funmotion joints martial arts karate pc mac free game turn based game