#Godot code part

5 messages · Page 1 of 1 (latest)

spring hull
#

Hello, I have a project related to godot. I will be given some data and I need to adapt it to godot. The incoming data will write the number of boxes, their locations and scale. I will need to get this as a code in godot. How can I create a box with code in godot? How can I change their locations and scales with code? I would be happy if you could help me. I am sending an example of the data to be given. örüntü = pattern , katman = layer

pale otter
#
var boxes = []

func create_box(location, scale):
  return { location = location, scale = scale }

func create_boxes():
  boxes.append(create_box(Vector2(5, 10), 0))
  boxes.append(create_box(Vector2(15, 5), 0))
  boxes.append(create_box(Vector2(10, 15), 0))
  boxes.append(create_box(Vector2(15, 15), 0))

  boxes.append(create_box(Vector2(5, 10), 4))
  boxes.append(create_box(Vector2(15, 10), 4))
  boxes.append(create_box(Vector2(5, 15), 4))
  boxes.append(create_box(Vector2(15, 15), 4))

  boxes.append(create_box(Vector2(5, 10), 8))
  boxes.append(create_box(Vector2(15, 5), 8))
  boxes.append(create_box(Vector2(10, 15), 8))
  boxes.append(create_box(Vector2(15, 15), 8))
#
func print_box(box):
  print("Box at (", box.location.x, ", ", box.location.y, ", ", box.scale, ")")
#
print_box(boxes[0])
spring hull
#

Thanks a lot. Should I write this code in the "scenes" script? The output I just gave was just a sample data. The values ​​entered can be random. I can explain it properly. I need to get the box data from the sample code I gave and create the boxes and their positions. For example, the user can select different patterns and positions. This way, different data can come. Can you guide me on how to set it up? Sorry, I'm new so I'm asking a lot of questions 🙂