{script} getDistance

Talk about creating Grimrock 1 levels and mods here. Warning: forum contains spoilers!
Post Reply
User avatar
cromcrom
Posts: 549
Joined: Tue Sep 11, 2012 7:16 am
Location: Chateauroux in a socialist s#!$*&% formerly known as "France"

{script} getDistance

Post by cromcrom »

Hi all.
This script returns the direct number of squares between obj1 and obj2.

Code: Select all

function getDistance(obj1,obj2)
local distance = 0
local XNumber = math.max(obj1.x,obj2.x) - math.min(obj1.x,obj2.x)
local YNumber = math.max(obj1.y,obj2.y) - math.min(obj1.y,obj2.y)
distance = XNumber + YNumber
return distance
end
enjoy :-)
Last edited by cromcrom on Mon Oct 01, 2012 10:15 am, edited 1 time in total.
A trip of a thousand leagues starts with a step.
User avatar
Komag
Posts: 3659
Joined: Sat Jul 28, 2012 4:55 pm
Location: Boston, USA

Re: {script} getDistance

Post by Komag »

that's a nice one, I like it! the closest thing to this in the original game was the dragon statues lining up thing, and I loved that one too. You could give clues to the player, compass headings, relative distance, etc
Finished Dungeons - complete mods to play
User avatar
cromcrom
Posts: 549
Joined: Tue Sep 11, 2012 7:16 am
Location: Chateauroux in a socialist s#!$*&% formerly known as "France"

Re: {script} getDistance

Post by cromcrom »

Should it go to the useful scripts then ?
A trip of a thousand leagues starts with a step.
User avatar
petri
Posts: 1917
Joined: Thu Mar 01, 2012 4:58 pm
Location: Finland

Re: {script} getDistance

Post by petri »

XNumber and YNumber should be local, otherwise they will be unnecessarily saved with save games.
User avatar
cromcrom
Posts: 549
Joined: Tue Sep 11, 2012 7:16 am
Location: Chateauroux in a socialist s#!$*&% formerly known as "France"

Re: {script} getDistance

Post by cromcrom »

:oops:
Fixed, thanks :-)
A trip of a thousand leagues starts with a step.
User avatar
Komag
Posts: 3659
Joined: Sat Jul 28, 2012 4:55 pm
Location: Boston, USA

Re: {script} getDistance

Post by Komag »

yes, repository worthy!
Finished Dungeons - complete mods to play
Post Reply