Toribash
Originally Posted by laboblox View Post
can i have a list of all the lua/toribash objects and events?

You can find a list of all hook names in startup.lua:

local events = {
	"new_game",
	"new_mp_game", --Called when you join a new server
	"enter_frame",
	"end_game",
	"leave_game",
	"enter_freeze",
	"exit_freeze",
	"match_begin",
	"key_up",
	"key_down",
	"mouse_button_up",
	"mouse_button_down",
	"mouse_move",
	"player_select",
	"joint_select",
	"body_select",
	"draw2d",
	"draw3d",
	"play", --Part of torishop.
	"camera",
	"console",
	"bout_mouse_down",
	"bout_mouse_up",
	"bout_mouse_over",
	"bout_mouse_outside",
	"spec_mouse_down",
	"spec_mouse_up",
	"spec_mouse_over",
	"spec_mouse_outside",
	"command", --Called when an unused /command is entered.
	"unload",
}
You can look into /data/script/sdk/ for little examples of most of the functions.

You can also create a list yourself. Every global variable is stored in a table called _G that maps the variables name to its value. To generate a ordered list from that you can use this little script:

local names = {}
local types = {}

local function find(tab, val)
	for k, v in pairs(tab) do
		if v == val then
			return k
		end
	end
	
	return -1
end

for k, v in pairs(_G) do
	names[type(v)] = names[type(v)] or {}
	table.insert(names[type(v)], k)
	if(find(types, type(v)) == -1) then
		table.insert(types, type(v))
	end
end

table.sort(types)

local out = assert(io.open("_G.txt", "w"))
for _, t in pairs(types) do
	out:write(t .. "s:\n")
	table.sort(names[t])
	
	for __, n in pairs(names[t]) do
		out:write(n .. "\n")
	end
	
	out:write("\n")
end

out:close()

echo("done")
It writes the result to a file called "_G.txt".

This of course only gives you a name without any documentation but with a bit of searching in the sdk folder, a bit of googling or some experimenting you will find out what most of them do.

Also, some functions are deprecated and don't do anything.
Signature temporarily out of order.
Lua code:
-- set_joint_state (integer player_index, integer joint_index, integer joint_state)

-- USE: Sets the state of a specified joint
-- NOTES: 1,2 = Apply force on joint, 3 = Hold joint, 4 = Release_joint

local player_index, joint_state = 0, 1
for i=0,19 do
echo ("set_joint_state (" .. player_index .. ", " .. i .. ", " .. joint_state .. ")")
set_joint_state (player_index, i, joint_state)
end


Lua code:
-- set_grip_info(integer player_index, integer hand_id, integer grip_state)

-- USE: Sets the grip state for a specified hand
-- NOTES: Valid hand_id's are 11 and 12

local player_index, hand_id, grip_state = 0, 11, 1

set_grip_info( player_index, hand_id, grip_state)
echo ("set_grip_info (" .. player_index .. ", " .. hand_id .. ", " .. grip_state .. ")")


Most documentation is found in /scripts/sdk/.
[23:23:53] <AndChat|700625> Blue eyes ultimate dragon best card
[23:24:29] <AndChat|700625> You know the one with 3 heads
[23:24:39] <~Lightningkid> just like my dick



[11:35:40] <box> Hampa suck
[11:36:21] <hampa> not the first to tell me that today
Originally Posted by box View Post
Lua code:
-- set_joint_state (integer player_index, integer joint_index, integer joint_state)

-- USE: Sets the state of a specified joint
-- NOTES: 1,2 = Apply force on joint, 3 = Hold joint, 4 = Release_joint

local player_index, joint_state = 0, 1
for i=0,19 do
echo ("set_joint_state (" .. player_index .. ", " .. i .. ", " .. joint_state .. ")")
set_joint_state (player_index, i, joint_state)
end


Lua code:
-- set_grip_info(integer player_index, integer hand_id, integer grip_state)

-- USE: Sets the grip state for a specified hand
-- NOTES: Valid hand_id's are 11 and 12

local player_index, hand_id, grip_state = 0, 11, 1

set_grip_info( player_index, hand_id, grip_state)
echo ("set_grip_info (" .. player_index .. ", " .. hand_id .. ", " .. grip_state .. ")")


Most documentation is found in /scripts/sdk/.

thanks!
Last edited by porcelains; Oct 6, 2015 at 01:47 AM. Reason: <24 hour edit/bump
also how do I:
1. get the outcome of a match that just ended
2. get the score of each player of a match that just ended
You need a hook that fires when the match is over. Hooks are found in data/script/startup.lua. The hook you need is "end_game."

get_player_info() has the score of each player. However, the "score" object returned by this function seems to tally in a different way and produces a different result from what the score at the top of the screen is. To counter this, we use the "injury" variable (i.e. To get Tori's score, get Uke's injury value). Keep in mind that even if a player has a higher score, it doesn't mean that they are the winner in the case of a DQ. get_world_state() has the winner value. (0 for Tori, 1 for Uke).

This script outputs the winner's username and the score of each player when the match is over.

Lua code:
function endGame()
tori = get_player_info(0).name
uke = get_player_info(1).name
toriscore = get_player_info(1).injury
ukescore = get_player_info(0).injury

winner = get_player_info(get_world_state().winner).name

echo(winner .. " won.")
echo(tori .. ": " .. toriscore .. " points")
echo(uke .. ": " .. ukescore .. " points")
end

add_hook("end_game", "end_game", endGame)
[23:23:53] <AndChat|700625> Blue eyes ultimate dragon best card
[23:24:29] <AndChat|700625> You know the one with 3 heads
[23:24:39] <~Lightningkid> just like my dick



[11:35:40] <box> Hampa suck
[11:36:21] <hampa> not the first to tell me that today
How can i get returned the name (and description perhaps) of the room that im currently in, please?
Last edited by DuckHuntP; Oct 15, 2015 at 07:56 PM.

Not possible.
[23:23:53] <AndChat|700625> Blue eyes ultimate dragon best card
[23:24:29] <AndChat|700625> You know the one with 3 heads
[23:24:39] <~Lightningkid> just like my dick



[11:35:40] <box> Hampa suck
[11:36:21] <hampa> not the first to tell me that today