Jump to content
  • 0

Need help scripting


Question

Posted

I used to script a little back in the day and I am trying to get back into it. 
 

I have a script that searches for value in this case 1048 (which is dirt In this game) then it uses gg.editAll to change the diet value into any other block. 
 

what I am having trouble with is I want to make a system where the user of the script can type what they want that 1048 value to turn into to. As in they could type stone and the script would search through a list for stone and find a paired integer corresponding to stone. Then it uses the stones integer to gg.editAll of the dirt (1048) into the stone. 
 

all I am having trouble with is the list part

I have some knowledge of python and it would be pretty easy to do in python is their a similar way to do it in gg code?

1 answer to this question

Recommended Posts

  • 0
Posted (edited)

How to store that data in your code effectively depends on which interface to choose an item script needs to provide. If user input is name of item, then table item names as keys and item identifiers as values can work well. If user chooses option from list of possible items, then it can be table of tables with each inner table having name and value fields. Below is an example of tables for both of mentioned options: 

-- Option 1
local items = {
  ["dirt"] = 123,
  ["stone"] = 456
}
-- Option 2
local items = {
  {name = "dirt", value = 123},
  {name = "stone", value = 456}
}
Edited by CmP

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.