generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: MOdule scripting

Previous Thread :: Next Thread 
lolb3 is not online. lolb3
Joined: 16 Jan 2010
Total Posts: 2268
09 Jan 2014 09:39 PM
module = {
print = function()
print("Hello world!")
end
}

Is it possible to call it by module.print()
?
Report Abuse
Absurdism is not online. Absurdism
Joined: 18 Jul 2013
Total Posts: 2568
09 Jan 2014 09:42 PM
Yes.
Report Abuse
lolb3 is not online. lolb3
Joined: 16 Jan 2010
Total Posts: 2268
09 Jan 2014 09:50 PM
WHy doesn't this work?

v={"2","n","0","o","e","w","s","w","p","t","4","8","x"}
c=v[4]..v[6]
t=9 x=3 m=4

onchat={
initiate = function(z)
print(z..c..math.sin(9).."x0l2GsIn"..t..m..x)
end
}

onchat.initate("A")
Report Abuse
Absurdism is not online. Absurdism
Joined: 18 Jul 2013
Total Posts: 2568
09 Jan 2014 09:51 PM
Before I even address any other problems, do you even know what math.sin is?
Report Abuse
lolb3 is not online. lolb3
Joined: 16 Jan 2010
Total Posts: 2268
09 Jan 2014 09:53 PM
I don't feel line writing the sine of 9 because that'd be long. A sine gives an angle of a triangle in radians btw
Report Abuse
lolb3 is not online. lolb3
Joined: 16 Jan 2010
Total Posts: 2268
09 Jan 2014 09:55 PM
trig yo
Report Abuse
Absurdism is not online. Absurdism
Joined: 18 Jul 2013
Total Posts: 2568
09 Jan 2014 10:02 PM
No. Sine returns the opposite over adjacent of a right triangle. It is also used to describe the y-value of a circle at any vector base angle. But, we are not here to discuss basic trigonometry.
Also, your problem is that initiate is a reserved function.

v={"2","n","0","o","e","w","s","w","p","t","4","8","x"}
c=v[4]..v[6]
t=9 x=3 m=4

onchat={}
onchat.initiate = function(z)
print(z..c..math.sin(9).."x0l2GsIn"..t..m..x)
end

onchat.initate("A")
Report Abuse
Absurdism is not online. Absurdism
Joined: 18 Jul 2013
Total Posts: 2568
09 Jan 2014 10:04 PM
Sorry, I failed to copy the fixed code. You spelled 'initiate' incorrectly, so:

onchat.initiate("A")
Report Abuse
Notunknown99 is not online. Notunknown99
Joined: 05 Sep 2008
Total Posts: 25360
09 Jan 2014 10:19 PM
@Absurdism: Works fine for me, given that the words are the same. I see no need to change the

t = {
f = function()
end
}

into

t = {}
t.f = function()
end

Why do that?
Report Abuse
Absurdism is not online. Absurdism
Joined: 18 Jul 2013
Total Posts: 2568
09 Jan 2014 10:20 PM
it is preferential, especially when going for an object-oriented style.
Report Abuse
lolb3 is not online. lolb3
Joined: 16 Jan 2010
Total Posts: 2268
09 Jan 2014 10:35 PM
Hm thats what my friend said. All I know about sines is they make cool lines on my calculator

I have this model called lua classes and it sets a global class for easy refrence like so

class math = {huge = math.huge,
random= math.random}

Is it the same thing? There's also other "classes" with functions in them
Report Abuse
SpeedySeat is online. SpeedySeat
Joined: 06 Jul 2011
Total Posts: 3048
09 Jan 2014 10:47 PM
Funny you should mention, because I also happen to have command-based modules and command-based module scripting called ModuLogic.

