portal like teleport

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!
Azel
Posts: 808
Joined: Thu Nov 06, 2014 10:40 pm

Re: portal like teleport

Post by Azel »

Eleven Warrior wrote:Hi all I don't know if anyone else has found this but it's very funny. When you walk through the Portal it will take you to the Script Entity Location.

Thxs to Issac for helping me with this script, although the move bit is strange and was hoping AH would be able to help out here.

1 - Put this code into script entity name does not matter. place in it one square of your choice (NOT WALL) floor.
2 - Put a portal on the map named: portal_1.
3 - Walk through the portal, when the fade finishes, press the ( h ) key and move in any direction. Now we are on the Moon walking Slow Mo lol.

Code: Select all

portal_1:removeComponent("portal")
         portal_1:createComponent("Portal")
            :addConnector("onArrival", self.go.id, "arrivalHook");

 function arrivalHook()      
         party:setPosition(self.go.x, self.go.y, self.go.facing, self.go.elevation, self.go.level)
         GameMode.fadeIn(0xffffff,1)  --Fade in from white, over a 1 second duration.
               GameMode.setGameFlag("DisableMovement",false) --added this Issac lol--
 end
I played someone else's Mod not too long ago and sent them a PM about how I was able to walk around in the dark after going through their Portal. It was kinda fun actually; thought it was another puzzle :o
User avatar
Eleven Warrior
Posts: 736
Joined: Thu Apr 18, 2013 2:32 pm
Location: Australia

Re: portal like teleport

Post by Eleven Warrior »

Mr Issac. Ok mate i'll try that solution, sounds good to me :) It's a shame that AH did not make the portal do a simular thing as the teleporter, but all good :)
User avatar
Isaac
Posts: 3172
Joined: Fri Mar 02, 2012 10:02 pm

Re: portal like teleport

Post by Isaac »

Eleven Warrior wrote:Mr Issac. Ok mate i'll try that solution, sounds good to me :) It's a shame that AH did not make the portal do a simular thing as the teleporter, but all good :)
We'll see if we get a developer comment; it might be a bug, or already have a solution that none of us know about. The only snag with my solution is that the portal occupies a cell, and no longer behaves like a doorway.
User avatar
Eleven Warrior
Posts: 736
Joined: Thu Apr 18, 2013 2:32 pm
Location: Australia

Re: portal like teleport

Post by Eleven Warrior »

Bump: Err Shit Ah helppppppppppppppppppppppppppppppppppp
Granamir
Posts: 202
Joined: Wed Jan 07, 2015 7:19 pm

Re: portal like teleport

Post by Granamir »

Sorry guys i'm out of business for some days more.
In meanwile, since seems portal has his own camera, is there a way to move/control it?
TY
User avatar
AndakRainor
Posts: 674
Joined: Thu Nov 20, 2014 5:18 pm

Re: portal like teleport

Post by AndakRainor »

Hey! With Minmay's findings here, the portal problems are over.

Here is my teleportal object:

Code: Select all

defineObject{
  name = "teleportal",
  components = {
    {
      class = "Model",
      name = "frame",
      model = "assets/models/env/portal_frame.fbx",
      staticShadow = true,
    },
    {
      class = "Portal",
      onArrival = function(self)
        local dest = self.go.script:get(self.go.script:get("destination") or 1) or {x=0,y=0,e=0,l=0}
        party:setPosition(dest.x, dest.y, party.facing, dest.e, dest.l)
        GameMode.fadeIn(0xffffff,1)
        GameMode.setEnableControls(true)
        --print("time multiplier value was "..GameMode.getTimeMultiplier())
        GameMode.setTimeMultiplier(1)
      end,
    },
    {
      class = "Light",
      offset = vec(0, 1, 0),
      type = "point",
      color = vec(0.9, 1.0, 1.3),
      brightness = 12,
      range = 6,
      castShadow = true,
      onUpdate = function(self)
        local noise = math.noise(Time.currentTime()*1 + 123) * 0.5 + 0.9
        self:setBrightness(noise * 15)
      end,
    },
    {
      class = "Particle",
      particleSystem = "portal_particles",
      emitterMesh = "assets/models/env/portal_rim_emitter.fbx",
    },
    {
      class = "Particle",
      name = "particle2",
      particleSystem = "portal_particles_radial",
      emitterMesh = "assets/models/env/portal_radial_emitter.fbx",
    },
    {
      class = "Model",
      name = "portalBeam",
      model = "assets/models/env/portal_beam.fbx",
    },
    {
      class = "Model",
      name = "planeModel",
      model = "assets/models/env/portal_plane.fbx",
    },
    {
      class = "Script",
      source = [[
        data = {{x=0,y=0,e=0,l=0},{x=0,y=0,e=0,l=0}}
        function dest1() self.data["destination"] = 1 end
        function dest2() self.data["destination"] = 2 end
        function get(self,name) return self.data[name] end
        function set(self,name,value) self.data[name] = value end
      ]],      
    },
    {
      class = "ScriptController",
      name = "controller",
    },
  },
  placement = "wall",
  tags = { "door" },
  editorIcon = 124,
  automapIcon = 84,
}
User avatar
Eleven Warrior
Posts: 736
Joined: Thu Apr 18, 2013 2:32 pm
Location: Australia

