Camera near position

» Siedler Map Source Forum » Siedler DEdK Script Forum » Camera near position

Seiten: 1

SH
#1
07.07.2020 20:46
Beiträge: 127

Camera near position

I want to make a job that when camera is near entity called "erec" (1000 distance) something happens (every second). I tried to do it in this SimpleJob:


function Test()
	local pE = GetPosition("erec")
	local pC = Camera.ScrollGetLookAt()
	if pC.X >= pE.X-1000 and pC.X <= pE.X+1000 and pC.Y >= pE.Y-1000 and pC.Y <= pE.Y+1000 then
		Message("test") -- for test
	end
end 

but it doesn't work. What's wrong or is it another way to do something like that?

____________________
Sorry for my German

totalwarANGEL
#2
08.07.2020 09:27
Beiträge: 2123

x, y = GUI.GetEntityInfoScreenPosition(EntityID)


You could try this one. But I am uncertain if this function exists in Settlers 5 (know it from Settlers 6).

____________________
Die Welt ist arschlochförmig und wir leben in der Mitte.

Play4FuN
#3
08.07.2020 09:57
Beiträge: 704

It should work if you change it a bit. Camera.ScrollGetLookAt does NOT return a table with X and Y values, it returns two values instead. You can use one of the two options here:

local xC, yC = Camera.ScrollGetLookAt()
-- or
local posC = { Camera.ScrollGetLookAt() }
local xC = posC[1]
local yC = posC[2]



As for GetPosition I am not sure what the return values look like, because I haven't had any time for this game for .... sigh Idk

Edit: GetPosition should be fine as it is, meaning it returns a table with X and Y entries.

____________________
LG Play4FuN

Siedler DEdK Mapping + Scripting Tutorials

totalwarANGEL
#4
08.07.2020 19:42
Beiträge: 2123

Oh shit, mir ist gar nicht aufgefallen, dass er da versucht hat eine Zahl zu indexieren.

____________________
Die Welt ist arschlochförmig und wir leben in der Mitte.

SH
#5
10.07.2020 11:02
Beiträge: 127

I see the mistake
Thanks for help

____________________
Sorry for my German

Seiten: 1

SiteEngine v1.5.0 by nevermind, ©2005-2007
Design by SpiderFive (www.siedler-games.de) - English translation by juja

Impressum