people playing: 185, servers online: 62, games played: 132,272,888 Top Player: Karteiro

  Toribash Community » Toribash » Mods » Lua scripts
Register FAQ Community
Reply
 
Thread Tools Display Modes
Old Dec 12, 2012   #1
Yoyo
 
5th Dan Black Belt
Join Date: Nov 2009
Posts: 4,169



Random useless (or not) mini-scripts thread
For any bits of scripting that don't belong anywhere else. Feel free to share them here.
Newbie scripts are also accepted.

To get things started:

Having been learning how to work with math.cos and math.sin, I have achieved some wonderful results:
lua code:

len = 0
ang = 0
w,h = get_window_size()
angtbl = {}

while len <= w do
table.insert(angtbl,{x=(w/2)+(len*math.cos(ang)), y=(h/2)+(len*math.sin(ang))})
len = len + 0.1
ang = ang+0.01
end

add_hook("draw2d","y_test",function()
set_color(0,0,0,1)
draw_quad(0,0,w,h)
for i = 1,#angtbl do
set_color(math.random(),math.random(),math.random(),1)
draw_quad(angtbl[i].x-2, angtbl[i].y-2,4,4)
end
end)
Attached Files
File Type: lua circletest.lua (423 Bytes, 74 views)
multiple texture uploader! updated: multiple texture remover!
updated pretty colorlist!

<BobJoelZ> ok ive just rebooted my pc and ive tried to activate my reflex on yahoo internet explorer :/ no luck

<Aracoon> I do not enjoy having anal sex with multiple men
Yoyo is offline   Reply With Quote
Old Dec 14, 2012   #2
Toriality
ub3r
 
6th Dan Black Belt
Join Date: Jan 2012
Posts: 2,879



Hello Yoyo.

What it does?
:D
Toriality is offline   Reply With Quote
Old Dec 14, 2012   #3
tailow
Junior Member
 
Black Belt
Join Date: Dec 2011
Posts: 20



what it does?
tailow is offline   Reply With Quote
Old Dec 14, 2012   #4
Yoyo
 
5th Dan Black Belt
Join Date: Nov 2009
Posts: 4,169



Why don't you try it? :)
multiple texture uploader! updated: multiple texture remover!
updated pretty colorlist!

<BobJoelZ> ok ive just rebooted my pc and ive tried to activate my reflex on yahoo internet explorer :/ no luck

<Aracoon> I do not enjoy having anal sex with multiple men
Yoyo is offline   Reply With Quote
Old Dec 16, 2012   #5
Toriality
ub3r
 
6th Dan Black Belt
Join Date: Jan 2012
Posts: 2,879



- Hmmm , I feel curious about that
- I'll download!
- Let me see.. WOW WTF

Nice script lol!
:D
Toriality is offline   Reply With Quote
Old Dec 18, 2012   #6
Yoyo
 
5th Dan Black Belt
Join Date: Nov 2009
Posts: 4,169



I was bored, so I decided to code 2 circle algorithms:
lua code:

function draw_circle_b(xc,yc,r)
local x = 0
local y = r
local p = 3 - 2 * r
if not r then return end
while y >= x do
draw_quad(xc-x, yc-y, 1, 1)
draw_quad(xc-y, yc-x, 1, 1)
draw_quad(xc+y, yc-x, 1, 1)
draw_quad(xc+x, yc-y, 1, 1)
draw_quad(xc-x, yc+y, 1, 1)
draw_quad(xc-y, yc+x, 1, 1)
draw_quad(xc+y, yc+x, 1, 1)
draw_quad(xc+x, yc+y, 1, 1)
if p < 0 then
x=x+1
p=p+(4*x+6)
else
x=x+1
y=y-1
p=p+(4*(x-y)+10)
end
end
end

function draw_circle_n(xc,yc,r)
draw_disk(xc,yc,r-1,r,r*2.5,1,0,360,0)
end

add_hook("draw2d","",function() set_color(0,0,0,1) draw_circle_b(500,300,50) draw_circle_n(700,500,10) draw_circle_n(700,500,100) end)


First one is a lua translation of Bresenham's circle algorithm, second one is a simplified version of draw_disk adapted for circles.
The hook provided is an example.

Parameters are x position, y position and radius of the circle on both functions.
multiple texture uploader! updated: multiple texture remover!
updated pretty colorlist!

<BobJoelZ> ok ive just rebooted my pc and ive tried to activate my reflex on yahoo internet explorer :/ no luck

<Aracoon> I do not enjoy having anal sex with multiple men
Yoyo is offline   Reply With Quote
Old Dec 22, 2012   #7
Yoyo
 
5th Dan Black Belt
Join Date: Nov 2009
Posts: 4,169



A hacked startup.lua requested by john (aka box), it removes several restrictions while keeping backwards compatibility.
It removes all OS and cpath restrictions, and allows you to use the original file functions.
ex: _old_io_open("etc","w")
You can check for the hacked startup by checking the boolean _hackedstartup.
_startup.lua is the default startup.

Please don't mess around with this if you don't know what you're doing.
Attached Files
File Type: lua _startup.lua (3.2 KB, 18 views)
File Type: lua startup.lua (3.3 KB, 13 views)
multiple texture uploader! updated: multiple texture remover!
updated pretty colorlist!

<BobJoelZ> ok ive just rebooted my pc and ive tried to activate my reflex on yahoo internet explorer :/ no luck

<Aracoon> I do not enjoy having anal sex with multiple men

Last edited by Yoyo; Dec 22, 2012 at 07:17 PM..
Yoyo is offline   Reply With Quote
Old Dec 22, 2012   #8
box
?crazykid700=flashglass
 
Cardboard Belt
Join Date: Sep 2007
Posts: 9,171
Clan: I am



Great work, Yoyo. Your talent does not go un-noticed.
[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 Dec 24, 2012   #9
Yoyo
 
5th Dan Black Belt
Join Date: Nov 2009
Posts: 4,169



Working on a maze generator that john asked for, using prim's algorithm.
This is as far as I've gotten, but the maze still doesn't generate quite properly.
If anyone wants to help, feel free to.
source (big) 
Attached Files
File Type: lua boxprims.lua (3.5 KB, 28 views)
multiple texture uploader! updated: multiple texture remover!
updated pretty colorlist!

<BobJoelZ> ok ive just rebooted my pc and ive tried to activate my reflex on yahoo internet explorer :/ no luck

<Aracoon> I do not enjoy having anal sex with multiple men
Yoyo is offline   Reply With Quote
Old Dec 24, 2012   #10
psycore
Member
 
2nd Dan Black Belt
Join Date: Feb 2010
Posts: 388



What do you mean with "the maze still doesn't generate quite properly"? Looks like a maze to me.
Signature temporarily out of order.
psycore 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 04:16 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