Difference between revisions of "love.bundle"

(Initial Version)
 
(<source> rather than some table. Much better, no?)
Line 15: Line 15:
  
 
Those 4 different types of values can easily be put into a created bundle or read from one with this:
 
Those 4 different types of values can easily be put into a created bundle or read from one with this:
{| cellpadding='3'
+
<source lang="Lua">Bundle = love.bundle.newBundle("A Bundle Name") --Creates a bundle with the given name/identifier
|-
+
Bundle:setIdentity("Another Bundle Name") --Changes the identity of the bundle
|style="border: 0px solid; background-color: #acd;"|
+
Bundle:save() --Saves the bundle to the saving directory
Bundle = love.bundle.newBundle("A Bundle Name") --Creates a bundle with the given name/identifier
+
Bundle = love.bundle.loadBundle("Another Bundle Name") --Loads a saved bundle with that name if it exists
Bundle:setIdentity("Another Bundle Name") --Changes the identity of the bundle
+
love.bundle.setExitFunction(aFunction) --Sets aFunction to be called when someone exits the game
Bundle:save() --Saves the bundle to the saving directory
+
success = Bundle:put("Name Of The Value", 42) --Returns if the operation succeeded or not
Bundle = love.bundle.loadBundle("Another Bundle Name") --Loads a saved bundle with that name if it exists
+
var = Bundle:get("Name Of The Value") --Returns the value with that name, or nil if not found
love.bundle.setExitFunction(aFunction) --Sets aFunction to be called when someone exits the game
+
var = Bundle:get("Name Of A Not Created Value", true) --Returns the value with that name, or the 2nd argument if not found</source>
success = Bundle:put("Name Of The Value", 42) --Returns if the operation succeeded or not
 
var = Bundle:get("Name Of The Value") --Returns the value with that name, or nil if not found
 
var = Bundle:get("Name Of A Not Created Value", true) --Returns the value with that name, or the 2nd argument if not found
 
|-
 
|}
 
  
 
To understand this more, you can download the documentation I have created which is just like the LÖVE Documentation one. It looks the same to make it easier to understand since you don't have to get used to a new type.
 
To understand this more, you can download the documentation I have created which is just like the LÖVE Documentation one. It looks the same to make it easier to understand since you don't have to get used to a new type.

Revision as of 13:43, 4 July 2010

love.bundle is a library for storing game data between sessions. Unlike the most used saving systems, you don't have to make your own converting algorithm for data to text and the opposite. Here all you have to do is putting your data in a created bundle, and save it. The library also features a function for setting a function to be called when the game exits, here the user can put stuff like saving their bundles. The bundle can store 4 types of values:

  • String
  • Number
  • Boolean
  • Nil

Those 4 different types of values can easily be put into a created bundle or read from one with this:

Bundle = love.bundle.newBundle("A Bundle Name") --Creates a bundle with the given name/identifier
Bundle:setIdentity("Another Bundle Name") --Changes the identity of the bundle
Bundle:save() --Saves the bundle to the saving directory
Bundle = love.bundle.loadBundle("Another Bundle Name") --Loads a saved bundle with that name if it exists
love.bundle.setExitFunction(aFunction) --Sets aFunction to be called when someone exits the game
success = Bundle:put("Name Of The Value", 42) --Returns if the operation succeeded or not
var = Bundle:get("Name Of The Value") --Returns the value with that name, or nil if not found
var = Bundle:get("Name Of A Not Created Value", true) --Returns the value with that name, or the 2nd argument if not found

To understand this more, you can download the documentation I have created which is just like the LÖVE Documentation one. It looks the same to make it easier to understand since you don't have to get used to a new type.