Toribash
A:
add_hook("enter_freeze","disableGhost",function() set_ghost(0) end)
C: The distance from Tori's head to Uke's Joints. Returns an array.
function getDistance()
 distance={}
 hPos = get_body_info(0,0).pos
 for j=0, 19 do
  jPos = get_joint_pos2(1, j)
  distance[j] = math.sqrt(math.pow(hPos.x-jPos.x,2)+math.pow(hPos.y-jPos.y,2)+math.pow(hPos.z-jPos.z,2))
 end
 return distance
end
As far as I know it's impossible to get the exact momentum. You could try to get the acceleration with a = 2s/tē for very short t. You have to figure out the mass somehow else.

e: My bad, momentum is m*v, not m*a. For v use get_body_linear_vel() and get_body_angular_vel(). Still the Problem with the mass.
Last edited by psycore; May 27, 2011 at 09:26 PM.
Signature temporarily out of order.
Originally Posted by jakob1234 View Post
how do i get three to four player on toribash

http://forum.toribash.com/showthread.php?t=16603

But not the right place to ask, seeing as you're not looking for help with a lua script.
Originally Posted by psycore View Post
A:
add_hook("enter_freeze","disableGhost",function() set_ghost(0) end)
C: The distance from Tori's head to Uke's Joints. Returns an array.
function getDistance()
 distance={}
 hPos = get_body_info(0,0).pos
 for j=0, 19 do
  jPos = get_joint_pos2(1, j)
  distance[j] = math.sqrt(math.pow(hPos.x-jPos.x,2)+math.pow(hPos.y-jPos.y,2)+math.pow(hPos.z-jPos.z,2))
 end
 return distance
end
As far as I know it's impossible to get the exact momentum. You could try to get the acceleration with a = 2s/tē for very short t. You have to figure out the mass somehow else.

e: My bad, momentum is m*v, not m*a. For v use get_body_linear_vel() and get_body_angular_vel(). Still the Problem with the mass.

I could theoretically use radius*vel to get momentum, the thing about this script is it's entirely fuzzy logic, so if the input isn't exact I'll still get a good result. At the moment I'm simply using velocity as input and it will do, lots of debugging to do to get this to work, I've had to re factor all 400 lines of code three times now due to LUA's dodgy object orientation methods.


[EDIT] Grah, having a problem I'm not sure how to resolve.

...
	function self:gameTurn(frames)
		...
		run_frames(frames)
	end
...

add_hook("enter_freeze","play a turn",h:gameTurn(10))
...
This doesn't appear to be working, it runs 10 frames once at the start of a game and never runs again, however I need this to run every turn. It also doesn't run if I press space-bar to advance the turn, it's as if the hook isn't working.

[EDIT] YoYo fixed that problem, never-mind, currently working with the programme to fine tune it.
Last edited by Vox; May 29, 2011 at 10:52 PM.
I would love to see the outcome of your script.
PS: to get the mass you can parse the mod file; look at the code of my ModEditor for a parser.
"Wenn Sensei Tanaka sein Shodushi ist, dann soll er hingehen und uns den Dimak zeigen!"
If you followed the Suggest a script thread lately you know that I'm working on a script with some buttons. I decided to use the GUI stuff that comes with TB. Now my problem is that I can't get it to work. What the script is supposed to do is displaying some buttons with different text. All it does is showing one button with the text of a button wich shouldn't be displayed.
If you just could look over the script and tell me what I'm missing.
(I know there is no onClick() yet, but I guess that won't cause my problems)
Attached Files
hosting.lua (2.0 KB, 6 views)
Signature temporarily out of order.
@Vox: It doesn't work because you tell the program to use the result of Lua code:
h:gameTurn(10)
as hook.
Lua code:

local function wrap()
h:gameTurn(10)
end
add_hook("enter_freeze","play a turn",wrap)

Notice that there are no braces after wrap in the last line. The function doesn't get called, but is a parameter to the add_hook function.
@psycore: Why not use DeScript?
"Wenn Sensei Tanaka sein Shodushi ist, dann soll er hingehen und uns den Dimak zeigen!"
Dunno if you can help me, but computer is being gay with WorldBuilder.lua
I have laptop, without number pad, I've seen a lot of tutorials, I press ~, nothing, I press *, nothing, I press K then ~, nothing, I press K then *, nothing.
Someone help me please...
oh yeah
???
I know nothing about lua but what is the easiest way to load a script every time Toribash loads up?
Edit: Is there a script to load scripts?
Last edited by PhrozenPHD; Oct 10, 2011 at 04:52 AM.
Add "ls <scriptname.lua>" to profile.tbs in your Toribash root directory (typically C:\Games\Toribash-version\) to autoload the script.
DeScript would load scripts for you, but I think there are a few compatibility issues and DeFransen is banned, so it's unlikely to be updated soon.
))<>((