0% found this document useful (0 votes)
50 views6 pages

Growtopia Lua Scripting Guide

The document provides a comprehensive guide on scripting functions for the Growtopia game, detailing various commands and their usage. Key functions include toggling dialogs, managing inventory, finding paths, sending packets, and creating dialogs. Each function is accompanied by examples and explanations to facilitate understanding and implementation.

Uploaded by

rwaanvnt
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
50 views6 pages

Growtopia Lua Scripting Guide

The document provides a comprehensive guide on scripting functions for the Growtopia game, detailing various commands and their usage. Key functions include toggling dialogs, managing inventory, finding paths, sending packets, and creating dialogs. Each function is accompanied by examples and explanations to facilitate understanding and implementation.

Uploaded by

rwaanvnt
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

-- Io File

Android/data/[Link]/script/[Link]

-- Basic Knowledge
bool / boolean, boolean value true or false
int / integer, integer value is number
string / string

-- Function
void ToggleDialog(bool)
calling function to disable OnDialogRequest, it's mean if you turn on ToggleDialog,
you won't get any Dialog.

-- How To Use Bo'ol


ToggleDialog(true)
ToggleDialog(false)

-- explanation
true for Active
false for disable

-- inventory
void GetInventory()

-- How to use
for _, inv in pairs(GetInventory())do
console("ID:"..[Link].." Amount:"..[Link])
end

-- For print all Inventory Item

function console(msg)
LogToConsole(msg)
end
calling function OnConsoleMessage, displaying what ever you write into Growtopia
Console. nb: only you can see.

-- How to use
console("hello world")

Output in GT Console: hello world

void findpath(int, int)


calling function Path Finders, auto finding path target without teleport back to
first position.

-- How to use
findpath(10, 10)

-- Explanation
it will automatic finding path to coordinate X: 10 Y: 10
```

```
void findpathdelay(int) // in miliseconds
calling function delay path finders.

-- How to use
findpathdelay(100)
-- Explanation
it will set path finders delay to 100 miliseconds
```

```
void sleep(int) // in miliseconds
calling function sleep, it will pause execution until sleep done.

-- How to use
sleep(1000)

-- Explanation
it will pause execution for 1 second
1000 = 1 second
2000 = 2 second
```

```
int checkamount(int)
calling function check item amount on your inventory.

-- How to use
if(checkamount(16) < 2)
//execute your code
end

-- Explanation
16 is Grass itemID so it will check if grass amount less than 2 it will execute
your code.
```

```
void SendPacket(int, std::string)

-- How to use
SendPacket(2, "action|input\n|text|Hello")

-- Explanation
it will send chat hello
2 is packet flags
```

```
void SendPacketRaw(bool, TankPacketStruct)

-- How to use
pkt {}
[Link] = 3
[Link] = 10
[Link] = 5
[Link] = 18
[Link] = GetLocal().posX
[Link] = GetLocal().posY
SendPacketRaw(false, pkt)

-- Explanation
it will send punching block on coordinate X: 10 Y: 5
[Link] is Packet Type and 3 is PACKET_TILE_CHANGE_REQUEST
[Link] is PunchX / Punch Coordinate X
[Link] is PunchY / Punch Coordinate Y
[Link] is Player Position X
[Link] is Player Position Y
[Link] = 18 is value itemID, 18 is Fist so it will send punch packet, if you
change it to 32 ( wrench ) it will wrenching any block on coordinate X: 10 Y: 5
```

```
void CreateDialog()

-- How to use

