Page 1 of 2

Beacon essence script

Posted: Sun Jun 28, 2015 4:43 pm
by ian363
Could someone tell me how to make the air beacon only accept the air essence. Thanks Ian

Re: Beacon essence script

Posted: Sun Jun 28, 2015 5:39 pm
by Duncan1246
ian363 wrote:Could someone tell me how to make the air beacon only accept the air essence. Thanks Ian
Hi Ian,
Edit "beacon_air" and modify it like this:

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,
}

Re: Beacon essence script

Posted: Sun Jun 28, 2015 6:53 pm
by ian363
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

Re: Beacon essence script

Posted: Sun Jun 28, 2015 9:11 pm
by minmay
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.

Re: Beacon essence script

Posted: Mon Jun 29, 2015 9:41 am
by ian363
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.
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.

Re: Beacon essence script

Posted: Mon Jun 29, 2015 10:03 pm
by minmay
ian363 wrote:
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.
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.
So? Just connect the connector to a script_entity and check for the specific essence there.

Re: Beacon essence script

Posted: Mon Jun 29, 2015 10:28 pm
by ian363
minmay wrote:
ian363 wrote:
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.
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.
So? Just connect the connector to a script_entity and check for the specific essence there.
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.
I understand (from other replies) you find my approach odd but not everyone knows how to write scripts and it would be simpler if they were needed as little as possible (alcove drop down menu). Anyway I have decided to be stubborn and not use scripts at all. My game is nearly complete and I'll let others decided if you can get away with not using scripts.

Re: Beacon essence script

Posted: Mon Jun 29, 2015 10:32 pm
by Duncan1246
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
If you want to do that, it's very easy:
  • 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
The solution of an external script is also possible, as Minmay says, but it's also programming... :(

Re: Beacon essence script

Posted: Mon Jun 29, 2015 10:54 pm
by ian363
Duncan1246 wrote:
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
If you want to do that, it's very easy:
  • 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
The solution of an external script is also possible, as Minmay says, but it's also programming... :(
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.

Re: Beacon essence script

Posted: Wed Jul 01, 2015 3:09 am
by Azel
There is a great many things that you can accomplish without knowing any LUA and implementing virtually zero script. Creativity goes a long way, but you also have to make sure to design the game around features that support your anti-script approach. If you want to trigger an event based on an objects unique and specific contents, then you have entered the world of scripting.

Maybe a better approach is to work with someone to write the scripts for you!