Page 258 of 391

Re: Ask a simple question, get a simple answer

Posted: Mon Oct 15, 2018 9:59 pm
by Isaac
Next time, you should use jpegs intead of png images for 'throw-away' examples. The PNGs are lossless, and can be more than ten times the size of a jpeg version. ;)
___________

For what you are doing, you need not use setWorldPosition() on the object. Instead use the object's model, and clickable component offset properties.

Example:

Code: Select all

-- Placed in a script_entity for a one-shot effect 
-- Either rename your lock to side_door_lock_1, or change the ID in the script to that of your lock.

side_door_lock_1.model:setOffset(vec(-1.45,-1.3,-0.2))
side_door_lock_1.clickable:setOffset(vec(-1.45,-1.3,-0.2))

Code: Select all

-- Add to both the model and clickable component definitions for a reusable lock asset.
offset = vec(-1.45,-1.3,-0.2),

Re: Ask a simple question, get a simple answer

Posted: Mon Oct 15, 2018 10:46 pm
by Zo Kath Ra
setWorldPosition() moves both the model and the clickable components.
I've tested this with setDebugDraw(true)

So why doesn't setWorldPosition() work?

Re: Ask a simple question, get a simple answer

Posted: Mon Oct 15, 2018 10:59 pm
by Pompidom
setWorldPosition worx perfect for stuff like this and I doubt that you're clicking on the"invisible" lock

I see a multitude of potential issues in your screenshot.

First of all, the door. When you take your key to the lock on the left, you're not clicking on the keyhole, but on the clickable component of that door as the clickable component of the lock is probably behind it. you can disable this and check to see if it works.

Second, when placing locks like that, make sure you place them in front making them stick out towards the party.
Test if you can use it and then keep adjusting slightly the lock's position back into the wall until you can't access the clickable component of the lock by mouse clicks. If you move it too far into the wall like on the screenshot it will never be clickable in the first place.

So what I think what's happening is that you're simply opening the door by clicking on the door which is a possibility with that specific door as it's the swinging door with opening/closing animation.

I hope you understand what I'm trying to explain :)

I have developed many workarounds myself in these types of situations in my own mod.

Just place the lock to the left like you did, but make it float in the air in front of the door and then slowly adjust values and see how far you can place it into the wall before the clickable component of the lock is blocked. And that's the position where you can offset your lock.clickable component thing.

Or just do what Isaac told you. Which is basically the short version of my long post.

Re: Ask a simple question, get a simple answer

Posted: Tue Oct 16, 2018 4:00 am
by KhrougH
Pompidom wrote: Mon Oct 15, 2018 10:59 pm First of all, the door. When you take your key to the lock on the left, you're not clicking on the keyhole, but on the clickable component of that door as the clickable component of the lock is probably behind it. you can disable this and check to see if it works.
i already disabled the clickable component on door:

Code: Select all

DL_1 = true
portadecasa_1.clickable:addConnector('onClick', self.go.id, 'lockdestroy')

function lockdestroy()
	if DL_1 == true then
		DL_1 = false
		doorlock_1:destroy()
	end
end

function serratura1()
	portadecasa_1.clickable:enable()
end
on activate the lock is connected to "function serratura1()"
than the door is still close. you can now click on the door to open it and the lock will destroy.

Re: Ask a simple question, get a simple answer

Posted: Tue Oct 16, 2018 6:05 am
by KhrougH
Isaac wrote: Mon Oct 15, 2018 9:59 pm Next time, you should use jpegs intead of png images for 'throw-away' examples. The PNGs are lossless, and can be more than ten times the size of a jpeg version. ;)
___________

For what you are doing, you need not use setWorldPosition() on the object. Instead use the object's model, and clickable component offset properties.

Example:

Code: Select all

-- Placed in a script_entity for a one-shot effect 
-- Either rename your lock to side_door_lock_1, or change the ID in the script to that of your lock.

side_door_lock_1.model:setOffset(vec(-1.45,-1.3,-0.2))
side_door_lock_1.clickable:setOffset(vec(-1.45,-1.3,-0.2))

Code: Select all

