Page 1 of 1

Beacons and Essences?

Posted: Wed Feb 25, 2015 11:21 pm
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?

Re: Beacons and Essences?

Posted: Sun Mar 22, 2015 11:15 pm
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