sanding a table with SendData()

Find quick help here to get you started with Hollywood

sanding a table with SendData()

Postby peceha » Thu Sep 14, 2017 9:29 am

Hello,
I've been trying to send a table (about 300 items inside containing sub-tables, numbers and strings - that is dungeon map generated on server computer) to the client computer:
Code: Select all
SendData(clientID,ArrayToStr(maze))


On the client computer I have:
Code: Select all
maze=ReceiveData(connectionID,#RECEIVEALL)
maze=StrToTable(maze)


and after using:
Code: Select all
ForEach(maze,DebugPrint)

i get:
0 0


The received table is not correct - what am I doing wrong?
Thanks
peceha
 
Posts: 110
Joined: Tue Dec 13, 2016 9:39 am
Location: Poland

Re: sanding a table with SendData()

Postby airsoftsoftwair » Thu Sep 14, 2017 10:13 pm

ArrayToStr() doesn't convert arbitrary tables into strings. It turns a number of characters stored inside a table into a text string. There is currently no function to turn a table into a string but you can easily write one by creating a virtual file and then use WriteTable() to write the table to it and then use FileToString() to get the virtual file back as a string, it's as easy as that :)
User avatar
airsoftsoftwair
 
Posts: 2224
Joined: Fri Feb 12, 2010 3:33 pm
Location: Germany

Re: sanding a table with SendData()

Postby peceha » Thu Sep 14, 2017 11:03 pm

Thanks, that worked - but I used real file instead of virtual one (just couldn't figure out how to write a table into virtual file).
peceha
 
Posts: 110
Joined: Tue Dec 13, 2016 9:39 am
Location: Poland

Re: sanding a table with SendData()

Postby peceha » Fri Sep 15, 2017 9:12 am

Just one more :D
How to change a brush into the string (or better - send it using the SendData() command) ?

I have a 16x16 pxl avatar that needs to be sent over the network to the rest of the computers.
I have found SaveBrush() command to make a file out of it and then FileToString()... is that correct? or there is some other way to send a brush?

Thanks
peceha
 
Posts: 110
Joined: Tue Dec 13, 2016 9:39 am
Location: Poland

Re: sanding a table with SendData()

Postby peceha » Mon Sep 18, 2017 4:22 pm

Looks like following sequence works just fine:
Code: Select all
...
saveBrush()
fileToString()
sendData()
stringToFile()
loadBrush()
...

Thanks
peceha
 
Posts: 110
Joined: Tue Dec 13, 2016 9:39 am
Location: Poland

Re: sanding a table with SendData()

Postby airsoftsoftwair » Mon Sep 18, 2017 4:48 pm

Yes, but you can use virtual files to avoid disk accesses. See DefineVirtualFileFromString() for details.
User avatar
airsoftsoftwair
 
Posts: 2224
Joined: Fri Feb 12, 2010 3:33 pm
Location: Germany


Return to Newbie questions

Who is online

Users browsing this forum: No registered users and 4 guests

cron