HTOTM: FUSION
Original Post
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
circletest.lua (423 Bytes, 91 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
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
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
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
_startup.lua (3.2 KB, 23 views)
startup.lua (3.3 KB, 18 views)
Last edited by Yoyo; Dec 22, 2012 at 08:17 PM.
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
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
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
boxprims.lua (3.5 KB, 32 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
What do you mean with "the maze still doesn't generate quite properly"? Looks like a maze to me.
Signature temporarily out of order.