Here's an example of some modules I've implimented:
Modules["kill"] = function(speaker, lists, args)
info={version="v1.1"}
for __,list in pairs(lists) do
for _,pl in pairs(list) do
local char = pl.Character
if char then
char:BreakJoints()
end
end
wait(5.1) -- create several lists of the same type to loopkill
end
end
Modules["heal"] = function(speaker, lists, args)
info={version="v1.1"}
for __,list in pairs(lists) do
for _,pl in pairs(list) do
local char = pl.Character
if char and char:FindFirstChild("Humanoid") and char.Humanoid:IsA("Humanoid") then
char.Humanoid.Health = char.Humanoid.MaxHealth
end
end
end
end
Modules["teleport"] = function(speaker, lists, args)
info={version="v1.1"}
if #lists ~= 2 then return end
from = lists[1]
to = lists[2][1]
if not to then return end
for _,pl in pairs(from) do
local char = pl.Character
if char and char:FindFirstChild("Torso") and to.Character and to.Character:FindFirstChild("Torso") then
char.Torso.CFrame = to.Character.Torso.CFrame
end
end
end
Modules["ff"] = function(speaker, lists, args)
info={version="v1.1"}
for __,list in pairs(lists) do
for _,pl in pairs(list) do
local char = pl.Character
if char then
local ff = Instance.new("ForceField", char)
ff.Name = "CommandShield"
end
end
end
end
Modules["unff"] = function(speaker, lists, args)
info={version="v1.1"}
for __,list in pairs(lists) do
for _,pl in pairs(list) do
local char = pl.Character
if char and char:FindFirstChild("CommandShield") then
repeat
char.CommandShield:Destroy()
until not char or not char:FindFirstChild("CommandShield")
end
end
end
end
Modules["vanish"] = function(speaker, lists, args)
info={version="v1.1"}
for __,list in pairs(lists) do
for _,pl in pairs(list) do
local char = pl.Character
if char then
for ___,c in pairs(char:GetChildren()) do
if c:IsA("BasePart") then
c.Transparency = 1
end
if c:IsA("Hat") and c:FindFirstChild("Handle") and c.Handle:IsA("BasePart") then
c.Handle.Transparency = 1
end
if c:FindFirstChild("face") and c.face:IsA("Decal") then
c.Transparency = 1
end
end
end
end
end
end


Here's also the code for my ModuLogic API Parser:

ModulogicAPI = function(speaker, logic, elvl, varis, defis, isloop, loopindex)
-- define>Cast/bla,ra>{case>player/stat/Money>given~(<)100{give: %ra%}};case>Player1/stat>CP~(=)1{kill:me;kill:others}|{m: Hi};
-- case>Player1/distancefrom/Part>given~(<=)50{m: Hello %player/name%!}|{m: No!}

