This repository was archived by the owner on Jan 4, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 120
api read all metadata
Jesse Freeman edited this page Nov 11, 2021
·
1 revision
The ReadAllMetadata() API allows you to get a copy of all metadata values that were passed into the game when it loaded. This is useful if you do not know the exact key you are looking for and need to iterate through them until you find the one you need. There could be a lot of values in the game’s metadata so keep this in mind before trying to iterate over them all.
ReadMetaData ( key, defaultValue )| Value | Description |
|---|---|
| Dictionary<string, string> | Returns a copy of the metadata dictionary that was passed into the currently loaded game. |
In this example, we are going to iterate over all of the game’s metadata keys and output what we can to the display. Running this code will output the following:
![]()
function Init()
-- Example Title
DrawText("ReadAllMetadata()", 8, 8, DrawMode.TilemapCache, "large", 15)
DrawText("Lua Example", 8, 16, DrawMode.TilemapCache, "medium", 15, -4)
-- Set up the values we'll use to keep track of the metadata
local nextRow = 3
local maxRows = 26
local counter = 0
local metadata = ReadAllMetadata()
-- Iterate over the game's metadata
for key, value in next, metadata do
-- We only display a key/value pair if there is space on the display
if(nextRow < maxRows ) then
-- Draw the key value pair from the game's metadata
DrawText(key .. ":", 8, nextRow * 8 + 24, DrawMode.TilemapCache, "large", 6)
DrawText(value, (2 + #key) * 8, nextRow * 8 + 24, DrawMode.TilemapCache, "large", 14)
-- Increment the row by 1 for the next loop
nextRow = nextRow + 1
end
-- Keep track of the total amount of metadata keys
counter = counter + 1
end
-- Display the amount displayed and the total in the game's metadata
DrawText("Showing " .. (nextRow - 3) .." of " .. counter .. " Metadata Keys", 8, 32, DrawMode.TilemapCache, "large", 15)
end
function Draw()
-- Redraw the display
RedrawDisplay()
endnamespace PixelVision8.Player
{
class ReadAllMetadataExample : GameChip
{
public override void Init()
{
// Example Title
DrawText("ReadAllMetadata()", 8, 8, DrawMode.TilemapCache, "large", 15);
DrawText("C Sharp Example", 8, 16, DrawMode.TilemapCache, "medium", 15, -4);
// Set up the values we'll use to keep track of the metadata
var nextRow = 3;
var maxRows = 25;
var counter = 0;
var metadata = ReadAllMetadata();
// Iterate over the game's metadata
foreach (var data in metadata)
{
// We only display a key/value pair if there is space on the display
if (nextRow < maxRows)
{
// Draw the key value pair from the game's metadata
DrawText(data.Key + ":", 8, nextRow * 8 + 24, DrawMode.TilemapCache, "large", 6);
DrawText(data.Value, (2 + data.Key.Length) * 8 , nextRow * 8 + 24, DrawMode.TilemapCache, "large", 14);
// Increment the row by 1 for the next loop
nextRow++;
}
// Keep track of the total amount of metadata keys
counter++;
}
// Display the amount displayed and the total in the game's metadata
DrawText("Showing " + (nextRow - 3) + " of " + counter + " Metadata Keys", 8, 32, DrawMode.TilemapCache,
"large", 15);
}
public override void Draw()
{
// Redraw the display
RedrawDisplay();
}
}
}- Game Project
- Lua Games (coming soon)
- C# Sharp Games
- C# Sharp Vs Lua
- API Cheat Sheet
- Enums
- Visual Studio Code
- Atom
- Tiled (Coming Soon)
- Aseprite (Coming Soon)
- AddScript
- BackgroundColor
- Button
- CalculateDistance
- CalculateIndex
- CalculatePosition
- CharacterToPixelData
- Clamp
- Clear
- Color
- ColorsPerSprite
- Display
- DrawMetaSprite
- DrawPixels
- DrawRect
- DrawSprite
- DrawText
- DrawTilemap
- Flag
- InputString
- IsChannelPlaying
- Key
- LoadTilemap
- MaxSpriteCount
- MouseButton
- MousePosition
- NewCanvas
- NewPoint
- NewRect
- PaletteOffset
- PauseSong
- PlaySong
- PlaySound
- ReadAllMetadata
- ReadMetadata
- ReadSaveData
- RedrawDisplay
- Repeat
- ReplaceColor
- RewindSong
- ScrollPosition
- SongData
- Sound
- SplitLines
- SpriteSize
- Sprite
- StopSong
- StopSound
- Tile
- TilemapSize
- TotalColors
- TotalSprites
- UpdateTiles
- WordWrap
- WriteSaveData