Changes

Jump to navigation Jump to search
8,809 bytes added ,  14:05, 5 November 2019
the rest of the page
<code>Gu.clearColor, Gu.clearDepth, Gu.clear, Gum.matrixMode, Gum.loadIdentity, Gum.perspective, Gum.translate, Gum.rotateXYZ, Gu.texImage, Gu.texFunc, Gu.texEnvColor, Gu.texFilter, Gu.texScale, Gu.texOffset, Gu.ambientColor, Gu.enable, Gu.disable, Gu.blendFunc, Gu.light, Gu.lightAtt, Gu.lightColor, Gu.lightMode, Gu.lightSpot and Gum.drawArray</code>. See the PSPSDK for documenation about the parameters, for example pspgu.h. If there is a <code>ScePspFVector3</code>, write 3 numbers instead one parameter (this will be changed in a later version). Whereever a color is expected, use a <code>Color</code> object. For textures use an <code>Image</code> object.
<code>Gum.drawArray</code> is something special: It has just 3 parameters: "prim", "vtype" and a table. With "prim" you specify which primitive should be used, for example <code>Gu.TRIANGLES</code>. "vtype" specifies the vertex format and the transformation operation. For example "<code>Gu.COLOR_8888|Gu.VERTEX_32BITF|Gu.TRANSFORM_3D" </code> means, that your vertices has a color component and a 3 vertex coordinate components and is transformed before passed to the rasterizer. The table is then a list of vertex entries, where each vertex entry has the form (color, x, y, z). If you have specified <code>GU_TEXTURE_32BITF</code>, too, then one entry looks like this: <code>(textureU, textureV, color, x, y, z)</code>. The order of the entries is defined in pspgu.h: textureU, textureV, color, normalX, normalY, normalZ, vertexX, vertexY, vertexZ. Indices, weights and multiple vertices per entry (which you’ll need for the morphing feature) currently are not supported.
After drawing anything, call <code>Gu.end3d()</code>, which flushs the display buffer and draws all pending 3D graphics and restores the 2D GE state. Don’t forget to call a <code>screen:clear()</code> before fullscreen 2D operations, because otherwise the z-buffer is not cleared and the blitting functions may not work correctly. If you need to blit 2D images in 3D mode, use textures and triangles.
Bool controls:note()</pre>
* <code>Number controls:analogX() -- ranges from -127 to 128</code> - Returns the current analog stick position in x direction.
Note: It's a good idea to ignore low values (perhaps -5<x, y<+5) for the analog stick, as its dead zone is larger than a single integer step.
* <code>Number controls:analogY() -- ranges from -127 to 128</code> - Returns the current analog stick position in y direction.
Note: It's a good idea to ignore low values (perhaps -5<x, y<+5) for the analog stick, as its dead zone is larger than a single integer step.
* <code>Bool (Controls a == Controls b) -- note! The analog stick is NOT considered when comparing because of analog fluctuations</code> - Compares two pad states.
* <code>Number controls:buttons() -- returns the bitmask like sceCtrlReadBufferPositive reads it</code> - Constants for binary operations on buttons() result (for example "Controls.read():buttons() & Controls.startMask > 0" is the same as "Controls.read():start()")
* <code>Number Timer:stop()</code> - Stops the timer. Returns the current time(). Subsequent time() calls returns the value when stopped. If the timer is stopped, this call is the same as time().
* <code>Number Timer:reset([startTime])</code> - Resets the timer to 0 by default or startTime in milliseconds and holds the timer. Returns the time before resetted to the new value.
 
