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 » Scripters
Home Search
 

Re: Scripting Challenge

Previous Thread :: Next Thread 
nairod7 is not online. nairod7
Joined: 26 Mar 2010
Total Posts: 869
23 Apr 2013 01:39 PM
Hello,

I've thought about something that can be interesting for a scripting challenge. This is the first time I do it, so maybe it would be too easy, or too long... I don't know, let's try.

----------------------------------------------------------------------------
Instructions:

- Make a function that will loop call another function (I know, that's noob when I say it like this). This function will have 3 arguments (nouns I'll give aren't fixed):
> a 'times' argument that corresponds of how many time you want to call the function
> a 'function_call' argument that corresponds to the function to loop call,
> a vararg argument for all the arguments of 'function_call'.

- The first argument of 'function_call' will be the number of time it had been called.

- The function you'll make will return 3 values:
> a table containing the returned values of each calls of 'function_call'
> an int value that corresponds to the number of time 'function_call' has been called
> a string that corresponds to errors done in 'function_call' (the use of ypcall is needed)

----------------------------------------------------------------------------
Example_1 (no_errored_version):

local function test_function(value,str1,str2)
return "("..str1..str2..tostring(value)..")"
end

local ypcall_return, time_break, error_string = execute_function(5, test_function, "v", "=")

print(table.concat(ypcall_return, ", "), time_break, error_string)

> (v=1), (v=2), (v=3), (v=4), (v=5) 5 nil

----------------------------------------------------------------------------
Example_2 (errored_version):

local function test_function(value,str1,str2)
local error = value == 3 and true + 1
return "("..str1..str2..tostring(value)..")"
end

local ypcall_return, time_break, error_string = execute_function(5, test_function, "v", "=")

print(table.concat(ypcall_return, ", "), time_break, error_string)

> (v=1), (v=2) 3 Workspace.Script:?????: attempt to perform arithmetic on a boolean value

----------------------------------------------------------------------------
Restrictions:

-You're not allowed to make more than 1 function (exclusing the 'test_function'(function_call) and the 'execute_function')
-You're not allowed to use '_numeric_ for' loops
-You're not allowed to make the execute_function do recursive calls
-You're not allowed to make tables except the one used to return values


That's all. Good luck (if you accept that challenge)
Report Abuse
nairod7 is not online. nairod7
Joined: 26 Mar 2010
Total Posts: 869
23 Apr 2013 01:44 PM
This function will have 3 PARAMETERS* (replace the rest o;o)
Report Abuse
nairod7 is not online. nairod7
Joined: 26 Mar 2010
Total Posts: 869
23 Apr 2013 01:57 PM
Also, in restrictions:
> while loops and repeat loops aren't allowed
Report Abuse
nairod7 is not online. nairod7
Joined: 26 Mar 2010
Total Posts: 869
23 Apr 2013 01:59 PM
"-You're not allowed to make more than 1 function (exclusing the 'test_function'(function_call) and the 'execute_function')"

> The function you're allowed to do musn't musn't call any other function (even itself).
Report Abuse
Dr01d3k4 is not online. Dr01d3k4
Joined: 11 Oct 2007
Total Posts: 17916
23 Apr 2013 02:04 PM
I didn't notice the restrictions at the end and did it in Moonscript. This means that more than 1 table was created.
pastebin/zaaNKVNv
I'm not even sure if that's correct.
Report Abuse
nairod7 is not online. nairod7
Joined: 26 Mar 2010
Total Posts: 869
23 Apr 2013 02:08 PM
The compiled lua version uses a numeric for loop.
Report Abuse
Dr01d3k4 is not online. Dr01d3k4
Joined: 11 Oct 2007
Total Posts: 17916
23 Apr 2013 02:10 PM
Fixed that by changing "unpack [v for v in *ret]" to just "unpack ret" (the original was just redundant and left over from a previous version, "[ret[v] for v = 2, #ret]"), but it still breaks restrictions.
Report Abuse
nairod7 is not online. nairod7
Joined: 26 Mar 2010
Total Posts: 869
23 Apr 2013 02:24 PM
There's something I have to clarify with returned value and the table containing those returned value. If the 'function_call' parameter return 1 value, that's fine. The table you're allowed to do will contain the returned value of each calls of that function. Assuming the function return a value and assuming there's no error in it, the table length will be the same as the number of times you call the function.
Report Abuse
nairod7 is not online. nairod7
Joined: 26 Mar 2010
Total Posts: 869
23 Apr 2013 04:09 PM
This is my version to do it.

local function execute_function(times, function_call, ...)
local ypcall_return, time_break, error_string, errored = {}
for value in function(times, value) return (value < times) and 1 + value or nil end, times, 0 do
errored,error_string = ypcall(function_call, value, ...)
time_break = value
if not errored then break
else
ypcall_return[#ypcall_return+1] = error_string
error_string = nil
end
end
return ypcall_return, time_break, error_string
end
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • 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