WLAN Multiplayer?

Discuss using and improving Lua and the Lua Player specific to the PSP.

Moderators: Shine, Insert_witty_name

Kakolukia
Posts: 21
Joined: Sun Jun 11, 2006 8:43 pm

WLAN Multiplayer?

Post by Kakolukia »

I made a little game, with multiplayer, by using irda,
but if I could use WLAN it would be much better...
so, if anyone could tell how the WLAN works, or even better, make something like the irda sample but WLAN based, I would be really happy.

Does anyone have enough sparetime to help me out?
thanx, Kakolukia
Altair
Posts: 76
Joined: Sat May 20, 2006 2:33 am
Location: The Netherlands

Post by Altair »

There is a WLAN example in the "Application" folder of LUAplayer itself. And there is no ad-hoc wlan yet for LUAplayer.
Kakolukia
Posts: 21
Joined: Sun Jun 11, 2006 8:43 pm

Post by Kakolukia »

well, i read this thread:
http://forums.ps2dev.org/viewtopic.php?t=2471
but i don't fully understand how to get 2 psps connecting to eachother.
what do I need te set as settings in the infrastructuremode?
and how can i get lua to send codes like the irda codes using wifi?
maybe i totally misunderstood it, and is it impossible, but if anyone could help me out...
be2003
Posts: 144
Joined: Thu Apr 20, 2006 2:46 pm

Re: WLAN Multiplayer?

Post by be2003 »

Kakolukia wrote:I made a little game, with multiplayer, by using irda,
but if I could use WLAN it would be much better...
so, if anyone could tell how the WLAN works, or even better, make something like the irda sample but WLAN based, I would be really happy.

Does anyone have enough sparetime to help me out?
thanx, Kakolukia
i started making what you are talking about, but it is very hard to do without adhoc support. so i am making a makeshift adhoc sample for you.
so far it is looking kind of good, um, it uses irda and wifi.

It's weird when you start the app you connect to a to a router(sorry had to use it) then you continue on to get your ip address and the ip address is sent to the other psp using irda(this is only done at the beginning of the app so that each psp knows the others ip). so this sample sets up a server and client at the same time. it is based off of the irda sample, you press x to send the "X" character to the other psp using a server/client method and vice-versa, sorry i can't post it today, but it will be up tomorrow, it's been hard sorting out the bugs and such... it should be useful to someone.
- be2003
blog
Kakolukia
Posts: 21
Joined: Sun Jun 11, 2006 8:43 pm

Post by Kakolukia »

wow, thats just great, thanx a lot!
wanna hug you for that ;)

But isnt it possible to set the ip manually instead of getting it from a router?
Cause not everywhere I go a router is available for me...

But thank you very much for your time and effort, I really appreciate it.
Altair
Posts: 76
Joined: Sat May 20, 2006 2:33 am
Location: The Netherlands

Post by Altair »

Yes you can set the ip manually. You can do that in the network settings menu. The part where you make a new connection (or edit one). Instead of automatic use Manual i think.
Kakolukia
Posts: 21
Joined: Sun Jun 11, 2006 8:43 pm

Post by Kakolukia »

Altair wrote:Yes you can set the ip manually. You can do that in the network settings menu. The part where you make a new connection (or edit one). Instead of automatic use Manual i think.
I know that, but be2003 said:
It's weird when you start the app you connect to a to a router(sorry had to use it) then you continue on to get your ip address and the ip address is sent to the other psp
But if the ip can be set manually (for example by using the manual settings option you mentioned), it doesnt have to use a router...
be2003
Posts: 144
Joined: Thu Apr 20, 2006 2:46 pm

Post by be2003 »

good point, but look at it this way, in network settings you can provide the information to give to the router. for example the ip i give to the router is 192.168.0.105, now that is different depending on how you set it up. another psp cant just send something directly to my psp without adhoc. it must be redirected through a router because only the router knows who 192.168.0.105 is, not the psp, because that number is used specifically for the router and nothing else. in my sample, a router is needed but not the internet so i suggest getting a car adapter for your router
- be2003
blog
Kakolukia
Posts: 21
Joined: Sun Jun 11, 2006 8:43 pm

Post by Kakolukia »

interresting, when do you think your code is ready?
I really want to know how you worked it out, and use it...
thanx a lot for your time and effort!
be2003
Posts: 144
Joined: Thu Apr 20, 2006 2:46 pm

Post by be2003 »

