I'm just going to throw my code in here

Everything else goes here!
Post Reply
User avatar
Xan
Premium 1
Accountname: subzeroshark
Posts: 39
Joined: Jun 17, 2013
Last login: 2 years ago
Played: 480 hours
Blocks Mined: 79,558
Achievements: 63
Contact:

I'm just going to throw my code in here

Post by Xan » Thu Jun 11, 2015 12:46 am

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)
Undertale Prediction: Undertale Is Not A Series That I Do Because Undertale Is Not Real ...

User avatar
nickmcski
Site Admin
Premium 6
Location: Calgary, Canada
Posts: 1893
Joined: Aug 26, 2011
Last login: 27 days ago
Played: 4,297 hours
Blocks Mined: 576,291
Achievements: 170
Contact:

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

Post by nickmcski » Thu Jun 11, 2015 1:06 am

What game is this for?
Contributor to the craftland wiki http://wiki.craftland.org/wiki
Craftland coder.
3500+ Hours played
2500+ Hours as a Craftland admin.

User avatar
Xan
Premium 1
Accountname: subzeroshark
Posts: 39
Joined: Jun 17, 2013
Last login: 2 years ago
Played: 480 hours
Blocks Mined: 79,558
Achievements: 63
Contact:

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

Post by Xan » Fri Jun 12, 2015 12:55 am

This one was written in ROBLOX Lua.
Undertale Prediction: Undertale Is Not A Series That I Do Because Undertale Is Not Real ...

User avatar
Xan
Premium 1
Accountname: subzeroshark
Posts: 39
Joined: Jun 17, 2013
Last login: 2 years ago
Played: 480 hours
Blocks Mined: 79,558
Achievements: 63
Contact:

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

Post by Xan » Thu Jun 18, 2015 6:57 pm

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
Undertale Prediction: Undertale Is Not A Series That I Do Because Undertale Is Not Real ...

Post Reply

Who is online

Users browsing this forum: No registered users and 102 guests