How can I add new zone into the map? I mean, make them visible in the map as red dot and show how it connects like those originals.
Viewing post in Modding help
The red dots are TextureRects in the map.scn file. The tooltip text and which points connect are stored in explorationregions.gd. map.gd uses those2 files to determine where to draw the lines when you hover over a red dot.
.scn files are not text files and are best edited using the Godot Engine. A new project can be created and Strive can be copied into the project folder to allow basic access. Beyond that it gets rather complex.
Alternatively, once map.scn has been loaded by the game, any script file can be used to create new red dots by duplicating an existing TextureRect.
explorationregions.gd should be fairly straight forward as it is a simple text file . I'd recommend starting from a copy an existing region.
explorationregions.gd only defines the pairs of dots connected by lines on the map.
In map.gd, the function "showtooltip(node)" creates the lines for each exit listed for the zone. The dots are Images displayed by TextureRect GUI controls(https://docs.godotengine.org/en/3.1/classes/class_texturerect.html). The position of those controls is what determines where the dot is. The name of those controls needs to match the name of a zone. The only way to get a zone to appear on the map is to add a new control node to the map.scn scene tree.
The following can be added to the beginning of _ready() in map.gd, as a minimal setup for adding a new red dot node:
var newNode = find_node("sea").duplicate()
newNode.rect_position = Vector2(100,100)
newNode.name = "newZone"
find_node("roads").add_child(newNode)
It seems like adding code to map.gd anywhere lead to freeze of the map. Here is my code to the end of _ready()
extends Control
#warning-ignore:unused_class_variable
var mouse_in = false
#warning-
ignore:unused_class_variable
var dragging = false
onready var size = $TextureRect.get_size()
var
offset = Vector2()
var status = 'none'
var timer = 0
var currentloc = null
var newNode = find_node("sea").duplicate()
newNode.rect_position = Vector2(100,100)
newNode.name = "newZone"
find_node("roads").add_child(newNode)
func _ready():
for i in get_node("TextureRect/roads").get_children() +
get_node("TextureRect/towns").get_children():
i.connect
("mouse_entered",self,'showtooltip',[i])
i.connect
("mouse_exited",self,'hidetooltip')
func _input(event):
if self.is_visible_in_tree() == false:
return
if event.is_action_pressed("LMB"):
var eventpos =
event.global_position
var barpos = $TextureRect.get_global_position()
size =
$TextureRect.get_size()
var target_rect = Rect2(barpos.x, barpos.y, size.x, size.y)
if target_rect.has_point(eventpos):
status = 'clicked'
offset = barpos - eventpos
if event.is_action_released("LMB"):
status
= 'none'
if status == 'clicked' and event.is_class("InputEventMouseMotion"):
status = 'dragging'
#centermap('frostford')
if status == 'dragging':
$TextureRect.set_global_position(event.global_position+offset)
So I said "The following can be added to the beginning of _ready() in map.gd."
You have: "The following code added before the beginning of _ready() in map.gd."
Spot the difference? It freezes cause you put local-scope code in the file-scoped portion of the code, which is completely undefined behavior. I tried to be quite precise with my description, because there are very few locations you can put this code in the file to get the expected behavior. Perhaps I was too concise, but I am going to sleep now. The code I gave you only works inside a function and not inside a for loop.