=== System ===
* <code>String System.currentDirectory() -- get</code> - Gets the current working directory.
* <code>String System.currentDirectory( path ) -- set, returns old path</code> - Sets the current working directory.
* <code>table System.listDirectory( [path] )</code> - Lists the contents of the current working directory or the specified path. The result is a table of tables, where each table-entry has the string entry "name", the number entry "size" and the boolean entry "directory", which is set to true, when the current entry is a directory. See for example this code to print all files in the current working directory:
<pre>files = System.listDirectory()
for index, file in files do
print(file.name)
end</pre>
* <code>nil System.createDirectory(path)</code> - Creates a new directory. The path is relative to the current directory, if not absolute.
* <code>nil System.removeDirectory(path)</code> - Deletes a directory. The path is relative to the current directory, if not absolute.
* <code>nil System.rename(oldName, newName)</code> - Renames files and directories. The path is relative to the current directory, if not absolute.
* <code>nil System.removeFile(path)</code> - Deletes a file. The path is relative to the current directory, if not absolute.
* <code>nil System.usbDiskModeActivate()</code> - Activates the USB mode. Attention: When writing from USB to the memory stick, you must not write from within your Lua script to the memory stick, until you disable USB, otherwise the filesystem of your memory stick gets corrupted and you have to reformat your memmory stick.
* <code>nil System.usbDiskModeDeactivate()</code> - Deactivates the USB mode.
 
==== Battery ====
* <code>Bool System.powerIsPowerOnline()</code>
* <code>Bool System.powerIsBatteryExist()</code>
* <code>Bool System.powerIsBatteryCharging()</code>
* <code>Number System.powerGetBatteryChargingStatus()</code>
* <code>Bool System.powerIsLowBattery()</code>
* <code>Number System.powerGetBatteryLifePercent()</code>
* <code>Number System.powerGetBatteryLifeTime()</code>
* <code>Number System.powerGetBatteryTemp()</code>
* <code>Number System.powerGetBatteryVolt()</code>
* <code>Number System.powerTick()</code> - When called, it resets the internal power off counter, which prevents auto power off.
* <code>String System.md5sum(String)</code> - Calculates the md5sum of a string. For example print(System.md5sum(io.input("EBOOT.PBP"):read("*a"))) prints the same digest as "md5sum EBOOT.PBP" on Unix.
* <code>number System.getFreeMemory()</code> - Gets the available free memory. You can use it like this:
<pre>print("about " .. System.getFreeMemory() / 1024 / 1024 .. " megabytes free memory available")</pre>
 
==== Serial Input/Output ====
* <code>nil System.sioInit(baudrate)</code> - Opens the SIO device and sets the baud rate. This needs some seconds to power up the UART.
* <code>System.sioWrite(string)</code> - Writes the string to the SIO
* <code>string System.sioRead()</code> - Reads all available data from the SIO. Returns an empty string, if no data was received.
* <code>System.sleep(number)</code> - Pauses program execution for the specified time in milliseconds. It doesn’t affect any timer object.
 
==== IrDA ====
* <code>nil System.irdaInit()</code> - Opens the IrDA device. Call this to start the IrDA module.
* <code>System.irdaWrite(string)</code> - Writes the string to the IrDA port.
* <code>string System.irdaRead()</code> - Reads all available data from the IrDA port. Returns an empty string, if no data was received.
 
=== Sound and Music ===
* <code>nil Music.playFile( string file, bool loop )</code> - Plays a music in one of the following formats: UNI, IT, XM, S3M, MOD, MTM, STM, DSM, MED, FAR, ULT or 669.
Note: It's possible to tell mikmod to loop only a part of a sample, or loop backwards, or loop back and forth.
* <code>nil Music.pause()</code>
* <code>nil Music.resume()</code>
* <code>nil Music.stop()</code>
* <code>bool Music.playing()</code>
* <code>Number Music.volume( [number {0-128}] )</code>
* <code>nil SoundSystem.SFXVolume( number {0-128} )</code>
* <code>nil SoundSystem.reverb( number {0-15} )</code>
* <code>nil SoundSystem.panoramicSeparation( number {0-128} )</code>
* <code>Sound Sound.load(filename, [bool loop])</code>
* <code>Voice sound:play()</code>
* <code>nil voice:stop()</code>
* <code>nil voice:resume(Sound) -- DISABLED due to bug. </code>
* <code>nil voice:volume( number [0-255] )</code>
* <code>nil voice:pan( number [0-255] )</code>
* <code>nil voice:frequency( number [1-80000] )</code>
* <code>bool voice:playing()</code>
 
