Skip to content
GitLab
Explorer
Connexion
Navigation principale
Rechercher ou aller à…
Projet
Vivy
Gestion
Activité
Membres
Labels
Programmation
Tickets
Tableaux des tickets
Jalons
Wiki
Wiki externe
Code
Requêtes de fusion
Dépôt
Branches
Validations
Étiquettes
Graphe du dépôt
Comparer les révisions
Compilation
Pipelines
Jobs
Planifications de pipeline
Artéfacts
Aide
Aide
Support
Documentation de GitLab
Comparer les forfaits GitLab
Forum de la communauté GitLab
Contribuer à GitLab
Donner votre avis
Raccourcis clavier
?
Extraits de code
Groupes
Projets
Afficher davantage de fils d'Ariane
Elliu
Vivy
Validations
75ab8260
Vérifiée
Valider
75ab8260
rédigé
5 août 2021
par
Kubat
Parcourir les fichiers
Options
Téléchargements
Correctifs
Plain Diff
SCRIPT: Update specification
parent
5804d09d
Aucune branche associée trouvée
Aucune étiquette associée trouvée
1 requête de fusion
!16
Add a way to execute a Lua file with Vivy in a click-click way
Modifications
2
Afficher les modifications d'espaces
En ligne
Côte à côte
Affichage de
2 fichiers modifiés
utils/lua/sample-spec.lua
+9
-52
9 ajouts, 52 suppressions
utils/lua/sample-spec.lua
utils/lua/sample-spec.spek
+24
-31
24 ajouts, 31 suppressions
utils/lua/sample-spec.spek
avec
33 ajouts
et
83 suppressions
utils/lua/sample-spec.lua
+
9
−
52
Voir le fichier @
75ab8260
--[[
Sample script to have a Vivy script specification. Note that all things in
a script should be "local" or you won't be saved if you break something
else in Vivy...
-- vim: ft=lua
local
global
=
Vivy
:
global
{
}
local
script
=
Vivy
:
script
{
"sample-spec"
}
local
utils
=
Vivy
:
import
{
"utils"
}
local
prettyPrint
=
Vivy
:
import
{
"utils"
,
"prettyPrint"
}
Get the global variables from the Vivy runtime, like the video dimensions
or duration, etc.
local global = Vivy:global()
Get other script, here the util script. You can pass an author in case of
ambiguity. The standard scripts are available under the "std" author, thus
you can't register scripts in the name of "std". If there is ambiguity, an
error will be displayed by Vivy. If the tuple (script, author, revision) is
not unique, you will get an error on register time.
local utils = Vivy:getScript { script = "utils", author = "std" }
Create a new script. All the options and other stuff is defined in the
`.spek` file.
local script = Vivy:newScript {
name = "sample_script", author = "Vivy", revision = "rev-1254"
}
A local function to the script may be used by another script with the
"Vivy:getScript" function call.
All job functions take as first parameter the opt structure. This is really
usefull when calling multiple scripts on the same Vivy document with a
document defined options. The type of the option structure is checked by
Vivy according to the `.spek` file.
]]
local
global
=
Vivy
:
global
()
local
utils
=
Vivy
:
getScript
{
script
=
"utils"
,
author
=
"std"
}
local
script
=
Vivy
:
newScript
{
name
=
"sample_script"
,
author
=
"Vivy"
,
revision
=
"rev-1254"
,
}
Vivy
:
newFunction
(
"tripleCopySyl"
,
function
(
syl
)
local
tripleCopySyl
=
Vivy
:
newFunction
(
"tripleCopySyl"
,
function
(
syl
)
return
{
syl
:
copy
(),
syl
:
copy
(),
syl
:
copy
()
}
end
)
Vivy
:
newFunction
(
"printFoo"
,
function
()
print
"Bar"
end
)
Vivy
:
newFunction
(
"printFoo"
,
function
()
print
"Bar"
end
)
Vivy
:
newJob
(
"retime_lines"
,
Iterable
.
LINE
,
function
(
opt
,
line
)
line
.
start
+=
opt
.
preTime
line
.
finish
+=
opt
.
postTime
if
line
.
start
<=
0
then
line
.
start
=
0
;
end
if
line
.
start
<=
0
then
line
.
start
=
0
end
if
line
.
finish
>=
global
.
finish
()
then
line
.
finish
=
global
.
finish
()
end
return
line
end
)
Vivy
:
newJob
(
"create_syllabes"
,
Iterable
.
SYLLABE
,
function
(
opt
,
syl
)
local
newSyls
=
tripleCopySyl
(
syl
)
newSyls
[
1
].
start
=
syl
.
line
.
start
newSyls
[
1
].
finish
=
syl
.
start
newSyls
[
3
].
finish
=
syl
.
line
.
finish
newSyls
[
3
].
start
=
syl
.
finish
-- You can return a table, the runtime will unroll it and add all the
-- elements to the new ASS AST.
return
newSyls
end
)
-- Register the script.
Vivy
:
registerScript
(
script
)
Ce diff est replié.
Cliquez pour l'agrandir.
utils/lua/sample-spec.spek
+
24
−
31
Voir le fichier @
75ab8260
-- The name and description of the script. Spaces and column `:` characters in
-- the script name are illegal. Comments begin by `--`.
|> sample-spec
#(Sample script use for the specification)
-- Set some usefull informations
file <- sample-spec.lua
author <- Vivy
revision <- rev-1254
-- Register option tipes
#{custom-opt}
optin1 : boolean -> false
#{time-opt}
preTime : integer -> -900
postTime : integer -> 300
#{color-opt}
color1 : color -> Vivy:newColor("#314159")
-- Register used job functions. Here the `sample-spec:` is implied.
@set_retime#{time-opt}
@demultiply_syllabes
@utils:color_after_read_3#{color-opt}
-- Here we have the free functions defined in the script, a comma-separated
-- list, thus comma and spaces and brackets in function names are not allowed.
#[tripleCopySyl, printFoo]
-- vim: ft=
-- vim: ft=lua
DeclareScript
{
name
=
[[ sample-spec ]]
,
description
=
[[ Sample script used for the specification proposition ]]
,
file
=
[[ sample-spec.lua ]]
,
author
=
[[ Vivy ]]
,
revision
=
[[ rev-1254 ]]
,
imports
=
{
"utils"
},
options
=
{
"custom-opt"
=
{
option1
=
false
},
"time-opt"
=
{
preTime
=
-
900
,
postTime
=
300
,
},
"color-opt"
=
{
color1
=
Vivy
:
newColor
(
"#314159"
)
}
},
functions
=
{
DeclareFunctopn
{
name
=
"tripleCopySyl"
},
DeclareFunction
{
name
=
"printFoo"
},
ImportFunction
{
name
=
"prettyPrint"
,
script
=
"utils"
},
},
jobs
=
{
DeclareJob
{
name
=
"set_retime"
,
options
=
{
"time-opt"
}
},
DeclareJob
{
name
=
"demultiply_syllabes"
},
ImportJob
{
name
=
"color_after_read_3"
,
script
=
"utils"
,
options
=
{
"color-opt"
}
}
}
}
Ce diff est replié.
Cliquez pour l'agrandir.
Aperçu
0%
Chargement en cours
Veuillez réessayer
ou
joindre un nouveau fichier
.
Annuler
You are about to add
0
people
to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Enregistrer le commentaire
Annuler
Veuillez vous
inscrire
ou vous
se connecter
pour commenter