ReadIniFloat

From Liberty Unleashed Wiki
Revision as of 10:27, 11 October 2010 by VRocker (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
Home   |   Squirrel Scripting   |   Server Functions   |   Server Events   |   Client Functions   |   Client Events
Note: This function requires the external module lu_ini.

This function reads a float value from an .ini file.

Syntax

  1. float ReadIniFloat( string filename, string section, string var )

Arguments

  • filename This is the name of the file
  • section The section that contains the value you want to read
  • var The name of the variable

Example

This example will teleport the player to a previously saved location when they type '/gotoloc LocationName'.

  1.  
  2. function onPlayerCommand( player, command, text )
  3. {
  4. local x = ReadIniFloat( "Locations.ini", text, "x" ),
  5. y = ReadIniFloat( "Locations.ini", text, "y" ),
  6. z = ReadIniFloat( "Locations.ini", text, "z" );
  7.  
  8. if ( x && y && z )
  9. {
  10. local pos = Vector( x, y, z );
  11. player.Pos = pos;
  12.  
  13. MessagePlayer( "Teleporting to " + text + "...", player );
  14. }
  15.  
  16. else MessagePlayer( "Location " + text + " not found.", player );
  17. }
  18.  

Notes

The functions Player.Pos, MessagePlayer and call onPlayerCommand were also used in in this example. More info about them in corresponding pages.

Related Functions

These functions are provided by the official module lu_ini.

Personal tools
Namespaces

Variants
Actions
Navigation
scripting
Toolbox