Page 1 of 1

Coordinates

Posted: Tue Jun 23, 2015 2:23 pm
by Kuro01
Hello, I'm new to GR2. I'm having trouble figuring out how to set coordinates maybe someone can help example spawn item.

function spawnaltar()
spawn("altar",1,0,0,0,0,"test_altar")
end

I only can get the item to spawn In the center dungeons 0.0.0 if I go in a side dungeon 1.0.0 and set script to spawn altar.
the altar spawns in the coordinates of level 0.0.0. Not recognizing level. only works directly up and down. How do I get the side dungeons
to recognize the coordinates to place my altar?

Re: Coordinates

Posted: Tue Jun 23, 2015 2:30 pm
by Dr.Disaster
Taken from scripting reference:
spawn(object, level, x, y, facing, elevation, [id])
Spawns a new object at given position on a dungeon level where x and y specify the x- and y-coordinates on the map and level is a level index. facing must be a number between 0 and 3 and it indicates the following directions: 0=north, 1=east, 2=south, 3=west. id parameter is optional. If given it must be an unique id in the context of the dungeon. If not given an unique id is automatically generated.
Your coordinates explizitly tell the spawn command to generate that altar on dungeon level 1 at location 0/0 facing north on elevation 0.

The level coordinates you see in the editor represent it's position in the game world a.k.a. on the map. Do NOT mix this up! A dungeon's level number as you need it in the spawn command is represented by it's entry in the level list. Dungeon level 1 is the first entry, level 2 is the second entry and so on.

Let's have a look at the main campaign.
Shipwreck Beach is the level you start the game on. Yet it's level number is not 1 but 31 when you set "debugInfo = true" in grimrock.cfg because it's entry in the level list of the campaign is at 31st position.

Re: Coordinates

Posted: Tue Jun 23, 2015 2:43 pm
by Kuro01
I understand that, I,m trying to figure out how to get the altar to spawn on the side dungeons. If i set the script in level 1.0.0 "level 1" the altar will spawn
in level 0.0.0. "level 1"where the coordinates specify. If i set it directly below 0.0.1 "level 2" it works fine. Won't recognize the side dungeons.

Does it only work on center levels like old Grimrock?

Re: Coordinates

Posted: Tue Jun 23, 2015 3:00 pm
by Dr.Disaster
You need to count down your level list to get the correct number for your spawn command.

(a/b/c) level 1 -> spawn("altar",1,x,y,facing,elevation)
(a/d/c) level 2 -> spawn("altar",2,x,y,facing,elevation)

and so on

Re: Coordinates

Posted: Tue Jun 23, 2015 3:07 pm
by Kuro01
Thanks you were very helpful I solved the problem