people playing: 222, servers online: 63, games played: 133,409,129 Top Player: Snook

  Toribash Community » Toribash » Mods » Lua scripts
Register FAQ General Rules Community
Reply
 
Thread Tools Display Modes
Old Aug 1, 2007   #1
Jok
Senior Member
 
White Belt
Join Date: Nov 2006



Get your Lua questions answered here!
Stuck on a piece of code that won't work no matter how you try to run it?

Post the relevant bits here and me (and any other person that knows the answer) will try and help you.

Also include what you're trying to do with the script. We may know Lua, but we're not mind-readers.
Jok is offline   Reply With Quote
Old Aug 5, 2007   #2
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,506
Clan: bncy



I tried to modify the dismember script, to show the name of the joint you have dismembered/fractured, and whether you have dismembered/fractured it.
It worked up until i added IF/THEN/ELSE and "ctype" things, before it always said the joint with dismembered or fractured by it depending on what you clicked.

(note: this is my first attempt at lua so be kind please :] )

Code:
 
-- dm.lua

function set_joint(player, joint)
	if (joint ~= -1) then
		cjointinfo = get_joint_info(player, joint)
		cjoint = joint
		cplayer = player
	end
end

function keydown(key)
	if ((key == string.byte("q")) and ((cplayer ~= -1) and (cjoint ~= -1))) then
	dismember_joint(cplayer,cjoint)
	ctype = "dismember"
	elseif ((key == string.byte("o")) and ((cplayer ~= -1) and (cjoint ~= -1))) then
	fracture_joint(cplayer,cjoint)
	ctype = "fracture"
	end
end

function keyup()
	ctype = ""
end

cplayer = -1
cjoint = -1

local function draw_centered_text_example()
      if ((ctype == "fracture")) then
	set_color(0, 0, 1, 1)
      draw_centered_text(cjointinfo.name.. "  " ..ctype, 100, 2)
	elseif ((ctype == "dismember"}} then
	set_color(1, 0, 0, 1)
      draw_centered_text(cjointinfo.name.. "  " ..ctype, 100, 2)
	elseif ((ctype == "")) then
	set_color(0, 0, 0, 1)
      draw_centered_text(cjointinfo.name, 100, 2)
	end
end

add_hook("draw2d", "draw_centered_text_example", draw_centered_text_example)
add_hook("joint_select", "dm", set_joint)
add_hook("key_down", "dm", keydown)
add_hook("key_up", "dm", keydup)
Now it doesn't do anything. Help please :].
Blam is offline   Reply With Quote
Old Aug 5, 2007   #3
suomynona
忍者
 
Not a Belt
Join Date: Jan 2007
Posts: 5,571
Clan: spirit



Originally Posted by Blam View Post
elseif ((ctype == "dismember"}} then

Supposed to be:

elseif ((ctype == "dismember")) then
I sell items from my inventory: 60k or more per item. Buy 200k worth of stuff and I'll give you a usertitle too. Some restrictions apply.
I'm a fan of following the rules as written, but I'm also a fan of rewriting poorly written rules.
If you think you've found a poorly written rule, please let me know!
suomynona is offline   Reply With Quote
Old Aug 5, 2007   #4
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,506
Clan: bncy



ack, i can't believe i missed that, thanks. =]

But now ctype doesnt want to go back to "" when the key is released :[

Last edited by Blam; Aug 5, 2007 at 07:34 PM..
Blam is offline   Reply With Quote
Old Aug 5, 2007   #5
suomynona
忍者
 
Not a Belt
Join Date: Jan 2007
Posts: 5,571
Clan: spirit



Originally Posted by Blam View Post
function keyup()
...
add_hook("key_up", "dm", keydup)

Perhaps this is the problem...
I sell items from my inventory: 60k or more per item. Buy 200k worth of stuff and I'll give you a usertitle too. Some restrictions apply.
I'm a fan of following the rules as written, but I'm also a fan of rewriting poorly written rules.
If you think you've found a poorly written rule, please let me know!
suomynona is offline   Reply With Quote
Old Aug 5, 2007   #6
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,506
Clan: bncy



god damn typos.

Thanks again.
I got to check my scripts more carefully.
:D

Last edited by Blam; Aug 5, 2007 at 10:44 PM..
Blam is offline   Reply With Quote
Old Oct 14, 2007   #7
Gynx

MESSATSU

Damn, i dont think i have the time to look this up, but where do you save teh .lua scripts to play them
?
collect snots from the nose
Gynx is offline   Reply With Quote
Old Oct 14, 2007   #8
Jam0864
ub3r
 
2nd Dan Black Belt
Join Date: Apr 2007
Posts: 3,066



DRIVE NAME (usually C)\Program Files\Toribash 2.75 (or other version)\data\scripts\My script.lua
^for windows^

thats all i know about lua scriptin! =D
Jam0864 is offline   Reply With Quote
Old Oct 23, 2007   #9
CanCan
Junior Member
 
White Belt
Join Date: Oct 2007



How do you draw lines?

Also, when you draw text, it takes the colour of any other text made (for example if you echo something it will go red). Any way to change this?
CanCan is offline   Reply With Quote
Old Oct 24, 2007   #10
Dafe
Serious Business
 
4th Dan Black Belt
Join Date: Jul 2006
Posts: 618
Clan: bncy



There's no simple way of drawing lines at the moment, so far as I know. You can write a line algorithm yourself with some periods or rectangles if you really need them.

You can set the text color explicitly prior to drawing it. Use set_color(<red>, <green>, <blue>, <alpha>). All values between 0 and 1.
Radioactive torso's description should be, "You have cancer like wow."
Dafe 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 08:06 PM.




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