sanding a table with SendData()

Find quick help here to get you started with Hollywood
Post Reply
peceha
Posts: 111
Joined: Tue Dec 13, 2016 9:39 am
Location: Poland

sanding a table with SendData()

Post by 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

User avatar
airsoftsoftwair
Posts: 2448
Joined: Fri Feb 12, 2010 3:33 pm
Location: Germany
Contact:

Re: sanding a table with SendData()

Post by 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 :)

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

Re: sanding a table with SendData()

Post by 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: 111
Joined: Tue Dec 13, 2016 9:39 am
Location: Poland

Re: sanding a table with SendData()

Post by 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: 111
Joined: Tue Dec 13, 2016 9:39 am
Location: Poland

Re: sanding a table with SendData()

Post by peceha » Mon Sep 18, 2017 4:22 pm

Looks like following sequence works just fine:

Code: Select all

...
saveBrush()
fileToString()
sendData()
stringToFile()
loadBrush()
...
Thanks

User avatar
airsoftsoftwair
Posts: 2448
Joined: Fri Feb 12, 2010 3:33 pm
Location: Germany
Contact:

Re: sanding a table with SendData()

Post by airsoftsoftwair » Mon Sep 18, 2017 4:48 pm

Yes, but you can use virtual files to avoid disk accesses. See DefineVirtualFileFromString() for details.

Post Reply