Ask a simple question, get a simple answer
Re: Ask a simple question, get a simple answer
yes, mimay, that's the part I understood.
but I thought, to check, if a monster exist, I ask, if it's alive.
thanks to AndakRainor I know 1) how to do it right, 2) that a monster CAN exist while being not alive.
but I thought, to check, if a monster exist, I ask, if it's alive.
thanks to AndakRainor I know 1) how to do it right, 2) that a monster CAN exist while being not alive.
Re: Ask a simple question, get a simple answer
If ratling1_1 proves to be null, then the second part of that condition will generate an error.AndakRainor wrote:Code: Select all
if ratling1_1 ~= nil and ratling1_1.monster:isAlive() then ... end
Here is a safer version of your code:
Code: Select all
if ratling1_1 != nil then
if ratling1_1.monster:isAlive() then
-- Do Something
end
end
Code: Select all
local ratling = findEntity("ratling1_1");
if ratling then
if ratling.monster:isAlive() then
-- Do Something
end
end
- AndakRainor
- Posts: 674
- Joined: Thu Nov 20, 2014 5:18 pm
Re: Ask a simple question, get a simple answer
In lua as in most other languages the "and" operator does not evaluate the second operand when the first is false
Re: Ask a simple question, get a simple answer
Ah you're right, I just tested it. Sorry, I don't trust LUA that much lol
- AndakRainor
- Posts: 674
- Joined: Thu Nov 20, 2014 5:18 pm
Re: Ask a simple question, get a simple answer
I have defined a clickable "wall". When you click on it it opens or closes. But when it is opened and an item is in mouse selection, I would like to allow the player to throw the mouse item instead of closing the wall... How could I do that ?
Re: Ask a simple question, get a simple answer
AndakRainor wrote:I have defined a clickable "wall". When you click on it it opens or closes. But when it is opened and an item is in mouse selection, I would like to allow the player to throw the mouse item instead of closing the wall... How could I do that ?
Code: Select all
onClick = function(self) if getMouseItem() then return false else self.go.door:toggle() end end,
SpoilerShow
defineObject{
name = "dungeon_click_secret_door",
baseObject = "base_secret_door",
components = {
{
class = "Model",
model = "assets/models/env/dungeon_secret_door.fbx",
staticShadow = true,
},
{
class = "Clickable",
offset = vec(0, 1.5, 0),
size = vec(1.2, 0.8, 0.2),
frontFacing = true,
onClick = function(self) if getMouseItem() then return false else self.go.door:toggle() end end,
},
},
}
name = "dungeon_click_secret_door",
baseObject = "base_secret_door",
components = {
{
class = "Model",
model = "assets/models/env/dungeon_secret_door.fbx",
staticShadow = true,
},
{
class = "Clickable",
offset = vec(0, 1.5, 0),
size = vec(1.2, 0.8, 0.2),
frontFacing = true,
onClick = function(self) if getMouseItem() then return false else self.go.door:toggle() end end,
},
},
}
- AndakRainor
- Posts: 674
- Joined: Thu Nov 20, 2014 5:18 pm
Re: Ask a simple question, get a simple answer
Thanks Isaac, that is also what I thought. But when I test this, it prevents the wall from closing, which is good, but the item is not thrown. So my problem is, whatever I tried so far, this wall, opened or not, prevents throwing items from the mouse selection because of the clickable component standing in the way.
Re: Ask a simple question, get a simple answer
Hey All!!
Where would I find the icon atlas that has all the tiny Condition icons???
Thanks
Where would I find the icon atlas that has all the tiny Condition icons???
Thanks
Labyrinth of Lies (viewtopic.php?f=14&t=4400)
Legacy of Lies (viewtopic.php?f=22&t=12983&hilit=+legacy)
Legacy of Lies (viewtopic.php?f=22&t=12983&hilit=+legacy)
Re: Ask a simple question, get a simple answer
Hmmm...AndakRainor wrote:Thanks Isaac, that is also what I thought. But when I test this, it prevents the wall from closing, which is good, but the item is not thrown. So my problem is, whatever I tried so far, this wall, opened or not, prevents throwing items from the mouse selection because of the clickable component standing in the way.
When I test this, the wall opens or closes ~unless there is an object on the mouse cursor; in which case the door ignores the click, and depending on the hight of the cursor, the object is either placed on the floor, or thrown.
Is there a notable between your defined door, and the one in my post? (in the spoiler tag)
Edit: Aha... It seems to involve the clickable region; as can be seen with debugDraw = true, in the clickable component.
- AndakRainor
- Posts: 674
- Joined: Thu Nov 20, 2014 5:18 pm
Re: Ask a simple question, get a simple answer
The offset of the clickable component is the same, but not its size. I will try different sizes tonight and see if I get a better result.