Scripting alter.

Talk about creating Grimrock 1 levels and mods here. Warning: forum contains spoilers!
Post Reply
User avatar
King Semos
Posts: 123
Joined: Sun Apr 15, 2012 6:05 pm

Scripting alter.

Post 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.
User avatar
Filipsan
Posts: 84
Joined: Fri Mar 16, 2012 10:18 am

Re: Scripting alter.

Post 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
User avatar
King Semos
Posts: 123
Joined: Sun Apr 15, 2012 6:05 pm

Re: Scripting alter.

Post by King Semos »

Filipsan wrote: Tick the "Activate Always" checkbox
:oops:

I love you.
User avatar
Filipsan
Posts: 84
Joined: Fri Mar 16, 2012 10:18 am

Re: Scripting alter.

Post 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:

Code: Select all

altar_1:addItem(spawn("dagger"))
or you can use existing item :)
User avatar
Komag
Posts: 3659
Joined: Sat Jul 28, 2012 4:55 pm
Location: Boston, USA

Re: Scripting alter.

Post 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.
Finished Dungeons - complete mods to play
User avatar
Komag
Posts: 3659
Joined: Sat Jul 28, 2012 4:55 pm
Location: Boston, USA

Re: Scripting alter.

Post by Komag »

Oh by the way, nice avatar!
Finished Dungeons - complete mods to play
User avatar
King Semos
Posts: 123
Joined: Sun Apr 15, 2012 6:05 pm

Re: Scripting alter.

Post 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.
Post Reply