well it is done...i just have have to work out some bugs, mostly screen printing stuff, i dont usually print to the screen, it should be easy. then i will upload it to my angelfire site around 4-5 pm us pacific time
- be2003
blog
be2003
Posts: 144
Joined: Thu Apr 20, 2006 2:46 pm

done

Post by be2003 »

the file is here, just follow the on screen instructions. when it says to press O to echo. that is if you only have one psp the psp will communicate with itself.
- be2003
blog
Kakolukia
Posts: 21
Joined: Sun Jun 11, 2006 8:43 pm

Post by Kakolukia »

havn't tested it yet, i'm going to do this within a few mins (if everything goes right), thanx a lot!
edit: It hangs at stage 3, don't no why, i'm going to test my Wlan.getIPAddress() to see if thats the problem...
I'll tell you later...

btw, which program do you use to edit/make the lua programs ons your psp on the go?
be2003
Posts: 144
Joined: Thu Apr 20, 2006 2:46 pm

Post by be2003 »

psp pda(used to be psp notepad i think). with it i can write my lua apps while listening to music. edit: god i wish that danzeff had a return key, anyway psp-pda v1.2 is here. it has onscreen keyboard cuz psprint sucks.
Last edited by be2003 on Wed Jun 14, 2006 6:23 am, edited 1 time in total.
- be2003
blog
be2003
Posts: 144
Joined: Thu Apr 20, 2006 2:46 pm

Post by be2003 »

if you set up a static connection and defined your ip in network settings then it should only take a second. what version of luaplayer do you have? god i hope u are pressing x like the onscreen command tells u to
- be2003
blog
Kakolukia
Posts: 21
Joined: Sun Jun 11, 2006 8:43 pm

Post by Kakolukia »

be2003 wrote:psp pda(used to be psp notepad i think). with it i can write my lua apps while listening to music. edit: god i wish that danzeff had a return key, anyway psp-pda v1.2 is here. it has onscreen keyboard cuz psprint sucks.
i'm using that too, but as far as I know there is no way to directly test the lua from there.
Kakolukia
Posts: 21
Joined: Sun Jun 11, 2006 8:43 pm

Post by Kakolukia »

be2003 wrote:if you set up a static connection and defined your ip in network settings then it should only take a second. what version of luaplayer do you have? god i hope u are pressing x like the onscreen command tells u to
I'm not that stupid, it just freezes, only the home button still works. which is more then in the WLAN app that comes with the luaplayer, I need the 10sec hard shutdown for that one...
I'm using luaplayer 0.20
be2003
Posts: 144
Joined: Thu Apr 20, 2006 2:46 pm

Post by be2003 »

you are using manual setup right, what fw are u?
- be2003
blog
be2003
Posts: 144
Joined: Thu Apr 20, 2006 2:46 pm

Post by be2003 »

you are using manual setup right, what fw are u?
- be2003
blog
Kakolukia
Posts: 21
Joined: Sun Jun 11, 2006 8:43 pm

Post by Kakolukia »

be2003 wrote:you are using manual setup right, what fw are u?
got it to work, I only set the ip manually in my emulated 2.50, I forgot my normal 1.50 in which I start the luaplayer. so, I'm not so stupid to nnt press the x, but I'm so stupid to forget to set the network settings correctly.
Kakolukia
Posts: 21
Joined: Sun Jun 11, 2006 8:43 pm

Post by Kakolukia »

thanx a lot for your help, i'm going to test it on 2 psps tomorrow, and tell you the results.
be2003
Posts: 144
Joined: Thu Apr 20, 2006 2:46 pm

Post by be2003 »

i am very interested, i only have one psp that is why i put in the echo option so i want to see how it works with 2, my friends couldnt find a 1.5 and they dont really like homebrew.
- be2003
blog
Kakolukia
Posts: 21
Joined: Sun Jun 11, 2006 8:43 pm

Post by Kakolukia »

It does work (w0000000t)!
thanx for your help, I'm going to play woth this the rest of the day, and post my findings.

But 1 question:
why does the other cross/circle only blink? If I keep my cross pressed at psp1, the othercross at psp 2 doesnt stay white, it blits, so it works, but only for a milisec. (It does this also on the 1 psp echo way)

aaah, another question (it doesnt stay at 1, sorry):
If I want to send coördinates, what would be the best way to do this, cause it sends strings, but numbers would be easyer to use...

Thanx for your help, time and effort, its really helpfull to me!

p.s. I have a 1.50 and a 2.50 with GTA: LCS, both with luaplayer 0.20.
Altair
Posts: 76
Joined: Sat May 20, 2006 2:33 am
Location: The Netherlands

Post by Altair »

