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.
1:
- 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
- In the mouth_socket, add a connector; Event = activate, Target = the script_entity, Action = onInsertItem
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
- In the eye_socket_*, add a connector; Event = deactivate, Target = the script_entity, Action = onRemoveItem
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,
}
4:
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