I need some help with the editor. To ask a few things IF they can be done, and subsequently HOW to script them.
1: Is it possible to get a demon statue mouth slot to only activate when a specific green gem is inserted, rather than just any green gem?
2: Is it possible to have gems spawned in a demon statue eye slot only be removable after a certain trigger, rather than at any given time?
3: Can I change the name of an object in the editor, so that in the game it displays a different name?
4: Can I program a door to be opened once certain monsters have been killed?
If anyone can advise me on this, it would be greatly appreciated and help me with the creation of a level.
A few questions about Editor
- Zo Kath Ra
- Posts: 940
- Joined: Sat Apr 21, 2012 9:57 am
- Location: Germany
Re: A few questions about Editor
1:Aranok wrote: ↑Thu Feb 27, 2020 9:11 pm I need some help with the editor. To ask a few things IF they can be done, and subsequently HOW to script them.
1: Is it possible to get a demon statue mouth slot to only activate when a specific green gem is inserted, rather than just any green gem?
2: Is it possible to have gems spawned in a demon statue eye slot only be removable after a certain trigger, rather than at any given time?
3: Can I change the name of an object in the editor, so that in the game it displays a different name?
4: Can I program a door to be opened once certain monsters have been killed?
If anyone can advise me on this, it would be greatly appreciated and help me with the creation of a level.
- Place a daemon_head or daemon_head_eye_sockets
- Place a mouth_socket at the same location
- Place a script_entity anywhere in the level; you can place the script entity in another level, but placing it in the same level makes things less confusing; you can use an existing script entity, as long as the function name is unique within the script entity
- Put this code in the script entity:
Code: Select all
function onInsertItem(self)
for i in self:containedItems() do
if (i.id == "green_gem_1") then
-- This action is executed when you insert "green_gem_1" into the mouth_socket
dungeon_door_iron_1:open()
end
end
end
2:
- Place a daemon_head_eye_sockets
- Place an eye_socket_left or eye_socket_right at the same location
- Place a script_entity anywhere in the level; you can place the script entity in another level, but placing it in the same level makes things less confusing; you can use an existing script entity, as long as the function name is unique within the script entity
- Put this code in the script entity:
Code: Select all
function onRemoveItem(self)
local mouseItem = getMouseItem()
-- This condition determines whether you can take the gem out of the eye socket
if (counter_1:getValue() > 0) then
-- Put the gem back in the eye socket
self:addItem(mouseItem)
-- Remove the gem from the mouse cursor, so it doesn't exist twice in the game
setMouseItem(nil)
-- Display a helpful warning message
hudPrint("You can't take the gem because counter_1's value is > 0")
end
end
3:
As far as I know, you can't change an object's name with a script.
You need to use cloneObject{…} to define a new type of object with a different name:
http://www.grimrock.net/modding_log1/as ... reference/ -> Dungeon Objects -> cloneObject{…}
(AFAIK you must do this in one of the mod's LUA files that are loaded in init.lua, such as items.lua)
For example, put this code in your mod's items.lua:
Code: Select all
cloneObject{
name = "sword_of_slaying",
baseObject = "long_sword",
uiName = "Sword of Slaying",
attackPower = 99,
coolDownTime = 1.0,
}
todo
I'm sure someone else will come along and post better solutions.
These solutions will probably involve:
http://www.grimrock.net/modding_log1/ -> Custom Assets
Re: A few questions about Editor
Thank you very much. This should atleast get me started.
Re: A few questions about Editor
For #4
Quick method:
________________________________________________
Alternate method:Place this script in scripts/monster.lua
Save the file, and reload the project.
Place one or more gate_monsters, and one door with the ID of 'monster_gate'.
Place a counter on the map, and assign it the id 'monster_count'; set its value to the number of gate_monsters.
If you would like there to be different kinds of gate monsters, then you must duplicate the above script for each monster, and update the name, and baseObject string values with the new monster name.
Quick method:
SpoilerShow
Nevermind the quick method.

Alternate method:
Code: Select all
cloneObject{
--use or replace 'snail' with whatever monster name is preferred.
name = "gate_monster_snail",
baseObject = "snail",
onDie = function()
if findEntity("monster_count") and monster_count:getValue() > 1 then
monster_count:decrement(1)
return
end
if findEntity("monster_gate") then monster_gate:open() end
end
}
Save the file, and reload the project.
Place one or more gate_monsters, and one door with the ID of 'monster_gate'.
Place a counter on the map, and assign it the id 'monster_count'; set its value to the number of gate_monsters.
If you would like there to be different kinds of gate monsters, then you must duplicate the above script for each monster, and update the name, and baseObject string values with the new monster name.
Last edited by Isaac on Fri Feb 28, 2020 5:39 am, edited 2 times in total.
Re: A few questions about Editor
Do not use this method. The allEntities() function doesn't work if the player has made a map note on the level. See viewtopic.php?f=14&t=5672.Isaac wrote: ↑Fri Feb 28, 2020 4:57 am For #4
Quick method:Rename the door to monster_gate.Code: Select all
cloneObject{ --use or replace 'snail' with whatever monster name is preferred. name = "gate_monster_snail", baseObject = "snail", onDie = function(self) local gate_monsters = 0 for monster in allEntities(self.level) do if monster.name == self.name then gate_monsters = gate_monsters + 1 end end if gate_monsters < 2 then monster_gate:open() end end }
The alternate method you gave is fine, though. Note that the decrement() method doesn't actually use any arguments, it always decrements by 1.
Grimrock 1 dungeon
Grimrock 2 resources
I no longer answer scripting questions in private messages. Please ask in a forum topic or this Discord server.
Grimrock 2 resources
I no longer answer scripting questions in private messages. Please ask in a forum topic or this Discord server.
Re: A few questions about Editor
Good call, I had actually forgotten about the debacle it caused in the ORRR2. The quick method was my second choice; a revision of the first.
Thanks for pointing it out.
Thanks for pointing it out.