Re: portal like teleport

Post by Eleven Warrior »

Well I say...... Bloody good job mate and thxs for this :)
kelly1111
Posts: 349
Joined: Sun Jan 20, 2013 6:28 pm

Re: portal like teleport

Post by kelly1111 »

AndakRainor wrote: Sat Mar 19, 2016 8:58 pm Hey! With Minmay's findings here, the portal problems are over.

Here is my teleportal object:

Code: Select all

defineObject{
  name = "teleportal",
  components = {
    {
      class = "Model",
      name = "frame",
      model = "assets/models/env/portal_frame.fbx",
      staticShadow = true,
    },
    {
      class = "Portal",
      onArrival = function(self)
        local dest = self.go.script:get(self.go.script:get("destination") or 1) or {x=0,y=0,e=0,l=0}
        party:setPosition(dest.x, dest.y, party.facing, dest.e, dest.l)
        GameMode.fadeIn(0xffffff,1)
        GameMode.setEnableControls(true)
        --print("time multiplier value was "..GameMode.getTimeMultiplier())
        GameMode.setTimeMultiplier(1)
      end,
    },
    {
      class = "Light",
      offset = vec(0, 1, 0),
      type = "point",
      color = vec(0.9, 1.0, 1.3),
      brightness = 12,
      range = 6,
      castShadow = true,
      onUpdate = function(self)
        local noise = math.noise(Time.currentTime()*1 + 123) * 0.5 + 0.9
        self:setBrightness(noise * 15)
      end,
    },
    {
      class = "Particle",
      particleSystem = "portal_particles",
      emitterMesh = "assets/models/env/portal_rim_emitter.fbx",
    },
    {
      class = "Particle",
      name = "particle2",
      particleSystem = "portal_particles_radial",
      emitterMesh = "assets/models/env/portal_radial_emitter.fbx",
    },
    {
      class = "Model",
      name = "portalBeam",
      model = "assets/models/env/portal_beam.fbx",
    },
    {
      class = "Model",
      name = "planeModel",
      model = "assets/models/env/portal_plane.fbx",
    },
    {
      class = "Script",
      source = [[
        data = {{x=0,y=0,e=0,l=0},{x=0,y=0,e=0,l=0}}
        function dest1() self.data["destination"] = 1 end
        function dest2() self.data["destination"] = 2 end
        function get(self,name) return self.data[name] end
        function set(self,name,value) self.data[name] = value end
      ]],      
    },
    {
      class = "ScriptController",
      name = "controller",
    },
  },
  placement = "wall",
  tags = { "door" },
  editorIcon = 124,
  automapIcon = 84,
}
can someone explain to me, what i have to fill into the script to get it working. I cant seem to get it to work for me?

data = {{x=0,y=0,e=0,l=0},{x=0,y=0,e=0,l=0}}
function dest1() self.data["destination"] = 1 end
function dest2() self.data["destination"] = 2 end
function get(self,name) return self.data[name] end
function set(self,name,value) self.data[name] = value end
Post Reply