Cant you just use the strings as numbers with lua?
I have made something (which I cant test because it uses netlib and thats offline :( ) and that sends stuff from a table as strings and when it receives I use substrings to put it all back in a table. I think it should work, because Im not copying apprentices ("s) with the substrings.
Kakolukia
Posts: 21
Joined: Sun Jun 11, 2006 8:43 pm

Post by Kakolukia »

Altair wrote:Cant you just use the strings as numbers with lua?
I have made something (which I cant test because it uses netlib and thats offline :( ) and that sends stuff from a table as strings and when it receives I use substrings to put it all back in a table. I think it should work, because Im not copying apprentices ("s) with the substrings.
Well, ive been working around a bit with irda before a started this thread, and if I sended a number, the other psp received it as a string. If I used that string as a number luaplayer gave me an error...
so i translated all seperate numbers of the string to a new number, which isnt fun to do...

I do not fully understand what u mentioned, maybe it is the same as I did, maybe it is something different...

I'll post my piece of code soon, to show you how I solved it...
Kakolukia
Posts: 21
Joined: Sun Jun 11, 2006 8:43 pm

Post by Kakolukia »

Code: Select all

-- irda write:
irdax = Player.x
System.irdaWrite(irdax)
Player.x is the Player's x position (I shortend the code so only the necessary was left).

Code: Select all

-- irda read
        x = 0
        command = System.irdaRead()
        if string.len(command) >= 1 then
          for i = 1, 1 do
              char = string.sub(command, i, i)
              if char == "0" then
                  x = x + 000
              end
              if char == "1" then
                  x = x + 100
              end
              if char == "2" then
                  x = x + 200
              end
              if char == "3" then
                  x = x + 300
              end
              if char == "4" then
                  x = x + 400
              end
          end
          for i = 2, 2 do
              char = string.sub(command, i, i)
              if char == "0" then
                  x = x + 00
              end
              if char == "1" then
                  x = x + 10
              end
              if char == "2" then
                  x = x + 20
              end
              if char == "3" then
                  x = x + 30
              end
              if char == "4" then
                  x = x + 40
              end
              if char == "5" then
                  x = x + 50
              end
              if char == "6" then
                  x = x + 60
              end
              if char == "7" then
                  x = x + 70
              end
              if char == "8" then
                  x = x + 80
              end
              if char == "9" then
                  x = x + 90
              end
          end
          for i = 3, 3 do
              char = string.sub(command, i, i)
              if char == "0" then
                  x = x + 0
              end
              if char == "1" then
                  x = x + 1
              end
              if char == "2" then
                  x = x + 2
              end
              if char == "3" then
                  x = x + 3
              end
              if char == "4" then
                  x = x + 4
              end
              if char == "5" then
                  x = x + 5
              end
              if char == "6" then
                  x = x + 6
              end
              if char == "7" then
                  x = x + 7
              end
              if char == "8" then
                  x = x + 8
              end
              if char == "9" then
                  x = x + 9
              end
          end
I know there is some unnessecary code in it, but that came into it by mistake... (dumb copy paste, and later only altering the highly necessary parts), also I could have used elseif's, but I was lazy or someting like that...
x is the opponent's x position.

Now I want to know how you did it, what that table stuff...
SSpeare
Posts: 63
Joined: Tue May 23, 2006 11:45 pm
Contact:

Post by SSpeare »

Have you tried this?

Code: Select all

command = System.irdaRead()
x = tonumber(command)
Kakolukia
Posts: 21
Joined: Sun Jun 11, 2006 8:43 pm

Post by Kakolukia »

SSpeare wrote:Have you tried this?

Code: Select all

command = System.irdaRead()
x = tonumber(command)
nope, I don't know the existance of that...

I'll try it.

thanx!
be2003
Posts: 144
Joined: Thu Apr 20, 2006 2:46 pm

Post by be2003 »

this is how u should set it up

first define the x
x = 5
then make it a string
sx = tostring(x)
then send it as string
System.irdaWrite(sx)

when other psp receives it, it should be...

command = System.irdaRead()
if string.len(command) > 0 then
opponentx = tonumber(command)
end
- be2003
blog
Kakolukia
Posts: 21
Joined: Sun Jun 11, 2006 8:43 pm

Post by Kakolukia »

And it works almost the same for WLAN?
Altair
Posts: 76
Joined: Sat May 20, 2006 2:33 am
Location: The Netherlands

Post by Altair »

Yes what you did is the same as what i did.

I didn't know the command tonumber existed. Thx for that!
Post Reply