Network Functions
Overview
Network functions provide packet sending and communication capabilities in Growtopia.
Functions
sendPacket()
sendPacket(type, packet, to_client_first?)
- Description: Send packet to server
- Parameters:
type:numberpacket:stringto_client_first?:boolean
- Returns:
- None
- Example:lua
sendPacket(2,"action|input\ntext|Hi")
sendVariant()
sendVariant(variantlist, packet_data?, netid?, value?)
- Description: Send variant list
- Parameters:
variantlist:VariantListpacket_data?:TankPacketnetid?:numbervalue?:number
- Returns:
- None
- Example:lua
sendVariant({v1 = "OnConsoleMessage", v2 = "Console here"})
sendPacketRaw()
sendPacketRaw(flag, packet)
- Description: Send raw TankPacket
- Parameters:
flag:booleanpacket:TankPacket
- Returns:
- None
- Example:lua
p = getLocal() sendPacketRaw(false, {type=3, value=18, x=p.posX, y=p.posY, px=p.posX//32, py = p.posY//32})
getPing()
getPing() -> integer
- Description: Get current connection ping
- Parameters:
- None
- Returns:
integer- Ping value, or-1when no entry is available
- Note:
- The value is a 32-bit field read from the matching peer entry. Whether the unit is milliseconds is not verified.
- Example:lua
log(getPing())