Beacons and Essences?

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
Level12Teleport
Posts: 1
Joined: Thu Feb 19, 2015 4:14 am

Beacons and Essences?

Post by Level12Teleport »

So I have been trying to utilize an "Insert proper item in alcove" type section in a mod I'm working on using a script I found on here

Code: Select all

function surfaceContains(surface, item)
   for v,i in surface:contents() do
   if i.go.name == item then return true
   end
end
end

function openPowerGemDoor()
   if surfaceContains(airbeacon.surface, "essence_air") then
   doorwoods.door:open()
   else
  doorwoods.door:close()
   end
end
The only problem is when I place an air essence on the beacon it just disappears entirely, the sound and light changes as if it is hovering on the pedestal but my door doesn't open and the essence disappears. I tried again on a beacon without the script attached and the essence just disappears every time I try placing it on any beacon, is this a problem in using beacons specifically? what is a way around this?



EDIT: I fixed the script problem, I just switched every word surface in the scrip to the word socket because the beacons appear to not actually have a surface, instead they have sockets and it worked, however the essence still disappears upon placing in socket instead of floating above it like expected. anyone know why?
User avatar
Duncan1246
Posts: 404
Joined: Mon Jan 19, 2015 7:42 pm

Re: Beacons and Essences?

Post by Duncan1246 »

Level12Teleport wrote:So I have been trying to utilize an "Insert proper item in alcove" type section in a mod I'm working on using a script I found on here

The only problem is when I place an air essence on the beacon it just disappears entirely, the sound and light changes as if it is hovering on the pedestal but my door doesn't open and the essence disappears. I tried again on a beacon without the script attached and the essence just disappears every time I try placing it on any beacon, is this a problem in using beacons specifically? what is a way around this?



EDIT: I fixed the script problem, I just switched every word surface in the scrip to the word socket because the beacons appear to not actually have a surface, instead they have sockets and it worked, however the essence still disappears upon placing in socket instead of floating above it like expected. anyone know why?
If you read the beacon definition, you see this hook:

Code: Select all

onUpdate = function(self)
				local socket = self.go.socket
				if socket:count() > 0 then
					local it = socket:getItem()
					if it.go.name == "essence_fire" then
						it.go:setWorldPositionY(0.85 + math.sin(Time.currentTime()) * 0.05)
					elseif it:hasTrait("essence") then
						it.go:setWorldPositionY(0.75)
					end
				end
			end,
setWorldposition is used with a value between 0.8 and 0.9; each elevation take place between 0 and 3, so the essence appears above the socket ONLY if elevation is 0! If your beacon is by exemple at elevation 3, make a clone object like this: (sorry! here, in a castle elevation, count 4 by elevation, not 3 ) :o

Code: Select all

cloneObject{
	name = "beacon_balance_elev3",
	baseObject = "beacon_balance",
	components = {
		
		{
			class = "Light",
			
			onUpdate = function(self)
				local socket = self.go.socket
				if socket:count() > 0 then
					local it = socket:getItem()
					if it.go.name == "essence_balance" then
						it.go:setWorldPositionY(12.85 + math.sin(Time.currentTime()) * 0.05)
					elseif it:hasTrait("essence") then
						it.go:setWorldPositionY(12.75)
					end
				end
			end,
		},
	},
	
}
and it's done! :mrgreen:
PS. for clone object, see JKos thread
The Blue Monastery (LOG1)
download at:http://www.nexusmods.com/grimrock/mods/399/?

Finisterrae(LOG2)
download at:http://www.nexusmods.com/legendofgrimrock2/mods/61/?
Post Reply