Beacon essence script
Posted: Sun Jun 28, 2015 4:43 pm
Could someone tell me how to make the air beacon only accept the air essence. Thanks Ian
Official Legend of Grimrock Forums
https://mail.almosthumangames.com/forum/
https://mail.almosthumangames.com/forum/viewtopic.php?t=10037
Hi Ian,ian363 wrote:Could someone tell me how to make the air beacon only accept the air essence. Thanks Ian
Code: Select all
`defineObject{
name = "beacon__only_air",
baseObject = "base_obstacle",
components = {
{
class = "Model",
model = "assets/models/env/elemental_holder_air.fbx",
staticShadow = true,
},
{
class = "Light",
offset = vec(0, 1.2, -1.1),
range = 6,
color = vec(0.4, 0.5, 1),
brightness = 8,
castShadow = false,
staticShadows = false,
fadeOut = 0,
onUpdate = function(self)
local socket = self.go.socket
if socket:count() > 0 then
local it = socket:getItem()
if it.go.name == "essence_air" then
it.go:setWorldPositionY(0.85 + math.sin(Time.currentTime()) * 0.05)
--elseif it:hasTrait("essence") then -----------HERE: this is not any more useful
-- it.go:setWorldPositionY(0.75)
end
end
end,
},
{
class = "Sound",
sound = "essence_ambient",
fadeOut = 0,
},
{
class = "Clickable",
offset = vec(0.0, 1.1, -1.1),
size = vec(0.6, 0.6, 0.1),
maxDistance = 1,
frontFacing = true,
--debugDraw = true,
},
{
class = "Socket",
offset = vec(0, 0.85, -1.1),
onAcceptItem = function(self, item)
return (item.go.name == "essence_air") and self:count() == 0 ---HERE:this limits beacon to "essence_air"
end,
onInsertItem = function(self, item)
if item.go.name == "essence_air" then
self.go.light:fadeIn(1)
self.go.sound:fadeIn(1)
end
end,
onRemoveItem = function(self, item)
if item.go.name == "essence_air" then
self.go.light:fadeOut(1)
self.go.sound:fadeOut(1)
end
end,
--debugDraw = true,
},
},
--placement = "wall",
--editorIcon = 88,
}You are correct that the essence needs to be correct to visually light the beacon but any essence will trigger the 'connector', say open a door. This means you only need one essence to make all beacons work. In the original game all four beacons had to be active to open the castle door but I'm using them individually to do something.minmay wrote:It DOES only react to the right essence in the first place. If the wrong essence is placed in the socket then it won't bob up and down.
And it is simple, but you need to know at least a little bit of programming and Lua to do anything significant in Grimrock mods.
So? Just connect the connector to a script_entity and check for the specific essence there.ian363 wrote:You are correct that the essence needs to be correct to visually light the beacon but any essence will trigger the 'connector', say open a door. This means you only need one essence to make all beacons work. In the original game all four beacons had to be active to open the castle door but I'm using them individually to do something.minmay wrote:It DOES only react to the right essence in the first place. If the wrong essence is placed in the socket then it won't bob up and down.
And it is simple, but you need to know at least a little bit of programming and Lua to do anything significant in Grimrock mods.
Yes, that was the whole point of the thread in the first place but I don't know much about scripts and I'm not sure how to edit the script I was given earlier. Also it doesn't change the fact that it would be a lot simpler if the beacon only reacted to the right essence.minmay wrote:So? Just connect the connector to a script_entity and check for the specific essence there.ian363 wrote:You are correct that the essence needs to be correct to visually light the beacon but any essence will trigger the 'connector', say open a door. This means you only need one essence to make all beacons work. In the original game all four beacons had to be active to open the castle door but I'm using them individually to do something.minmay wrote:It DOES only react to the right essence in the first place. If the wrong essence is placed in the socket then it won't bob up and down.
And it is simple, but you need to know at least a little bit of programming and Lua to do anything significant in Grimrock mods.
If you want to do that, it's very easy:ian363 wrote:Thank you for the info but this is a bit beyond me. I don't know how to edit an item and I'm not sure what I would need to alter for the earth, fire and water beacons to work. I was hoping it would be simple. I wonder why they made it work this way, I would have the beacon only react to the right essence in the first place. Thanks once again Ian
Thanks I'll give it a go for a future game but I've decided to be stubborn and use no scripts this time. I think I've become obsessed with making things work without them, yes madness. Thanks again Ian.Duncan1246 wrote:If you want to do that, it's very easy:ian363 wrote:Thank you for the info but this is a bit beyond me. I don't know how to edit an item and I'm not sure what I would need to alter for the earth, fire and water beacons to work. I was hoping it would be simple. I wonder why they made it work this way, I would have the beacon only react to the right essence in the first place. Thanks once again IanThe solution of an external script is also possible, as Minmay says, but it's also programming...
- In your mod folder, open the file objects.lua in mod_assets with a text editor (EditPad Lite, by exemple, it's free)
Copy the code in my previous mail and paste it in objects.lua
Save the file, reload your mod: the new object "beacon_only_air" will appear in the editor object window
Use it instead of "beacon_air" when you needs it, that's all