=== WLAN ===
* <code>Wlan.init()</code> - Must be called once at program start to initialize the WLAN module.
* <code>nil Wlan.term()</code> - Unloads the WLAN module.
* <code>array Wlan.getConnectionConfigs()</code> - Gets the available WiFi connection configurations.
* <code>Wlan.useConnectionConfig(number)</code> - Selects the connection configuration. The number is the index in the array that is returned by Wlan.getConnectionConfigs (e.g. use 1 for the first configuration).
* <code>string Wlan.getIPAddress()</code> - Gets the IP address of the PSP.
* <code>Socket Socket.connect(host, port)</code> - Creates a new TCP/IP Socket object and starts the connection process to the specified host and port. All sockets are non-blocking.
Note: <code>Socket.connect()</code> actually returns two values according to the samples, the first is Socket as above, there is also an error number returned (elaborate on this?)
 
An example of this would be as follows:
 
<pre>socket, error = Socket.connect("www.server.com", 80)</pre>
 
You could then test the "error" variable to see what the error code is, if any.
* <code>bool Socket:isConnected()</code> - Returns true, when the connection is established. Now recv and send can be called on this socket object.
* <code>Socket Socket:createServerSocket(port)</code> - Creates a server socket, which listens on the specified port for incoming connections.
* <code>Socket Socket:accept()</code> - Can be called for server sockets and returns a new incoming connection socket or nil, if no incoming connection is waiting.
* <code>string Socket:recv()</code> - Reads and returns all available data from the socket or returns an empty string, if no data is available.
* <code>number Socket:send(string)</code> - Sends a string. The result is the number of bytes which was sent (which can be less than the length of the string) or less than 0, if an error occured.
* <code>nil Socket:close()</code> - Closes a socket.
 
=== Netlib 2.0 ===
* <code>Socket Socket.udpConnect(host,port)</code> - Creates a new UDP Socket object and starts the connection process to the specified host and port. All sockets are non-blocking.
* <code>number udpSocket:udpSend(string)</code> - Sends a string through UDP. The result is the number of bytes which was sent (which can be less than the length of the string) or less than 0, if an error occured.
* <code>nil udpSocket:close()</code> - Closes an UDP socket
* <code>String udpSocket:recv()</code> - Reads and returns all available data from the socket or returns an empty string, if no data is available.
* <code>nil netconnect()</code> - Connects to the standard netlib UDP server for netlib 2.0 unless modified
* <code>nil netclose()</code> - Closes the connection to any UDP socket
* <code>nil netsend(id, data, attribute)</code> - Send the specified data to the ID file on the server using the following attribue (w or a for write or append) using UDP.
* <code>nil netget(id)</code> - Gets the contents of the ID file on the server using UDP.
* <code>nil netreg(id)</code> - Tells the server to resend the info of the ID whenever changed
* <code>nil netunreg(id)</code> - Tells the server to stop sending info to the client, even if it is changed.
* <code>nil netrecv()</code> - Recieves data from the server (normally the netlib one) and sorts the data accordingly.
* <code>nil netvalue(id)</code> - Returns the value of the given ID
* <code>nil netmail(to,from,subject,message)</code> - Sends an email to "to" from "from" with the subject of "subject" and the message of "message"
* <code>nil netcall(contact, destination)</code> - Sets up a call between the contact and destination
* <code>nil netsms(to,message,from)</code> - Sends a text message to "to" from "from" with the message of "message". Alternatively, for certain phones, you can send an email to their phone number at a special website. For Verizon, it is @vtext.com

Navigation menu