-- ex: case>executionLevel>given~(=)1{m: Hia}|{m: NOWONTLETU}
-- ex2: _G.ModulogicAPI(game.Players.Player1, "case>executionLevel>given~(=)1{m: Hia}>{m: NOWONTLETU}")
-- ex3: _G.ModulogicAPI(game.Players.Player1, "case>Player1/name>given~(=)Player1{m: Wussup}>{m: Nm '%Player1/name%'}")
local geterror = GetBadCountError(logic)
local vars=varis or {}
local defs=defis or {}
vars["pln"]=speaker.Name
vars["executionLevel"]=(elvl or 0) + 1
vars["elvl"]=vars["executionLevel"]
vars["ModulogicVersion"]=1.1
vars["mlv"]=vars["ModulogicVersion"]
if isloop then
print("Loop index found")
vars["index"]=tostring(loopindex)
end
if elvl and elvl >= 25 then print("Stack overflow!") return end
if geterror ~= "noerror" then
if speaker ~= "console" then
local m = Instance.new("Message", speaker.PlayerGui)
m.Text = "ModuLogic Error: " ..geterror
wait(4)
m:Destroy()
else
print("ModuLogic Error: " ..geterror)
end
return
end
local commands = ModulogicExplodeAPI(logic, ";")
for i = 1, #commands do
local parts = ModulogicExplodeAPI(commands[i], ">")
if #parts >= 3 then
local command = FixVariables(speaker, parts[1], vars)
local type = FixVariables(speaker, "%" ..parts[2].. "%", vars)
local args = FixVariables(speaker, parts[3], vars)
if command == "case" then
local check = false
local capsuloc, capsulend = args:find("~%(")
if not capsuloc or capsuloc == 1 then return end
local comploc = args:find(")")
local case = args:find("{")
local caseend = args:sub(args:len(), args:len())
if not comploc or comploc == capsulend+1 or not case or caseend ~= "}" or case == args:len()-1 then return end
local compargs = {
args:sub(1, capsuloc-1),
args:sub(capsulend+1, comploc-1),
args:sub(comploc+1, case-1),
args:sub(case+1, args:len()-1)
}
local elsecase = ""
if parts[4] and parts[4]:len() > 2 and parts[4]:sub(1, 1) == "{" and parts[4]:sub(parts[4]:len()) == "}" then
elsecase = parts[4]:sub(2, parts[4]:len()-1)
end
local GetObj = function(arg)
if arg == "given" then -- for variable use
if tonumber(type) then
return tonumber(type)
else
return type
end
elseif tonumber(arg) then -- for variable fixation
print(arg.. " found.")
return tonumber(arg)
end
end
if compargs[2] == "=" or compargs[2] == "==" then
if compargs[3] and GetObj(compargs[1]) then
check = (tostring(compargs[3]) == tostring(GetObj(compargs[1])))
end
elseif compargs[2] == ">" then
if tonumber(compargs[3]) and tonumber(GetObj(compargs[1])) then
check = (tonumber(GetObj(compargs[1])) > tonumber(compargs[3]))
end
elseif compargs[2] == "<" then
if tonumber(compargs[3]) and tonumber(GetObj(compargs[1])) then
check = (tonumber(GetObj(compargs[1])) < tonumber(compargs[3]))
end
elseif compargs[2] == ">=" then
if tonumber(compargs[3]) and tonumber(GetObj(compargs[1])) then
check = (tonumber(GetObj(compargs[1])) >= tonumber(compargs[3]))
end
elseif compargs[2] == "<=" then
if tonumber(compargs[3]) and tonumber(GetObj(compargs[1])) then
check = (tonumber(GetObj(compargs[1])) <= tonumber(compargs[3]))
end
elseif compargs[2] == "~=" or compargs[2] == "!=" or compargs[2] == "<>" or compargs[2] == "~" then
if compargs[3] and GetObj(compargs[1]) then
check = (tostring(GetObj(compargs[1])) ~= tostring(compargs[3]))
end
end
if check then
ModulogicAPI(speaker, compargs[4], vars["executionLevel"], vars, defs)
print("FINAL RESULT: Execution successful!")
elseif elsecase ~= "" then
ModulogicAPI(speaker, elsecase, vars["executionLevel"], vars, defs)
print("FINAL RESULT: Execution else successful!")
else
print("FINAL RESULT: Execution failed!")
end
elseif command == "define" then
type = parts[2]
if #parts ~= 3 then return end
vars[type]=args
elseif command == "function" then
type = CommandExplodeAPI(parts[2], "/")
if #parts ~= 3 then return end
if parts[3]:len() < 3 then return end
if parts[3]:sub(1, 1) ~= "{" or parts[3]:sub(parts[3]:len(), parts[3]:len()) ~= "}" then return end
if #type > 1 then
local args = CommandExplodeAPI(type[2], ",")
defs[type[1]]={args, parts[3]:sub(2, parts[3]:len()-1)}
end
elseif command == "loop" then
local count = tonumber(FixVariables(speaker, parts[2], vars))
if #parts ~= 3 or not count or count < 1 then print("Bad count") return end
local case = parts[3]:find("{")
local caseend = parts[3]:sub(parts[3]:len(), parts[3]:len())
if caseend ~= "}" or case ~= 1 then print("Nope. Not good. " ..caseend) return end
local sublogic = (parts[3]):sub(2, parts[3]:len()-1)
print("Looping " ..sublogic.. " " ..count.. " times...")
for i = 1, math.ceil(count) do
ModulogicAPI(speaker, sublogic, vars["executionLevel"], vars, defs, true, i)
end
elseif command == "call" then
type = CommandExplodeAPI(parts[3], ",")
if not defs[parts[2]] then return end
for i = 1, #type do
vars[defs[parts[2]][1][i]]=type[i]
end
ModulogicAPI(speaker, defs[parts[2]][2], vars["executionLevel"], vars, defs)
end
elseif #parts == 1 then
local sendCommand = FixVariables(speaker, parts[1], vars)
print(sendCommand, type(sendCommand))
if type(sendCommand) ~= "string" then return end
_G.SendCommand(speaker, sendCommand)
end
end
end
Report Abuse
lolb3 is not online. lolb3
Joined: 16 Jan 2010
Total Posts: 2268
09 Jan 2014 11:28 PM
Interesting
I'm definitely going to track this thread
Report Abuse
Absurdism is not online. Absurdism
Joined: 18 Jul 2013
Total Posts: 2568
10 Jan 2014 04:49 PM
Speedy, that isn't a good script.
Report Abuse
VoidShredder is not online. VoidShredder
Joined: 06 Jan 2014
Total Posts: 1467
10 Jan 2014 05:19 PM
@Absurd, sine is opposite over hypotenuse, not opposite over adjacent. Thats tangent.

Although... sine is more commonly used as the 'y' coordinate of the end point of a line that has one endpoint at the center of a circle with a radius of 1 centered at the origin. aka unit circle.
Report Abuse
Absurdism is not online. Absurdism
Joined: 18 Jul 2013
Total Posts: 2568
10 Jan 2014 05:42 PM
@VoidShredder, you are correct. Just a slip of the tongue. Although, I already stated your latter statement.
Report Abuse
SpeedySeat is online. SpeedySeat
Joined: 06 Jul 2011
Total Posts: 3048
10 Jan 2014 10:20 PM
@Absurdism That isn't an eightieth of the script.

The reason the modules are simple are to promote adaptability, and the APIs used to make the parsing work are actually quite complex.

Thanks for judging it based on a gaze over the module, but they actually integrate very well.

also you can use every command in module scripting. Example:

case>me/stat/Money>given ~(<) 100
{
kill:me;
case>me/name>given ~(=) SpeedySeat
{
tool:me: tools;
tool:me: bins
}
}

This is all done on the fly, you can paste that directly into a chat window. Also the system is not fully developed yet so don't comment on the minor inconveniences about the thing (namely the parentheses around the comparisons)
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image