Well here is the code bugs are lower in the post.
force = 500
assert( _file.Exists( "lua/ULib/init.lua" ), "UBowl needs ULib to run!" )
_OpenScript( "ULib/init.lua" )
assert( ULib.ULIB_VERSION >= 1, "UBowl requires ULib version 1 or higher to run!" )
red = 255
blu = 255
gre = 255
alph = 255
bowl = {}
for i = 1, _MaxPlayers() do
bowl[i] = {}
bowl[i].isbowl = 0 -- Dont edit
bowl[i].frame = 0 -- Dont edit
bowl[i].pins = 0 -- Dont edit
bowl[i].at = 1 -- Dont edit
bowl[i].on = 0 -- Dont edit
bowl[i].force = force -- Dont edit it is the amount of force only edit if you have a brain.
bowl[i].omg = 0 -- Dont edit it at all
bowl[i].lol = 0 -- Dont edit it at all
bowl[i].back = 0 -- Dont edit
bowl[i].start = nil; -- Try and guess
bowl[i].timeitself = nil; -- Try and guess
end
local pin = "models/mixerman3d/bowling/bowling_pin.mdl"
local ball = "models/mixerman3d/bowling/bowling_ball.mdl"
local spacing = 20
local rows = 4 -- Standard pin setup has 4 rows
local ents = {}
local function cc_makeLane( userid )
bowl[userid].timeitself = AddTimer(0.1,0,bowlthink,userid)
ents[ userid ] = ents[ userid ] or {}
PlayerLookTrace( userid, 4096 )
if not _TraceHit() then
ULib.tsay( userid, "Please look at where you want to spawn the lane!" )
return
end
local start = _TraceEndPos()
ULib.freezePlayer( userid )
local back = _EntGetForwardVector( userid )
local right = _EntGetRightVector( userid )
back.z = 0 -- We don't care about the third dimension
right.z = 0
local ang = vector3( 0, 90, 0 ) -- Used for angles
for y=1, rows do
local odd = (math.mod( y, 2 ) ~= 0)
offy = vecMul( back, spacing * (y-1) )
for x=1, y do
local offx
if x == 1 and odd then -- We just go straight back
offx = vector3( 0, 0, 0 )
ULib.print( "easy way out" )
ULib.print( "x =", x, "y =", y, "offx =", offx, "offy =", offy )
else
local direction = math.mod( x, 2 ) * 2 - 1 -- Go right on odd numbers, left on even, timesing by two makes it 1 or -1
local offnum
if not odd then -- We need to add one to account for the middle pin
offnum = x + 1 - math.mod( x + 1, 2 ) -- This rounds down to the nearest multiple of 2
else
offnum = x - math.mod( x, 2 ) -- This rounds down to the nearest multiple of 2
end
offnum = offnum / 2 -- And this gives us the number we want
if not odd then offnum = offnum - 0.5 end -- For those odd rows!
offx = vecMul( right, spacing * offnum * direction )
ULib.print( "x =", x, "y =", y, "offx =", offx, "offy =", offy )
ULib.print( "odd =", odd, "direction =", direction, "offnum =", offnum )
end
local pos = vecAdd( start, vecAdd( offx, offy ) )
table.insert( ents[ userid ], ULib.makeProp( pin, pos, ang ) )
ULib.print( pos, "\n\n\n" )
bowl[userid].isbowl = 1
_GModRect_Start( "gmod/white" );
_GModRect_SetPos( 0.02, 0.26, 0.18, 0.02 );
_GModRect_SetColor( 120, 120, 120, 200 );
_GModRect_SetTime( 99999, 0, 0 );
_GModRect_SetDelay( 0 );
_GModRect_Send( userid, 21 );
_GModRect_Start( "gmod/white" );
_GModRect_SetPos( 0.01, 0.025, 0.2, 0.27 );
_GModRect_SetColor( 20, 20, 20, 200 );
_GModRect_SetTime( 99999, 0, 0 );
_GModRect_SetDelay( 0 );
_GModRect_Send( userid, 20 );
_GModText_Start( "ChatFont" );
_GModText_SetPos( 0.02, 0.03 );
_GModText_SetColor( red, gre, blu, alph );
_GModText_SetTime( 99999, 0, 0 );
_GModText_SetText( "Name: " );
_GModText_Send( userid, 1 );
_GModText_Start( "ChatFont" );
_GModText_SetPos( 0.1, 0.03 );
_GModText_SetColor( red, gre, blu, alph );
_GModText_SetTime( 99999, 0, 0 );
_GModText_SetText( _PlayerInfo(userid,"name") );
_GModText_Send( userid, 2 );
_GModText_Start( "ChatFont" );
_GModText_SetPos( 0.02, 0.06 );
_GModText_SetColor( red, gre, blu, alph );
_GModText_SetTime( 99999, 0, 0 );
_GModText_SetText( "Frame: " );
_GModText_Send( userid, 3 );
_GModText_Start( "ChatFont" );
_GModText_SetPos( 0.1, 0.06 );
_GModText_SetColor( red, gre, blu, alph );
_GModText_SetTime( 99999, 0, 0 );
_GModText_SetText( "WTF" );
_GModText_Send( userid, 4 );
_GModText_Start( "ChatFont" );
_GModText_SetPos( 0.02, 0.09 );
_GModText_SetColor( red, gre, blu, alph );
_GModText_SetTime( 99999, 0, 0 );
_GModText_SetText( "Pins Out" );
_GModText_Send( userid, 5 );
_GModText_Start( "ChatFont" );
_GModText_SetPos( 0.1, 0.09 );
_GModText_SetColor( red, gre, blu, alph );
_GModText_SetTime( 99999, 0, 0 );
_GModText_SetText( "WTF" );
_GModText_Send( userid, 10 );
_GModText_Start( "ChatFont" );
_GModText_SetPos( 0.02, 0.12 );
_GModText_SetColor( red, gre, blu, alph );
_GModText_SetTime( 99999, 0, 0 );
_GModText_SetText( "Pins Left" );
_GModText_Send( userid, 7 );
_GModText_Start( "ChatFont" );
_GModText_SetPos( 0.1, 0.12 );
_GModText_SetColor( red, gre, blu, alph );
_GModText_SetTime( 99999, 0, 0 );
_GModText_SetText( "WTF" );
_GModText_Send( userid, 8 );
_GModText_Start( "ChatFont" );
_GModText_SetPos( 0.02, 0.15 );
_GModText_SetColor( red, gre, blu, alph );
_GModText_SetTime( 99999, 0, 0 );
_GModText_SetText( "Level at:" );
_GModText_Send( userid, 9 );
_GModText_Start( "ChatFont" );
_GModText_SetPos( 0.1, 0.15 );
_GModText_SetColor( red, gre, blu, alph );
_GModText_SetTime( 99999, 0, 0 );
_GModText_SetText( "By: Terminal58" );
_GModText_Send( userid, 11 );
bowl[userid].lol = math.floor(bowl[userid].force * 2)
end
end
end
ULib.CONCOMMAND( "makelane", cc_makeLane )
function bowlingguithink(userid)
local pLen = math.abs(100/500*bowl[userid].at);
local aLen = math.abs(0.16*(pLen/100));
local rColor = math.floor(255 - (255*(pLen/100)));
local gColor = math.floor(255*(pLen/100));
local bColor = 0
local aColor = 255
_GModRect_Start( "gmod/white" );
_GModRect_SetPos( 0.03, 0.265, aLen, 0.01 );
_GModRect_SetColor( rColor, gColor, bColor, aColor );
_GModRect_SetTime( 99999, 0, 0 );
_GModRect_SetDelay( 0 );
_GModRect_Send( userid, 22 );
_GModText_Start( "ChatFont" );
_GModText_SetPos( 0.02, 0.18 );
_GModText_SetColor( red, gre, blu, alph );
_GModText_SetTime( 99999, 0, 0 );
_GModText_SetText( bowl[userid].at );
_GModText_Send( userid, 12 );
end
function bowlthink(userid)
if bowl[userid].isbowl == 1 then
if bowl[userid].back == 0 then
bowl[userid].at = bowl[userid].at + 8
bowlingguithink(userid)
else
if bowl[userid].back == 1 then
bowl[userid].at = bowl[userid].at - 8
bowlingguithink(userid)
end
if bowl[userid].isbowl == 1 then
raisingthebar(userid)
end
end
end
end
function raisingthebar(userid)
if bowl[userid].at >= bowl[userid].force then
bowl[userid].back = 1
bowl[userid].at = bowl[userid].at - 8
bowlingguithink(userid)
ULib.print( "Back it up" )
else
if 0 >= bowl[userid].at then
undo(userid)
ULib.print( "A little bit ahead." )
end
end
end
function undo(userid)
if bowl[userid].isbowl == 1 then
_GModRect_Hide(userid,21);
_GModRect_Hide(userid,20);
_GModText_Hide(userid,1);
_GModText_Hide(userid,2);
_GModText_Hide(userid,3);
_GModText_Hide(userid,4);
_GModText_Hide(userid,5);
_GModText_Hide(userid,10);
_GModText_Hide(userid,7);
_GModText_Hide(userid,8);
_GModText_Hide(userid,9);
_GModText_Hide(userid,11);
_GModText_Hide(userid,22);
_GModText_Hide(userid,12);
bowl[userid].isbowl = 0 -- Dont edit
bowl[userid].frame = 0 -- Dont edit
bowl[userid].pins = 0 -- Dont edit
bowl[userid].at = 0 -- Dont edit
bowl[userid].on = 0 -- Dont edit
bowl[userid].force = force -- Dont edit it is the amount of force only edit if you have a brain.
bowl[userid].omg = 0 -- Dont edit it at all
bowl[userid].lol = 0 -- Dont edit it at all
bowl[userid].back = 0 -- Dont edit
bowl[userid].start = nil; -- Try and guess
HaltTimer(bowl[userid].timeitself)
ULib.unfreezePlayer( userid ) -- Unfreeze
if not ents[ userid ] then return end -- Nothing to do
for _, entid in ipairs( ents[ userid ] ) do
if _EntExists( entid ) and (_EntGetModel( entid ) == pin or _EntGetModel( entid ) == ball) then -- No exploiting here!
_EntRemove( entid )
end
end
end
end
ULib.CONCOMMAND( "undobowl", undo )
The problems I'm having are that half the time I start it it doesn't add or subtract the other half it doesn't go back also this isn't done yet I still have to add force and press space to stop is easy so don't worry about anything else. Also that GUI is from my other PBN project.
Edit
Cleaned it a little. EDIT 2 Cleaned it a lil more.