Page 1 of 1
Scripting alter.
Posted: Mon Oct 15, 2012 9:22 pm
by King Semos
I was wondering if anyone knows how to script an alter, so if a specific item on the alter is removed, it triggers an action.
Deactivate alter is too basic since you can put something on the alter and take another thing off in order to avoid the deactivating function.
Also, another, how do I script a teleporter to teleport an item from one place, to an alter. Rather than on the ground at the tile the alter is on.
Re: Scripting alter.
Posted: Mon Oct 15, 2012 9:56 pm
by Filipsan
King Semos wrote:I was wondering if anyone knows how to script an alter, so if a specific item on the alter is removed, it triggers an action.
Deactivate alter is too basic since you can put something on the alter and take another thing off in order to avoid the deactivating function.
Tick the "Activate Always" checkbox
Re: Scripting alter.
Posted: Mon Oct 15, 2012 10:00 pm
by King Semos
Filipsan wrote:
Tick the "Activate Always" checkbox
I love you.
Re: Scripting alter.
Posted: Mon Oct 15, 2012 10:01 pm
by Filipsan
King Semos wrote:
Also, another, how do I script a teleporter to teleport an item from one place, to an alter. Rather than on the ground at the tile the alter is on.
For example:
or you can use existing item

Re: Scripting alter.
Posted: Mon Oct 15, 2012 10:10 pm
by Komag
the code for "item on alcove" will be useful, just tweaked to be the opposite, so the script will always look for that item every time the altar is activated or deactivated, and if it ever doesn't find it, you make it to the action you have set up.
viewtopic.php?p=31524#p31524
probably all the different methods there could work, but just using the last one, here is how I might tweak it:
Code: Select all
-- This function returns true if the entity contains a given item.
-- It works for any entity that implements the checkIfThere() method.
function checkIfThere(entity, item) -- DON'T CHANGE ANYTHING IN THIS FUNCTION
for i in entity:containedItems() do
if i.name == item then
return true
end
end
-- if we get here the item was not found
return false
end
-- example usage
function messWithAltar() -- CUSTOMIZE THIS FUNCTION HOW YOU WANT
if containsItem(komagAltar, "dagger") ~= true then
badstuff:happens!
end
end
If you are going to test for a very specific ID of an item, then put i.id in the first script and the full id instead of "dagger" in the second script.
Re: Scripting alter.
Posted: Mon Oct 15, 2012 10:16 pm
by Komag
Oh by the way, nice avatar!
Re: Scripting alter.
Posted: Mon Oct 15, 2012 11:42 pm
by King Semos
I think I understand what I'm supposed to be trying to do.
But the code isn't working, something is wrong with how I'm doing it.
Code: Select all
-- The alter
if alter_19 == empty then
altar_20:addItem(spawn("dagger"))
end
end
My goal initially was to teleport an item from one alter to another, but as Filipsan was saying I could just make the 2nd alter spawn a second version of the item, and this would be triggered when the first alter empties. Pulling off a very "Prestige" teleportation.