DSLua Community
Welcome, Guest. Please login or register.
February 05, 2012, 08:46:45 AM
1371 Posts in 262 Topics by 33109 Members
Latest Member: Limewire Download
DSLua Community  |  DSLua - Best scripting language for Nintendo DS  |  Examples/Tutorials  |  Using DSLua with PHP « previous next »
Pages: [1]
Author Topic: Using DSLua with PHP  (Read 5096 times)
Jeremysr
First Quarter
***
Posts: 215



WWW
« on: January 22, 2007, 05:34:53 PM »

I found out how to use Wifi to pass variables to .php scripts on the internet. You can just put them in the URL. Here are the programs I made.

dslua_php.lua:

Code:
require( "keyboard.inc.lua" )

SCREEN_TOP = 1
SCREEN_BOTTOM = 0

BGTopText = Screen.LoadTextBG()
Screen.Initialize( SCREEN_TOP, BGTopText )

BGTopText:PrintXY( 0, 0, "Connecting to WFC..." )
Wifi.ConnectWFC()
BGTopText:Clear()

function ReceiveMessage()
BGTopText:Clear()
receive_message = ""
Wifi.GetHTTP( "http://www.bio-gaming.com/dslua.php", receive_message )
BGTopText:PrintXY( 0, 0, receive_message )
end

function SendMessage( msg )
msg = string.gsub( msg, " ", "." )
unusedvariable = ""
Wifi.GetHTTP( "http://www.bio-gaming.com/dslua.php?msg=" .. msg, unusedvariable )
ReceiveMessage()
end

while Pads.Start() == false do
BGTopText:PrintXY( 0, 23, "A - Send             B - Receive" )
if Pads.A() then
while Pads.A() do end
msg = keyboard()
SendMessage( msg )
end
if Pads.B() then
while Pads.B() do end
ReceiveMessage()
end
end

dslua.php :

Code:
<?php

if (isset($_GET['msg'])) {
$file fopen("dslua.txt""w");
fwrite($filestr_replace("."" "$_GET['msg']));
} else {
$file fopen("dslua.txt""r");
$message fgets($file);
echo ($message);
}

?>


It stores the text in dslua.txt on my site. You can send and receive messages (each time overwriting dslua.txt) using the lua program, or using your web browser (type "bio-gaming.com/dslua.php" to see the current message or "bio-gaming.com/dslua.php?msg=insert.message.here" to send a message.) BTW spaces don't seem to work yet so don't use them! Edit: Fixed the spaces!

Oh and you'll need to download keyboard and put it in the same directory as the lua script for it to work: http://www.bio-gaming.com/jeremy/dslua/index.php?act=keyboard
« Last Edit: January 24, 2007, 12:16:03 PM by Jeremysr » Logged
daltonlaffs
First Quarter
***
Posts: 189


Freaking Insane


WWW
« Reply #1 on: January 23, 2007, 06:32:15 PM »

Nice discovery, Jeremysr. This makes a PHP editor possible! *pokes sypherce about keyboard again*

Aaanyway, I have found a way to add spaces. Use the %20 tag as a space. Like this:

http://bio-gaming.com/dslua.php?msg=space>%20lol!

I'm gonna put this on my php hoster (4000mb) and try it on another php!

NICE DISCOVERY!
Logged

Code:
-- Bored? Read code line below.
-- Bored? Read code line above.



^^ That works, I SWEAR! ^^
Jeremysr
First Quarter
***
Posts: 215



WWW
« Reply #2 on: January 23, 2007, 06:38:50 PM »

I know about the %20 but it doesn't seem to work with the Wifi.GetHTTP() function. A solution would be to change all the spaces into "."'s or something before sending, then with the PHP change the "."'s into spaces before displaying. I'll try it. *edits the scripts in first post*

Quote
Nice discovery, Jeremysr. This makes a PHP editor possible! *pokes sypherce about keyboard again*

I've already added a keyboard to DSLua 0.7 Smiley (I just have to find out how to make it work when it's on top of other backgrounds. Right now it only works when there isn't anything else being displayed on the bottoms screen.)
Logged
Salz`
New Moon
*
Posts: 1


« Reply #3 on: June 19, 2008, 07:23:37 PM »

Just use "+" instead of %20.
Logged
Pages: [1]
« previous next »
    Jump to: