Ask a simple question, get a simple answer
Re: Ask a simple question, get a simple answer
I believe I got this from an old asset pack from bongo. If you go back a few pages in this topic, you will find the link where I was asking about shadow removers. I will be available tonight for further help. As i have to go now somewhere and can't reply.
edit: viewtopic.php?f=22&t=9320&hilit=bongobeat+assets
edit: viewtopic.php?f=22&t=9320&hilit=bongobeat+assets
Last edited by Pompidom on Tue Oct 16, 2018 5:19 pm, edited 1 time in total.
Re: Ask a simple question, get a simple answer
Hi All
I have found a 'defineObject' for a re-useable lock:
defineObject{
name = "re-usable_lock",
components = {
{
class = "Model",
model = "assets/models/env/wall_lock.fbx",
offset = vec(0, 1.375, 0),
staticShadow = true,
},
{
class = "Clickable",
offset = vec(0, 1.375, 0),
size = vec(0.4, 0.4, 0.4),
--debugDraw = true,
},
{
class = "Lock",
onActivate = function(self)
self:enable()
sound = "key_lock",
end
},
},
placement = "wall",
editorIcon = 20,
}
but when I put it in my objects.lua I get an error: mod_assets/scripts/object.lua:27: unexpected symbol near 'end'
Is there something wrong with the code? any help pls.
I have found a 'defineObject' for a re-useable lock:
defineObject{
name = "re-usable_lock",
components = {
{
class = "Model",
model = "assets/models/env/wall_lock.fbx",
offset = vec(0, 1.375, 0),
staticShadow = true,
},
{
class = "Clickable",
offset = vec(0, 1.375, 0),
size = vec(0.4, 0.4, 0.4),
--debugDraw = true,
},
{
class = "Lock",
onActivate = function(self)
self:enable()
sound = "key_lock",
end
},
},
placement = "wall",
editorIcon = 20,
}
but when I put it in my objects.lua I get an error: mod_assets/scripts/object.lua:27: unexpected symbol near 'end'
Is there something wrong with the code? any help pls.
Re: Ask a simple question, get a simple answer
Your script have to show like this:
Then you have to replace the line "sound = "key_lock",". Set it direct after "class = "Lock",".
That should be all.
Don´t use a "minus" in your names. It will crash the editor (like it did in my place).defineObject{
name = "reusable_lock",
components = {
{
class = "Model",
model = "assets/models/env/wall_lock.fbx",
offset = vec(0, 1.375, 0),
staticShadow = true,
},
{
class = "Clickable",
offset = vec(0, 1.375, 0),
size = vec(0.4, 0.4, 0.4),
--debugDraw = true,
},
{
class = "Lock",
sound = "key_lock",
onActivate = function(self)
self:enable()
end
},
},
placement = "wall",
editorIcon = 20,
}
Then you have to replace the line "sound = "key_lock",". Set it direct after "class = "Lock",".
That should be all.
Re: Ask a simple question, get a simple answer
It's a time-saver to do it as definitions; they don't need scripted adjustment.
Alternatively, you can change the visual appearance of any lock by assigning it a different lock model via script.
Code: Select all
side_door_lock_1.model:setModel("assets/models/env/wall_lock_ornament.fbx")
side_door_lock_2.model:setModel("assets/models/env/wall_lock_golden.fbx")
side_door_lock_3.model:setModel("assets/models/env/wall_lock_gear.fbx")
Re: Ask a simple question, get a simple answer
Hi maneus thx for your speedy reply, all OK now
Re: Ask a simple question, get a simple answer
Isaac wrote: ↑Tue Oct 16, 2018 8:47 pmIt's a time-saver to do it as definitions; they don't need scripted adjustment.
Alternatively, you can change the visual appearance of any lock by assigning it a different lock model via script.Code: Select all
side_door_lock_1.model:setModel("assets/models/env/wall_lock_ornament.fbx") side_door_lock_2.model:setModel("assets/models/env/wall_lock_golden.fbx") side_door_lock_3.model:setModel("assets/models/env/wall_lock_gear.fbx")
Oh, my gosh...
I have so much to learn!!!
[...]
All those moments will be lost in time, like tears in rain.
Time to die.
All those moments will be lost in time, like tears in rain.
Time to die.
Re: Ask a simple question, get a simple answer
Ok, it sounds good but than i could also randomize the lock's model but than i need to recognize it for using the correct key.Isaac wrote: ↑Tue Oct 16, 2018 8:47 pm Alternatively, you can change the visual appearance of any lock by assigning it a different lock model via script.Code: Select all
side_door_lock_1.model:setModel("assets/models/env/wall_lock_ornament.fbx") side_door_lock_2.model:setModel("assets/models/env/wall_lock_golden.fbx") side_door_lock_3.model:setModel("assets/models/env/wall_lock_gear.fbx")
Or changing models also change the usable key?
[...]
All those moments will be lost in time, like tears in rain.
Time to die.
All those moments will be lost in time, like tears in rain.
Time to die.
Re: Ask a simple question, get a simple answer
Every object has a name (usually different from its ID). The ID can be anything, but is commonly either a number, or the name with a number appended to it. To identify an object, you inspect its ID, and possibly its name. The script that your locks are connected to receives a reference to the lock (as its first argument) when gets called. You can use this variable name while in the function to access the lock's name, id, and any of its other properties; you can assign changes to the object through this.
__________
If you tell us exactly what behavior it is that you need, then the member suggestions for how to achieve it can be given with an understanding of the effect that you want—and choose the most suitable methods for it.
__________
The way to adjust the locks is to use a script with a table in it that contains matched pairs of model, and key. That way each lock can be set with an appearance, and its proper key.
{"wall_lock_ornament", "ornate_key", "dungeon_iron_door_14"}
__________
If you tell us exactly what behavior it is that you need, then the member suggestions for how to achieve it can be given with an understanding of the effect that you want—and choose the most suitable methods for it.
__________
The way to adjust the locks is to use a script with a table in it that contains matched pairs of model, and key. That way each lock can be set with an appearance, and its proper key.
- side_door_lock_1.model:setModel("assets/models/env/wall_lock_ornament.fbx")
- side_door_lock_1.model:setOpenedBy("ornate_key")
- side_door_lock_1.lock:addConnector("onActivate", "dungeon_iron_door_14", "open" )
{"wall_lock_ornament", "ornate_key", "dungeon_iron_door_14"}
Re: Ask a simple question, get a simple answer
you're right i'll try to be as clear as possible:
so let's say i'm setting up a town. some doors are locked.
lock is on a side and doors are clickable:disable()
i did this with a cycle, pretty easy:
SpoilerShow
Code: Select all
LOK = 100
for i = 1, LOK do
local DL = findEntity("doorlock_"..i)
local OD = findEntity("openingDoor_"..i)
if (DL or OD) == nil then
break
else
DL.model:setOffset(vec(-1.15,1.2,-0.01))
DL.clickable:setOffset(vec(-1.15,1.2,-0.01))
OD.clickable:disable()
end
end
even if you gave me several suggestion i'm still on this one because i can use it with all the locks and all the doors unless they are right named. so FOR THE MOMENT i can say is the best solution for my possibilities.
now. the next question is:
every lock is linked to a function that don't open the door, make just the door clickable:enable() .
SpoilerShow
Code: Select all
function serratura1()
openingDoor_1.clickable:enable()
end
function serratura2()
openingDoor_2.clickable:enable()
end
function serratura3()
openingDoor_3.clickable:enable()
end
function serratura4()
openingDoor_4.clickable:enable()
end
function serratura5()
openingDoor_5.clickable:enable()
end
function serratura6()
openingDoor_6.clickable:enable()
end
function serratura7()
openingDoor_7.clickable:enable()
end
I only would like to know how to make it "shorter" like for the "offsett"ing and "clickable:disable"ing.
so i can connect every lock just to one function and the function detects which lock i unlocked and open the relative door.
maybe a cycle with lock.go.id . it could identify the lock ... i was thinking about the alcove opening door with a specified object
SpoilerShow
Code: Select all
function skelAlc(surface, item)
for v,i in surface:contents() do
if i.go.name == item then return true
end
end
end
function skelOpenDoor()
if skelAlc(alcoveSkel.surface, "figure_skeleton") then
secretwall.door:open()
else
secretwall.door:close()
end
end
thanks for your patience, guys
[...]
All those moments will be lost in time, like tears in rain.
Time to die.
All those moments will be lost in time, like tears in rain.
Time to die.
Re: Ask a simple question, get a simple answer
There is a built in iterator for this.KhrougH wrote: ↑Wed Oct 17, 2018 2:45 am i did this with a cycle, pretty easy:SpoilerShowCode: Select all
LOK = 100 for i = 1, LOK do local DL = findEntity("doorlock_"..i) local OD = findEntity("openingDoor_"..i) if (DL or OD) == nil then break else DL.model:setOffset(vec(-1.15,1.2,-0.01)) DL.clickable:setOffset(vec(-1.15,1.2,-0.01)) OD.clickable:disable() end end
Code: Select all
for level = 1, Dungeon:getMaxLevels() do
for obj in Dungeon.getMap(level):allEntities() do
if not obj.chest then
if obj.lock or obj.door then
print('Name:', obj.name, "ID:", obj.id, "Level:",obj.level)
end
end
end
end
https://github.com/JKos/log2doc/wiki
** In the above (spoilered) condition: if (DL or OD) == nil then break ...end, it only breaks if DL and OD are both nil at the same time—and not when just one of them is nil. That's a crash if it ever finds one but not both.
Last edited by Isaac on Fri Oct 19, 2018 4:03 am, edited 3 times in total.