Page 1 of 1

I'm just going to throw my code in here

Posted: Thu Jun 11, 2015 12:46 am
by Xan
And you can watch.
Or put more code into this so I can modify it to my needs. (Preferably this one. I'm bored.)


This specific code will put a realistic tail on the player that can be controlled with the mouse's position.
The higher up the mouse is on the screen, the more straight, the lower is the more curved.
Left/Right are inverted.

Code: Select all

wait(1)
local Parts = {game.Players.LocalPlayer.Character.Torso}
local w = {}
for i = 2, 22 do
	Parts[i] = Instance.new("Part", game.Players.LocalPlayer.Character)
	Parts[i].BrickColor = BrickColor.Blue()
	Parts[i].CanCollide = false
	Parts[i].Locked = true
	Parts[i].formFactor = "Symmetric"
	Parts[i].Size = Vector3.new(1, 1, 1)
	Mesh = Instance.new("BlockMesh", Parts[i])
	Mesh.Name = "Mesh"
	if i > 18 then
		mult = (i-18) / 10
	else
		mult = 0
	end
	Mesh.Scale = Vector3.new((math.abs(0.4 - (i - 1) / 40)) + 0.2 + mult, 0.6 - (i - 1) / 40, 0.5)
	w[i - 1] = Instance.new("Weld", Parts[i])
	w[i - 1].Part0 = Parts[i - 1]
	w[i - 1].Part1 = Parts[i]
	w[i - 1].C0 = CFrame.new(0, 0, 0.25)
	w[i - 1].C1 = CFrame.new(0, 0, -0.25)
end
w[1].C0 = CFrame.new(0, -0.75, 0.5)
function Smooth(WhereTo0, Welds)
	local CR0 = CFrame.new(Welds[1].C1:toEulerAnglesXYZ()).p
	local CR1 = CFrame.new(WhereTo0).p
	local AddTo0 = (CR1 - CR0) / 50
	for a = 1, #Welds do
		Welds[a].C1 = Welds[a].C1 * CFrame.fromEulerAnglesXYZ(AddTo0.x, AddTo0.y, AddTo0.z)
	end
end

local scr = Instance.new("ScreenGui", game.Players.LocalPlayer.PlayerGui)
local absx = scr.AbsoluteSize.X
local absy = scr.AbsoluteSize.Y

scr:Destroy()

local mouse = game.Players.LocalPlayer:GetMouse()
game:GetService("RunService").RenderStepped:connect(function ()
	local r = CFrame.new(Vector3.new((mouse.Y - absy/2)/absy, (mouse.X - absx/2)/absx, 0)).p
	local x = r.x
	local y = r.y
	local z = r.z
	Smooth(Vector3.new(x, y, z), w)
end)

Re: I'm just going to throw my code in here

Posted: Thu Jun 11, 2015 1:06 am
by nickmcski
What game is this for?

Re: I'm just going to throw my code in here

Posted: Fri Jun 12, 2015 12:55 am
by Xan
This one was written in ROBLOX Lua.

Re: I'm just going to throw my code in here

Posted: Thu Jun 18, 2015 6:57 pm
by Xan
Another ROBLOX one - Admin commands.
This one is unique in the way that it works:
Commands are entries in a table, their index key (what you use to index them) is the command:

Code: Select all

local Commands = {
	["What I type after the /"] = {{Usergroup(s)}, "Description", function (plr, args)
	
	end}
}
Alongside this, the index is a table storing what ranks can use the command, a brief description of the command (for the "/commands" command) as well as a function value for storing the code that runs when that command is indexed.

Each function has two things passed in: plr (object) and args (table)
plr is the player that executed the command and args are the extra arguments that the command gives (You'll see what I mean by this). The arguments are interesting because if I say "/pm Player1 Hello", the text "Player1" is the first table entry, and "Hello" is the second.

Another cool thing is that I use a web API to get players' user IDs from their name. This is beneficial for the /char command. The /char command allows players to transform into other ROBLOX players on the website. The /char command (in other admin scripts) generally takes in only a user ID then uses the link http://www.roblox.com/Asset/CharacterFetch.ashx?userId= to get that player's appearance. On the other hand, my system will allow you to type in a username (i.e. /char Player1 Boopbot), making it much easier for the user of the commands.

I also use a web API to get asset information, so when a player runs the /insert command to load assets from the website, I am capable of displaying a message on their screen that says "Inserting asset name by asset creator"

You can see the code here. MANY commands will be added.

http://pastebin.com/zQmVX5kh