Loop Me Not (CMS)
From The Official Visionaire Studio: Adventure Game Engine Wiki
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.
Instructions
1. Add this script into the script section of the Visionaire Studio editor & set as a defintion type script...
--[[
Loop Me Not [v1] (29/08/2022)
Written by AFRLme [Lee Clarke]
-- + --
afrlme@outlook.com | 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)
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
Resources
Name | Description |
---|---|
N/A | Sorry, there is no ved & resources available for this script example. |