diff --git a/Docs/Luadoc/Lua.xsl b/Docs/Luadoc/Lua.xsl index 73b9875d2c..a7cf0ea501 100644 --- a/Docs/Luadoc/Lua.xsl +++ b/Docs/Luadoc/Lua.xsl @@ -204,7 +204,7 @@ } } - +
c's R, G, and B values by fBoost.
@@ -85,7 +85,8 @@ save yourself some time, copy this for undocumented things:
[02 Colors.lua] Modifies the brightness of the specified color.
true if Center 1P is being used.
+ [02 Utilities.lua] Returns true if the Center1Player preference is enabled during single style. Returns true when the style is double or routine, regardless of the Center1Player preference.false otherwise.
true if checkpoint judgments and tap judgments
@@ -162,7 +163,7 @@ save yourself some time, copy this for undocumented things:
Creates a RageBezier2D for you to use. Make sure you destroy the RageBezier2D when you're done with it, or you will have a memory leak.
dofile is normally a core function of Lua's basic library. StepMania overrides this in
- [01 base.lua] to use loadfile, which itself has been overridden.
+ [01 base.lua] to use loadfile, which itself has been overridden.
ipairs is a core function of Lua's basic library; see the Lua manual for more details.
true if the coin mode is not set to CoinMode_Home.
true if the current is Nonstop, Oni, or Endless.true if IsArcade() and the coin mode is CoinMode_Free.
true if the current game is sGame.
true if the coin mode is set to CoinMode_Home.
loadfile is normally a core function of Lua's basic library. StepMania overrides this in
- [01 base.lua] to use lua.ReadFile.
+ [01 base.lua] to use lua.ReadFile.
Enum.Enum.GetName(PlayerNumber) and
- Enum.Reverse(PlayerNumber) can be used likePlayerNumber:GetName() and
- PlayerNumber:Reverse(), respectively.
+
+Enum.GetName(PlayerNumber)
+Enum.Reverse(PlayerNumber)
+
+ can be condensed like
+PlayerNumber:GetName()
+PlayerNumber:Reverse()
+
x and y need to be elements of the enumerated
@@ -913,12 +919,13 @@ local playable_steps = SongUtil.GetPlayableSteps(song)
Returns a reverse lookup table for the enumerated type e. For
example:
-local r = PlayerNumber:Reverse()
-local n = r['PlayerNumber_P2']
+local pn1 = PlayerNumber:Reverse()['PlayerNumber_P1']
+local pn2 = PlayerNumber:Reverse()['PlayerNumber_P2']
+-- pn1 is 0
+-- pn2 is 1
- The value of n in this case would be 1 corresponding
- to the 0-based indexing using in C++ and not 2 as might be
- expected for the 1-based indexing used in Lua.
+ Note that the values returned from Reverse() will correspond
+ to the 0-based indexing from C++ and not 1-based indexing conventional to Lua.
+local file = RageFileUtil.CreateRageFile()
+
zoom.
fRotation degrees.
cmds on the Actor's children, as well as the Actor itself.RunCommandsRecursively belongs to StepMania's base Actor class, it is available to all specialized actors. Calling it from an ActorFrame or ActorFrameTexture can be helpful, as those specialized actors can contain children actors.
+Def.ActorFrame{
+ Name="AF",
+
+ Def.Sprite{ Name="sun", Texture="sun.png" },
+
+ Def.ActorFrame{
+ Name="AF2",
+ InitCommand=function(self)
+ -- bounce() will be applied to AF2, airhorn, and catchphrase
+ self:RunCommandsRecursively( function(actor) actor:bounce() end )
+ end,
+
+ Def.Sprite{ Name="airhorn", Texture="airhorn.png" },
+ Def.BitmapText{ Name="catchphrase", Font="Common Normal", Text="Yo!" }
+ }
+}
+
+ fAlign which should be a float in the range 0..1. An alignment of 0 is top-aligned while an alignment of 1 is bottom-aligned.align.1).
--- in the context of a lua file as a screen layer
--- this ActorFrame is a table
+-- in the context of a .lua file as a screen layer
+-- this ActorFrame can be thought of as a Lua table
local af = Def.ActorFrame{}
-- add a Sprite at the next index
@@ -1665,7 +1699,7 @@ af[#af+1] = Def.BitmapText{
return af
When actor commands like and
- are used position and scale an ActorFrame, its children will position relative to the parent ActorFrame
+ are used to position and scale an ActorFrame, its children will position relative to the parent ActorFrame
and scale proportionally.visible(false) to it, its children
+ will stop drawing with it.cmds on the ActorFrame's children.
+ Runs the commands in cmds on the ActorFrame's immediate children.
+Def.ActorFrame{
+ Name="AF",
+ InitCommand=function(self)
+ -- bounce() will be applied to sun and AF2
+ self:RunCommandsOnChildren( function(child) child:bounce() end )
+ end,
+
+ Def.Sprite{ Name="sun", Texture="sun.png" },
+
+ Def.ActorFrame{
+ Name="AF2",
+ Def.Sprite{ Name="airhorn", Texture="airhorn.png" },
+ Def.BitmapText{ Name="catchphrase", Font="Common Normal", Text="Yo!" }
+ }
+}
+
cmds on the ActorFrame's leaves.
+ Runs the commands in cmds on the ActorFrame's leaves. Leaves are nodes in the ActorFrame tree that have no further child nodes.
+Def.ActorFrame{
+ Name="AF",
+ InitCommand=function(self)
+ -- bounce() will be applied to sun, airhorn, and catchphrase
+ self:runcommandsonleaves( function(leaf) leaf:bounce() end )
+ end,
+
+ Def.Sprite{ Name="sun", Texture="sun.png" },
+
+ Def.ActorFrame{
+ Name="AF2",
+ Def.Sprite{ Name="airhorn", Texture="airhorn.png" },
+ Def.BitmapText{ Name="catchphrase", Font="Common Normal", Text="Yo!" }
+ }
+}
+
c.
@@ -4763,11 +4837,11 @@ prev_note_name, succeeded = options:NoteSkin("cel")
Returns the profile for player pn.
/Save/LocalProfiles/00000001/./Save/LocalProfiles/00000001/.s has been played with the specified ProfileSlot.
+ Returns the number of times Song s has been played with the specified ProfileSlot.
event table:
This should behave identically to the normal back button behavior. This function is for the pause menu to use when the player forfeits or restarts, so that a score isn't saved.
true if a single has its NoteField centered.
+ Returns true if a single has its NoteField centered using the Center1Player preference.false if the current theme has AllowCenter1Player=false under [ScreenGameplay].false when the player's NoteField is visually centered, as is convention in double style or Techno_Single8.event table:
true if anyone is still entering their name.true if Player pn is entering their name.
@@ -6043,7 +6120,7 @@ local spr = Def.Sprite{
Returns true if any player has given up on the song.
PlayerNumber and Difficulty as arguments.
+ For example, accepts a and as arguments.
Each of these is valid way to set P1's preferred difficulty to hard:
-- using strings
@@ -6751,6 +6828,24 @@ GAMESTATE:SetPreferredDifficulty( "PlayerNumber_P1", "Difficulty_Hard" )
GAMESTATE:SetPreferredDifficulty( 0, 3 )
-- using global Lua tables
GAMESTATE:SetPreferredDifficulty( PlayerNumber[1], Difficulty[4] )
+
+ It's worth pointing out that, as tables, these enums can be iterated over using or . This can be handy when you want to perform some action on every value in an enum; for example, displaying a graphic for each Difficulty.
+
+-- Difficulty is a global Lua table that corresponds with
+-- the StepMania engine's Difficulty enum
+for i, diff in ipairs(Difficulty) do
+
+ -- append a file extension to create a string like
+ -- "Difficulty_Beginner.png"
+ local filename = diff .. ".png"
+
+ -- load files like "Difficulty_Beginner.png",
+ -- "Difficulty_Easy.png", etc. from the directory
+ -- where this code is run, and offset each vertically
+ af[#af+1] = LoadActor( filename )..{
+ InitCommand=function(self) self:y( i * 100 ) end
+ }
+end