-- Add to both the model and clickable component definitions for a reusable lock asset.
offset = vec(-1.45,-1.3,-0.2),
right, JPEG instead PNG...
about the code, your suggestion was good
here is the code now:

Code: Select all

for i = 1, 100 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
it looks nice to me but maybe you have a better suggestion.

Re: Ask a simple question, get a simple answer

Posted: Tue Oct 16, 2018 8:42 am
by Isaac
My suggestion was two, depending on your situation. If you are planning to have several of these locks, then you should define the lock as a custom object, and add the offset values into both the model, and clickable components; that way the change is automatic when loaded.

Example:

Code: Select all

defineObject{
	name = "side_door_lock",
	components = {
		{
			class = "Model",
			model = "assets/models/env/wall_lock.fbx",
			offset = vec(-1.45,-1.3,-0.2),
			staticShadow = true,
		},
		{
			class = "Clickable",
			offset = vec(-1.45,-1.3,-0.2),
			size = vec(0.4, 0.4, 0.4),
			--debugDraw = true,
		},
		{
			class = "Lock",
			sound = "key_lock",
		},
	},
	placement = "wall",
	editorIcon = 20,
}

Re: Ask a simple question, get a simple answer

Posted: Tue Oct 16, 2018 3:40 pm
by KhrougH
Isaac wrote: Tue Oct 16, 2018 8:42 am My suggestion was two, depending on your situation. If you are planning to have several of these locks, then you should define the lock as a custom object, and add the offset values into both the model, and clickable components; that way the change is automatic when loaded.
i would like to use this thing with different locks, so i prefer a script into the map instead making other 10 different defineObject.
and with my script i don't have to set the offset for every lock. the routine identify itself.
but i would also do the same (or something similar with the door to open.
so, instead connecting every lock with the relative function:

Code: Select all

function serratura1()
	openingDoor_1.clickable:enable()
end

function serratura2()
	openingDoor_2.clickable:enable()
end

function serratura3()
	openingDoor_3.clickable:enable()
end
--then many others
i would like to identify the lock i just unlocked and than enabling the relative clickable "openingDoor_"..n
there's any way i can do this?
i still have some problem understanding how to use the "go" things (lock.go.id , for example). why it doesn't works?

Re: Ask a simple question, get a simple answer

Posted: Tue Oct 16, 2018 3:50 pm
by KhrougH
and now i have a new annoying question :lol: :lol: :lol:
sorry, guys.

I copied and modified a defineObject. a table that was placed on the floor i wanted to place on the wall so it can stand between two tiles. so this is the original:

Code: Select all

defineObject{
	name = "sx_town_table_02",
	baseObject = "base_altar",
	components = {
	{
			class = "Model",
			model = "mod_assets/sx_towntileset/models/sx_town_table_02.fbx",
			staticShadow = true,
	},
	},
	automapIcon = 152,
	tags = { "sx", "town" },
}
and this is the new defineObject:

Code: Select all

defineObject{
	name = "sx_town_table_03_onwall",
	baseObject = "base_altar",
	components = {
	{
			class = "Model",
			model = "mod_assets/sx_towntileset/models/sx_town_table_02.fbx",
			offset = vec(0, 0, -0.5),
			staticShadow = true,
	},
	},
	placement = "wall",
	automapIcon = 152,
	tags = { "sx", "town" },
}
it works, but i can't stand on both sides of the "walled" table. i can on a side, but the tile the table is facing i still can't stand.
picture (JPEG as ISAAC suggested :D )

https://drive.google.com/open?id=1J1oSq ... ctV_ORGIn6
how can I adjust this thing?

Re: Ask a simple question, get a simple answer

Posted: Tue Oct 16, 2018 4:01 pm
by Pompidom
https://ibb.co/h5isQf

I have a sx_town_table_2 that does the job

Re: Ask a simple question, get a simple answer

Posted: Tue Oct 16, 2018 4:05 pm
by KhrougH
Pompidom wrote: Tue Oct 16, 2018 4:01 pm https://ibb.co/h5isQf

I have a sx_town_table_2 that does the job
did you modified the original?