3 dimensional teleporter

Ask for help about creating mods and scripts for Grimrock 2 or share your tips, scripts, tools and assets with other modders here. Warning: forum contains spoilers!
Post Reply
User avatar
Frenchie
Posts: 219
Joined: Wed Oct 16, 2013 2:50 am

3 dimensional teleporter

Post by Frenchie »

I haven't tested if it works, but it is based on a 2-dimensional teleporter without the el variable. I don't know what the exact relation is between elevation and level and I also don't know if increment of 1 works with elevation. Of course if you move to a spot with nothing underneath you should fall and get fall damage.

Code: Select all

function Move(st,el)
fa = party.facing le = party.level xx = party.x yy = party.y zz = party.elevation dx, dy = getForward(fa)
if el == nil then el = 0
party:setPosition(xx + dx * st, yy + dy * st, fa, zz+el, le)
end
Move(1) moves you 1 step forward, Move(0,1) should move you 1 elevation up and Move(1,1) should do both. If you want to move up but not fall use spawn("magic_bridge").item:setPosition(xx + dx * st, yy + dy * st, fa, zz+el, le) first. This might become an obstacle later, so to remove it a timer could be used. Maybe it can become the 3rd variable br in Move(st,el,br) but that is above my lua knowledge.

Any help to make it complete and working is appreciated.
User avatar
Isaac
Posts: 3189
Joined: Fri Mar 02, 2012 10:02 pm

Re: 3 dimensional teleporter

Post by Isaac »

Frenchie wrote:I don't know what the exact relation is between elevation and level and I also don't know if increment of 1 works with elevation.
Elevation [as I understand it], is any height from 7 to -7; with the default of 0. Elevation is used on maps that have different floor heights... (usually where you see ladders). Elevation is relative to the default floor of a map, and unrelated to locations on adjacent maps. *And it only works with integers, not floats. :(

You can have teleporters that transport to different elevations on the same map; (or to others) .
User avatar
Frenchie
Posts: 219
Joined: Wed Oct 16, 2013 2:50 am

Re: 3 dimensional teleporter

Post by Frenchie »

Elevation is used on maps that have different floor heights
But can elevation + 1 lead you to an upper level as well? If you have a level above your current level and both lead to a bigger multi elevation room, then elevation = level. When the upper level is not above the current one, but still lead to the same bigger multi elevation room, then level = map or is it still the current level with a higher elevation?
minmay
Posts: 2790
Joined: Mon Sep 23, 2013 2:24 am

Re: 3 dimensional teleporter

Post by minmay »

Isaac wrote:
Frenchie wrote:I don't know what the exact relation is between elevation and level and I also don't know if increment of 1 works with elevation.
Elevation [as I understand it], is any height from 7 to -7; with the default of 0.
Elevation is not constrained to +-7, only floor/ceiling height is. Objects placed at elevation values outside that range work fine (inf, -inf, and possibly real values outside integer range will produce weird behaviour, but that doesn't matter).
Isaac wrote:*And it only works with integers, not floats. :(
Who told you that? Non-integer elevations work just like integer elevations, as far as I can tell from testing.
Grimrock 1 dungeon
Grimrock 2 resources
I no longer answer scripting questions in private messages. Please ask in a forum topic or this Discord server.
User avatar
Isaac
Posts: 3189
Joined: Fri Mar 02, 2012 10:02 pm

Re: 3 dimensional teleporter

Post by Isaac »

minmay wrote:
Isaac wrote:
Frenchie wrote:I don't know what the exact relation is between elevation and level and I also don't know if increment of 1 works with elevation.
Elevation [as I understand it], is any height from 7 to -7; with the default of 0.
Elevation is not constrained to +-7, only floor/ceiling height is. Objects placed at elevation values outside that range work fine (inf, -inf, and possibly real values outside integer range will produce weird behaviour, but that doesn't matter).
Well... At the time I was thinking of the editor. It does not allow a setting of <> -7/7, and items set to a positive fractional elevation in script fall to the [integer] floor level on load; also if you inspect those objects, the editor rewrites the elevation height and does not let you enter a fractional value. Clearly it's not intended for average use, but it is neat that a script can employ it for novel effects. :)

Code: Select all

x = 0
y = 0
tName = "gold_mask_statue_floor"
tempId = findEntity(spawn(tName).id).id

print(tempId)
function ersatzAnimator()
	 x=x+0.02%4
	 y=y+0.25%.1
	 local tId = findEntity(tempId)
	 tId:setPosition(self.go.x,self.go.y,x,(math.sin(y)*0.02+0.1), self.go.level)
end

spawn("timer",1,0,0,0,0,"animation")
animation.timer:setTimerInterval(0.03)
animation.timer:setDisableSelf(false)
animation.timer:setTriggerOnStart(false)
animation.timer:setCurrentLevelOnly(false)
animation.timer:addConnector("onActivate", self.go.id, "ersatzAnimator")
animation.timer:start()
Note: The OP was about teleporting the party, if you reposition the party at a fractional rotation, the game will do it, but it throws an error if the player clicks on anything or tries to move.
minmay
Posts: 2790
Joined: Mon Sep 23, 2013 2:24 am

Re: 3 dimensional teleporter

Post by minmay »

Yes, non-integer facing doesn't work properly. But facing and elevation are totally different.
Grimrock 1 dungeon
Grimrock 2 resources
I no longer answer scripting questions in private messages. Please ask in a forum topic or this Discord server.
Post Reply