Difference between revisions of "Loop Me Not (CMS)"
m |
|||
(4 intermediate revisions by the same user not shown) | |||
Line 3: | Line 3: | ||
! style="text-align:left" | Name !! style="text-align:left" | Type !! style="text-align:left" | By | ! style="text-align:left" | Name !! style="text-align:left" | Type !! style="text-align:left" | By | ||
|- | |- | ||
− | | Loop Me Not || Definition || AFRLme | + | | Loop Me Not || Definition || [https://www.patreon.com/AFRLme AFRLme] |
|} | |} | ||
Line 9: | Line 9: | ||
− | == Instructions == | + | == Version 1: Reusable Looping Function == |
+ | |||
+ | This version can be reused multiple times as we are calling a function stored in a variable that contains the lines of code that we want to execute each time the function is looped. | ||
+ | |||
+ | === Instructions === | ||
1. Add this script into the script section of the Visionaire Studio editor & set as a defintion type script... | 1. Add this script into the script section of the Visionaire Studio editor & set as a defintion type script... | ||
Line 15: | Line 19: | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
--[[ | --[[ | ||
− | Loop Me Not [v1] (29/08/2022) | + | Loop Me Not (reusable) [v1] (29/08/2022) |
Written by AFRLme [Lee Clarke] | Written by AFRLme [Lee Clarke] | ||
-- + -- | -- + -- | ||
− | afrlme@outlook.com | + | email: afrlme@outlook.com |
+ | paypal: afrlme@zoho.com | ||
+ | patreon: https://www.patreon.com/AFRLme | ||
+ | portfolio: https://afrl.me | ||
-- + -- | -- + -- | ||
This script is donation optional. In game credit is non-negotiable. | This script is donation optional. In game credit is non-negotiable. | ||
Line 30: | Line 37: | ||
-- + -- | -- + -- | ||
inc = inc - 1 -- decrement inc variable by 1 | inc = inc - 1 -- decrement inc variable by 1 | ||
− | setDelay(delay, function() loopMeNot(act, inc, delay) end) | + | setDelay(delay, function() loopMeNot(act, inc, delay) end) -- recall function after x delay |
end | end | ||
end | end | ||
Line 43: | Line 50: | ||
end | end | ||
− | loopMeNot(cf, 10, 1000) -- init loop, link action function, specfify loop amount & delay between loops | + | loopMeNot(cf, 10, 1000) -- init loop, link action function, specfify loop amount & delay between loops in milliseconds |
+ | </syntaxhighlight> | ||
+ | |||
+ | |||
+ | == Version 2: Disposable Looping Function == | ||
+ | |||
+ | This version requires a new function to be written for each set of lines of code that you want to loop a specific amount of times. | ||
+ | |||
+ | === Instructions === | ||
+ | |||
+ | 1. Add this script into the script section of the Visionaire Studio editor & set as a defintion type script... | ||
+ | <hr> | ||
+ | <syntaxhighlight lang="lua"> | ||
+ | --[[ | ||
+ | Loop Me Not (disposable) [v1] (29/08/2022) | ||
+ | Written by AFRLme [Lee Clarke] | ||
+ | -- + -- | ||
+ | email: afrlme@outlook.com | ||
+ | paypal: afrlme@zoho.com | ||
+ | patreon: https://www.patreon.com/AFRLme | ||
+ | portfolio: https://afrl.me | ||
+ | -- + -- | ||
+ | This script is donation optional. In game credit is non-negotiable. | ||
+ | You are free to: ¹ use it in your game(s). ² modify the script. | ||
+ | Do not remove - or edit - this comment block. | ||
+ | --]] | ||
+ | |||
+ | function loopMeNot(inc, delay) | ||
+ | if inc > 0 then | ||
+ | local n = math.random(10) -- generate random number up to a max value of 10 | ||
+ | print(n < 5 and "goodbye world!" or "hello world!") -- print "hello world!" if n >= 5, or "goodbye world!" if n < 5 | ||
+ | -- + -- | ||
+ | inc = inc - 1 -- decrement inc variable by 1 | ||
+ | setDelay(delay, function() loopMeNot(inc, delay) end) -- recall function after x delay | ||
+ | end | ||
+ | end | ||
+ | </syntaxhighlight> | ||
+ | <hr> | ||
+ | 2. To use this script you need to create an '''execute a script''' action part somewhere & then insert some code that looks like something along the lines of this... | ||
+ | <hr> | ||
+ | <syntaxhighlight lang="lua"> | ||
+ | loopMeNot(10, 1000) -- init loop, specfify loop amount & delay between loops in milliseconds | ||
</syntaxhighlight> | </syntaxhighlight> | ||
Latest revision as of 13:56, 15 September 2022
Name | Type | By |
---|---|---|
Loop Me Not | Definition | AFRLme |
They loop me, they loop me not. Small script that demonstrates how to create a looping function that loops the function a specific amount of times with delay between each loop. Visionaire Studio 5+ is required to run this script.
Version 1: Reusable Looping Function
This version can be reused multiple times as we are calling a function stored in a variable that contains the lines of code that we want to execute each time the function is looped.
Instructions
1. Add this script into the script section of the Visionaire Studio editor & set as a defintion type script...
--[[
Loop Me Not (reusable) [v1] (29/08/2022)
Written by AFRLme [Lee Clarke]
-- + --
email: afrlme@outlook.com
paypal: afrlme@zoho.com
patreon: https://www.patreon.com/AFRLme
portfolio: https://afrl.me
-- + --
This script is donation optional. In game credit is non-negotiable.
You are free to: ¹ use it in your game(s). ² modify the script.
Do not remove - or edit - this comment block.
--]]
function loopMeNot(act, inc, delay)
if inc > 0 then
act() -- execute code
-- + --
inc = inc - 1 -- decrement inc variable by 1
setDelay(delay, function() loopMeNot(act, inc, delay) end) -- recall function after x delay
end
end
2. To use this script you need to create an execute a script action part somewhere & then insert some code that looks like something along the lines of this...
cf = function() -- lines of code we want to execute in the loop
local n = math.random(10) -- generate random number up to a max value of 10
print(n < 5 and "goodbye world!" or "hello world!") -- print "hello world!" if n >= 5, or "goodbye world!" if n < 5
end
loopMeNot(cf, 10, 1000) -- init loop, link action function, specfify loop amount & delay between loops in milliseconds
Version 2: Disposable Looping Function
This version requires a new function to be written for each set of lines of code that you want to loop a specific amount of times.
Instructions
1. Add this script into the script section of the Visionaire Studio editor & set as a defintion type script...
--[[
Loop Me Not (disposable) [v1] (29/08/2022)
Written by AFRLme [Lee Clarke]
-- + --
email: afrlme@outlook.com
paypal: afrlme@zoho.com
patreon: https://www.patreon.com/AFRLme
portfolio: https://afrl.me
-- + --
This script is donation optional. In game credit is non-negotiable.
You are free to: ¹ use it in your game(s). ² modify the script.
Do not remove - or edit - this comment block.
--]]
function loopMeNot(inc, delay)
if inc > 0 then
local n = math.random(10) -- generate random number up to a max value of 10
print(n < 5 and "goodbye world!" or "hello world!") -- print "hello world!" if n >= 5, or "goodbye world!" if n < 5
-- + --
inc = inc - 1 -- decrement inc variable by 1
setDelay(delay, function() loopMeNot(inc, delay) end) -- recall function after x delay
end
end
2. To use this script you need to create an execute a script action part somewhere & then insert some code that looks like something along the lines of this...
loopMeNot(10, 1000) -- init loop, specfify loop amount & delay between loops in milliseconds
Resources
Name | Description |
---|---|
N/A | Sorry, there is no ved & resources available for this script example. |