Hello all,
Newbie here (sort of, more like returning to modding after a hiatus), trying to code my way through a custom dungeon creation.
I need help with a bit of scripting, or any other way to make work what I'd like to do: A two "locks" combo to make an open trap, close.
So far, I've got the dungeon_pit installed with the "open" set.
I have a lock nearby, accepting brass_key, connected to a counter. The lock decrements the counter by one.
I have the counter, with a set number of 2, which decrements to zero when both connected locks have been activated. The counter connects to the trap to close when reaches zero.
Here's the catch: My second lock, I'd like it to be a receptor (named receptor_alpha) that works with skulls. If a skull is "inserted" in the receptor, then it decrements my counter, just like a normal lock.
So, I've been fooling around with scripting lua to get my "receptor_alpha" to accept skulls instead of blobs, and get it connected to my counter to decrements.
Not succeeding
Help???
Regards,
Zanreth
Receptor Accepting skulls
Re: Receptor Accepting skulls
I think, the predefined receptor as it is doesn't work for that, therefore it doesn't accept items. I think you have to add a socket-object on the same square which can hold your skull (and trigger your counter).
-
- Posts: 275
- Joined: Sat Jun 16, 2012 5:32 am
Re: Receptor Accepting skulls
Not sure if this is what you are looking for ( did it by head ( with help from others, who showed me stuff like this, credits goes to them)
BUt I think this will work: ( not tested)
U might wanna change the location on the wall ( height/etc etc) and link the "activate always" to ur thing/event you want to happen.
BUt I think this will work: ( not tested)
Code: Select all
defineObject{
name = "receptor_skull",
class = "Alcove",
model = "assets/models/env/spell_receptor.fbx",
replacesWall = false,
--anchorPos = vec(0, 1, -0.17),
--targetPos = vec(0,0.88,-0.25),
--targetSize = vec(0.6, 0.5, 0.6),
placement = "wall",
editorIcon = 92,
onInsertItem = function(self, item)
return item.name == "skull" and
self:getItemCount() == 0
end,
}
Re: Receptor Accepting skulls
OK, thanks guys.
I tried the script blurb from trancelistic and it doesn't seem to work. I get a "attempt to call global 'defineObject' (a nil value)" ...
Now, THOM mentionned the predefined Receptor is not designed to accept items, just blobs. I'm thinking there may be a way to change that based on the scritping references where I found the following:
"Receptor:setEntityType(entityType)" with notes that read that this sets the entity type which triggers the receptor. there's also a string that indicates how to create a connector to an asset (my counter).
Here's my script so far:
-- Skull Receptor Script
spawn("receptor",4,21,11,2,"receptor_alpha")
receptor_alpha:setEntityType("skull")
I'm not getting any error messages, but when I try to "drop" the skull "in" the receptor that was spawned by the script, it does not work ....
I tried the script blurb from trancelistic and it doesn't seem to work. I get a "attempt to call global 'defineObject' (a nil value)" ...
Now, THOM mentionned the predefined Receptor is not designed to accept items, just blobs. I'm thinking there may be a way to change that based on the scritping references where I found the following:
"Receptor:setEntityType(entityType)" with notes that read that this sets the entity type which triggers the receptor. there's also a string that indicates how to create a connector to an asset (my counter).
Here's my script so far:
-- Skull Receptor Script
spawn("receptor",4,21,11,2,"receptor_alpha")
receptor_alpha:setEntityType("skull")
I'm not getting any error messages, but when I try to "drop" the skull "in" the receptor that was spawned by the script, it does not work ....
Re: Receptor Accepting skulls
You cannot use that script in a script_entity on the map. To use that script, you must place it in the object.lua file in your project's script folder. The script defines a new object for the editor. Open the file in a text editor, paste the code, and save.zanreth wrote:OK, thanks guys.
I tried the script blurb from trancelistic and it doesn't seem to work. I get a "attempt to call global 'defineObject' (a nil value)" ...
*You will need to reload your project after editing the object.lua file, in order for this to update and show in the editor. Once loaded, there will be a new placeable object called "receptor_skull".
-
- Posts: 275
- Joined: Sat Jun 16, 2012 5:32 am
Re: Receptor Accepting skulls
Thanks Isaac. I just tested the script at my house. It works perfectly.
Zanreth copy this code
and place it in /mod_assets/scripts/objects.lua.
Zanreth copy this code
Code: Select all
defineObject{
name = "receptor_skull",
class = "Alcove",
model = "assets/models/env/spell_receptor.fbx",
replacesWall = false,
anchorPos = vec(0, 1, -0.17),
targetPos = vec(0,0.88,-0.25),
targetSize = vec(0.6, 0.5, 0.6),
placement = "wall",
editorIcon = 92,
onInsertItem = function(self, item)
return item.name == "skull" and
self:getItemCount() == 0
end,
}
Re: Receptor Accepting skulls
Oh ya !! That works fine, thanks a lot everyone.
I've yet to really play with the assets scripts. So far, I've managed to do pretty much everything (keeping to basic stuff) with the existing items and logics effect. I see how scripting into the asset scripts can provide a much wider variety, and be more powerfull ...
Guess I need to learn that lua stuff
Z.
I've yet to really play with the assets scripts. So far, I've managed to do pretty much everything (keeping to basic stuff) with the existing items and logics effect. I see how scripting into the asset scripts can provide a much wider variety, and be more powerfull ...
Guess I need to learn that lua stuff
Z.