CreateDialog("add_textbox|Test Dialog?|left\nadd_quick_exit|\nend_dialog|end|
Cancel||")

-- Explanation

just try it

```

```
string GetCurrentWorldName()

-- How to use

console(GetCurrentWorldName())

-- Explanation

Print Current World Name

```

```
void GetWorldObject()

-- How to use
for _, drop in pairs(GetWorldObject())do
console("X:"..drop.x.." Y:"..drop.y.." ItemID:"..[Link].." Amount:"..[Link])
end
-- explanation

Print all Dropped Object

```

```
void GetTile()

-- How to use

for _, tile in pairs(GetTile()) do


if([Link] == 2) then
findpath(tile.x, tile.y)
break
end
end

-- Explanation

if the code executed, it will scan all tile and find tile foreground ID 2 ( itemID:
dirt ) after tile found it will find path to tile

```

```
void CheckTile()

-- How to use

for _, tile in pairs(GetTile()) do


if([Link] == 2 and CheckTile(tile.x,tile.y-1).fg == 0) then
findpath(tile.x, tile.y)
break
end
end

-- Explanation

if the code executed, it will scan all tile and find tile foreground ID 2 ( itemID:
dirt ) then it will check foreground id above dirt and if foreground id is 0 it
will finding path.

```

---- Structure
```
Packet Structure:

PACKET_STATE = 0,
PACKET_CALL_FUNCTION = 1
PACKET_UPDATE_STATUS = 2
PACKET_TILE_CHANGE_REQUEST = 3
PACKET_SEND_MAP_DATA = 4
PACKET_SEND_TILE_UPDATE_DATA = 5
PACKET_SEND_TILE_UPDATE_DATA_MULTIPLE = 6
PACKET_TILE_ACTIVATE_REQUEST = 7
PACKET_TILE_APPLY_DAMAGE = 8
PACKET_SEND_INVENTORY_STATE = 9
PACKET_ITEM_ACTIVATE_REQUEST = 10
PACKET_ITEM_ACTIVATE_OBJECT_REQUEST = 11
PACKET_SEND_TILE_TREE_STATE = 12
PACKET_MODIFY_ITEM_INVENTORY = 13
PACKET_ITEM_CHANGE_OBJECT = 14
PACKET_SEND_LOCK = 15
PACKET_SEND_ITEM_DATABASE_DATA = 16
PACKET_SEND_PARTICLE_EFFECT = 17
PACKET_SET_ICON_STATE = 18
PACKET_ITEM_EFFECT = 19
PACKET_SET_CHARACTER_STATE = 20
PACKET_PING_REPLY = 21
PACKET_PING_REQUEST = 22
PACKET_GOT_PUNCHED = 23
PACKET_APP_CHECK_RESPONSE = 24
PACKET_APP_INTEGRITY_FAIL = 25
PACKET_DISCONNECT = 26
PACKET_BATTLE_JOIN = 27
PACKET_BATTLE_EVEN = 28
PACKET_USE_DOOR = 29
PACKET_SEND_PARENTAL = 30
PACKET_GONE_FISHIN = 31
PACKET_STEAM = 32
PACKET_PET_BATTLE = 33
PACKET_NPC = 34
PACKET_SPECIAL = 35
PACKET_SEND_PARTICLE_EFFECT_V2 = 36
GAME_ACTIVE_ARROW_TO_ITEM = 37
GAME_SELECT_TILE_INDEX = 38

```

```
Raw Packet Structure:
pkt {}
[Link] = 0 // Packet Type (int)
[Link] = 0 // Character State (int)
[Link] = 0 //XSpeed (int)
[Link] = 0 // YSpeed (int)
[Link] = 0 //PunchX (int)
[Link] = 0 // PunchY (int)
[Link] = 0 // a Value (int)
[Link] = 0 // Player Position X (int)
[Link] = 0 // Player Position Y (int)

```

```
Checktile Structure
tile.x = Get X position of tile (int)
tile.y = Get Y position of tile (int)
[Link] = Get Foreground tile itemID (int)
[Link] = Get Background tile itemID (int)
[Link] = Get Fruit Bloom Progress Percent (bool) ( true = Ready
Harvest )
```

```
GetWorldObject() Structure
obj.x = Get X position of object ( int )
obj.y = Get Y position of object (int)
[Link] = Get Amount of Object (int)
[Link] = Get itemID of Object (int)
```

```
GetTile Structure
tile.x = Get X position of tile (int)
tile.y = Get Y position of tile (int)
[Link] = Get Foreground tile itemID (int)
[Link] = Get Background tile itemID (int)
[Link] = Get Fruit Bloom Progress Percent (bool) ( true = Ready
Harvest )
```
```
GetLocal Structure
GetLocal().posX = Get X position of Local player (int)
GetLocal().posY = Get Y position of Local player (int)
GetLocal().name = Get name of Local player (string)
GetLocal().country = Get country code of Local player (string)
GetLocal().userid = Get userID of Local player (int)
GetLocal().status = Get status of Local player (int)
GetLocal().isLeft = Get is Facing Left of Local player (bool)
GetLocal().hair = Get hair of Local player (int)
GetLocal().shirt = Get shirt of Local player (int)
GetLocal().pants = Get pants of Local player (int)
GetLocal().feet = Get feet of Local player (int)
GetLocal().face = Get face of Local player (int)
GetLocal().hand = Get hand of Local player (int)
GetLocal().back = Get back of Local player (int)
GetLocal().mask = Get mask of Local player (int)
GetLocal().necklace = Get necklace of Local player (int)
```

```
GetInventory() Structure
GetInventory().id = Get itemID from Inventory Local Player ( int )
GetInventory().amount = Get Amount of item from Inventory Local Player ( int )
```

Common questions

Powered by AI

GetCurrentWorldName improves the overall user experience by keeping players informed about their current game location. This constant feedback supports orientation and navigation within the game's multiple environments, enhancing the player's situational awareness and ability to share or seek information about specific worlds. While the utility is vital for multi-environment navigation, it might be limited if not combined with additional world-specific information to provide deeper context .

The sleep and findpathdelay functionalities affect gameplay pacing by introducing pauses at strategic points. Sleep pauses all execution for a designated time, allowing for breaks in action or synchronization of events. Findpathdelay, specifically for pathfinding, adjusts the speed of navigation to target points. Together, they enable players to manage their presence and action timing, helping to synchronize with game events or opponent actions, adding a layer of tactical control over game pacing .

The Path Finder functions enhance player movement strategies by automatically calculating efficient paths to a target location (findpath) and allowing players to control the timing of these paths (findpathdelay). By automating navigation to specified coordinates and setting delays, players can optimize their in-game actions, ensuring more strategic positioning and movement timing with minimal manual input, which is crucial in dynamically changing game environments .

SendPacketRaw differs from SendPacket by providing direct manipulation of packet data through a structured input, allowing for more precise actions such as changing tiles, interacting with objects, or player state manipulation. This facilitates more dynamic interactions and responses beyond simple chat communication, offering benefits such as customized player actions and more complex interaction sequences that can impact gameplay significantly .

The SendPacket function is used to send chat messages or other actions in the game by specifying a packet flag (e.g., 2 for chat) and a message string (e.g., 'action|input\n|text|Hello'). It facilitates player-to-game communication, but its limitations include the predefined structure requirement and potential for limited interaction types beyond chat and input commands .

Using the GetTile function in combination with CheckTile allows for complex pathfinding by identifying and responding to specific tile configurations in the game world. GetTile scans for foreground tile ID 2 (dirt), and CheckTile further refines this by checking the tile above for a foreground ID of 0. If conditions are met, it initiates pathfinding to the target tile, allowing for informed navigation decisions and efficient resource gathering .

The GetWorldObject function plays a pivotal role in understanding the game world's dynamics by providing details of all objects, including their positions, item IDs, and amounts. Players can use this information to track resource locations and densities, allowing for strategic planning in resource harvesting and optimized pathfinding, ultimately contributing to a more effective exploration and management of in-game resources .

The CreateDialog function enhances the user interface by allowing for the creation of customizable dialog boxes. With options to add textboxes, quick exits, and end dialogs, it enables developers to present information or obtain input from users dynamically. However, the customization is limited to the predefined structure and content, potentially restricting complex interaction or designs .

The boolean value in the ToggleDialog function determines whether the dialog is active or disabled. When the boolean value is true, the function disables the OnDialogRequest, meaning no dialog will pop up. Conversely, setting the boolean to false will enable the dialog .

The GetInventory function effectively aids in inventory management by allowing players to iterate through all items, displaying their IDs and amounts. This enables players to make informed decisions about resource allocation and usage. However, its reliance on console output for display might limit its usability for detailed analysis directly within the game environment, as it doesn't inherently offer sorting or filtering functionalities .

You might also like