Page 3 of 3
Re: I only have Daemon Eyes for you!
Posted: Tue Oct 23, 2012 11:34 am
by Grimwold
Ok I see what is happening... it is to do with item.id vs item.name
When I set my test version up I spawned an ordinary blue gem but gave it the id = "blue_gem_fake" so I was using item.id ==
e.g.
spawn("blue_gem",nil,nil,nil,nil,"blue_gem_fake")
However it looks like you are spawning a new item type which has name = "blue_gem_fake"... so you will need to use item.name ==
e.g.
spawn("blue_gem_fake",nil,nil,nil,nil)
So.... Hopefully this revised party script should work for your setup...
Code: Select all
cloneObject{
name = "party",
baseObject = "party",
onPickUpItem = function(party,item)
if item.name == "blue_gem_fake" then
return false
else
return true
end
end,
}
Re: I only have Daemon Eyes for you!
Posted: Tue Oct 23, 2012 11:51 am
by akroma222
LOL I so almost tried that, then thought... 'nah that is silly chris, it is the same thing!'
Clearly not though... Works like a charm!!!
Thank you good sir, much appreciated... You da man

Re: I only have Daemon Eyes for you!
Posted: Tue Oct 23, 2012 12:28 pm
by akroma222
Further to that, I have found that
Code: Select all
cloneObject{
name = "party",
baseObject = "party",
onPickUpItem = function(party,item)
if item.name == "blue_gem_fake" then
return false
end
end,
}
will also work, however, I also need to do the same for other coloured gems (green, red and maybe yellow if I can get my hands on it).
I tried:
Code: Select all
cloneObject{
name = "party",
baseObject = "party",
onPickUpItem = function(party,item)
if item.name == "blue_gem_fake" then
return false
end
end,
}
cloneObject{
name = "party",
baseObject = "party",
onPickUpItem = function(party,item)
if item.name == "green_gem_fake" then
return false
end
end,
}
cloneObject{
name = "party",
baseObject = "party",
onPickUpItem = function(party,item)
if item.name == "red_gem_fake" then
return false
end
end,
}
as well as:
Code: Select all
cloneObject{
name = "party",
baseObject = "party",
onPickUpItem = function(party,item)
if item.name == {"blue_gem_fake","green_gem_fake","red_gem_fake"} then
return false
else
return true
end
end,
}
But that ends up allowing me to pick up all of them still.... would I have to make a local gem list including all fake gems?
Sorry to ask so many questions, I am learning, but slowly

Re: I only have Daemon Eyes for you!
Posted: Tue Oct 23, 2012 12:43 pm
by Grimwold
Additonal clones of the party will not work, as each successive one will replace the previous.. You are on the right lines with the second example, but there is a problem with the setup of your IF statement.
A very basic solution, I think (but have not tested), would be
Code: Select all
if item.name == "blue_gem_fake" or item.name == "red_gem_fake" or item.name == "green_gem_fake" then
But you could script a more robust solution.... if you changed the name of the fake games to "fake_gem_xxxxx" you could check for the first 9 characters of the name as a substring. like so.
Code: Select all
if item.name:sub(1,9) == "fake_gem_" then
with this you could have any number of different fake gem types, none of which the party could pick up. The reason I would re-name the gems to do it this way is because the colours have different numbers of characters... with this way we know we can always check characters 1 to 9 for the string "fake_gem_"
I used something similar with pits called "sequence_pit_xx" to activate ALL pits that began with that ID.
Code: Select all
function openAllPits()
for i in allEntities(party.level) do
if i.id:sub(1,13) == "sequence_pit_" then
i:open()
end
end
end
Re: I only have Daemon Eyes for you!
Posted: Tue Oct 23, 2012 1:34 pm
by akroma222
Ahh beautiful!!
Changed the names to 'fake_gem_xxx' and used the - if item.name == "fake_gem_blue" or if item.name == "fake_gem_green" etc etc and it works great!! THANK YOU
Kept the fake gem name change in case I want to use the other script (pit sequnce) you have suggested too... it is a good one, I have used it to reset (open all portcullis) a gate maze that changes every time you hit a lever....
Thanks again Grimwold!! (seems you are answering my questions in more threads than just this one)
BTW nice display pic, if I am not mistaken - 'Dwarven Warriors' from either 3rd/4th ed magic core set (or Fallen Empires?)
Re: I only have Daemon Eyes for you!
Posted: Tue Oct 23, 2012 1:39 pm
by Grimwold
akroma222 wrote:Thanks again Grimwold!! (seems you are answering my questions in more threads than just this one)
BTW nice display pic, if I am not mistaken - 'Dwarven Warriors' from either 3rd/4th ed magic core set (or Fallen Empires?)
I enjoy solving scripting problems and like to help.
Dwarven Warriors indeed... artwork by Quinton Hoover... for the very first ever release of Magic: The Gathering right through to 5th Edition.
Re: I only have Daemon Eyes for you!
Posted: Tue Oct 23, 2012 1:58 pm
by akroma222
Indeed! Inspired to get up some Akroma Angel of Wrath artwork.... the pixels are restrictions are brutal so it is hard to tell it is her

Re: I only have Daemon Eyes for you!
Posted: Tue Oct 30, 2012 6:37 pm
by Komag
Is there some method to make the hook work for items already in the inventory or in hands?
I want to run a check on something right when the player left-clicks to pick up an item in the players hand, but onPickUpItem only works for items in the dungeon that the player doesn't currently have.
Re: I only have Daemon Eyes for you!
Posted: Tue Oct 30, 2012 7:02 pm
by Grimwold
I thought there was a way to do that... I remember various discussions about cursed items that cannot be dropped and about torches that cannot be held in hand... but can't find an answer to your specific situation.
Re: I only have Daemon Eyes for you!
Posted: Tue Oct 30, 2012 7:09 pm
by Komag
I found this post, but it's not quite what I'm looking for:
viewtopic.php?p=33965#p33965
I may just use a short timer (0.2 or so) to very often run the check I'm looking to run, so if a player does select an item being held in hand, the timer will soon see that it's no longer equipped.