people playing: 33, servers online: 10, games played: 142,000,000 Top Player: Penguin

  Toribash Community » Toribash » Mods » Lua scripts
Register FAQ General Rules Community
Reply
 
Thread Tools Display Modes
Old Mar 7, 2015   #671
psycore
Member
 
2nd Dan Black Belt
Join Date: Feb 2010
Posts: 388



get_player_info(0).name stores Tori's name.

Is autobet a standart Toribash command? Or does it come from a different script? If it's from a different script, you can't execute it with run_cmd.
Signature temporarily out of order.
psycore is offline   Reply With Quote
Old Mar 7, 2015   #672
AbsurdAzn
Junior Member
 
Black Belt
Join Date: Dec 2014
Posts: 12



It's a toribash command...
AbsurdAzn is offline   Reply With Quote
Old Mar 7, 2015   #673
psycore
Member
 
2nd Dan Black Belt
Join Date: Feb 2010
Posts: 388



You're right. I tested it only in single player which obviously doesn't work. But it seems that autobet indeed is one of the commands that run_cmd can't run (as mentioned earlier, /say doesn't work either). My guess is that it is to prevent abuse.
Signature temporarily out of order.
psycore is offline   Reply With Quote
Old Mar 18, 2015   #674
Dackill
Junior Member
 
Green Belt
Join Date: Mar 2015
Posts: 1



I need help with move saver, can anyone help me?
Dackill is offline   Reply With Quote
Old Jun 8, 2015   #675
psycore
Member
 
2nd Dan Black Belt
Join Date: Feb 2010
Posts: 388



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:

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

Code:
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.
psycore is offline   Reply With Quote
Old Oct 5, 2015   #676
porcelains
Junior Member
 
Orange Belt
Join Date: Feb 2015
Posts: 3



how do i use set_joint_state and set_grip_info?
porcelains is offline   Reply With Quote
Old Oct 5, 2015   #677
box
?crazykid700=flashglass
 
Cardboard Belt
Join Date: Sep 2007
Posts: 9,243
Clan: I am



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
box is offline   Reply With Quote
Old Oct 5, 2015   #678
porcelains
Junior Member
 
Orange Belt
Join Date: Feb 2015
Posts: 3



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 12:47 AM.. Reason: <24 hour edit/bump
porcelains is offline   Reply With Quote
Old Oct 6, 2015   #679
porcelains
Junior Member
 
Orange Belt
Join Date: Feb 2015
Posts: 3



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
porcelains is offline   Reply With Quote
Old Oct 6, 2015   #680
box
?crazykid700=flashglass
 
Cardboard Belt
Join Date: Sep 2007
Posts: 9,243
Clan: I am



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
box 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 06:28 AM.




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