Thank you so much, man! I'm standing here staring at your version and mine and I have no idea why yours works, but it does. Everything outside of the spawning daggers before pedestal placement and the XP gain is the same. Shouldn't I at least get the secret sound playing when I do the sequence in my version? Does the rest of the code interrupt and break because the dagger spawning code is bad?Xardas wrote:Hey Curunir,
Copying your code is always bad. If you can avoid that, you should so.
Here is a version which works for as many alcoves as you want
...
And here is a working Version for your puzzle. You have to spawn the daggers, before you can add them to the pedestals. Also i think you got a little mistake with the gain exp function.
Note that the key_lock_faint Sound is always played when you insert any item to any of the alcoves, once you got one right item in the right alcove. So this is very irritating. I couldn´t find a fast solution for that Problem, maybe someone else knows a better way to do this whole script, since there is also a lot of copied Code in there.
Ask a simple question, get a simple answer
Re: Ask a simple question, get a simple answer
Re: Ask a simple question, get a simple answer
There is a difference with the if end closing at food2_Found.
I think the else end was making some problems.
Like i said, the lock sounds still aren't working as YOU want them, but i don't know a simple solution for it now.
I think the else end was making some problems.
Like i said, the lock sounds still aren't working as YOU want them, but i don't know a simple solution for it now.
In order to get to the other side of the pit you have to get hit by the fireball and die....
Yep.....moving on!
Yep.....moving on!
Re: Ask a simple question, get a simple answer
I just removed them, the puzzle is very doable even without them and you still have the sound and on-screen prompt to let you know you've completed it.
Thanks again!
Thanks again!
Re: Ask a simple question, get a simple answer
Xardas wrote:Note that the key_lock_faint Sound is always played when you insert any item to any of the alcoves, once you got one right item in the right alcove. So this is very irritating. I couldn´t find a fast solution for that Problem, maybe someone else knows a better way to do this whole script, since there is also a lot of copied Code in there.
Because you asked (or I wouldn't rewrite another's script), and you later mention that it is still not working quite as Curunir hoped... I looked at it, and tried to reduce repeated code.Xardas wrote:Like i said, the lock sounds still aren't working as YOU want them, but i don't know a simple solution for it now.
These are what I came up with:
(They work on my own test level.)
Code: Select all
--Needs one onRemoveItem connection from indy alcove; and of course, it should have the prize item in the alcove.
function indyAlcoveCheck(self)
if self.go.surface:count() < 1 then
spawn("flame_wave", party.level, party.x, party.y, party.facing, party.elevation)
self.go.surface:removeConnector(self.go.surface:getConnector(1)) --trigger only once
end
end
Code: Select all
--Needs both (insert & remove) item connections from each of the the puzzle alcoves.
foundItems = {}
function hunterShape(self, item)
local itemTraits = {['sword']="sword", ['scroll']="tome", ['food1']="consumable", ['food2']="consumable", ['flute']="instrument"}
for name in pairs(itemTraits) do
local alcove = findEntity(name..'Alcove')
if alcove and alcove.surface:count() >0 then
for _,i in alcove.surface:contents() do
if i:hasTrait(itemTraits[name]) or (i.go.name == name and itemTraits[name] == "instrument") then
foundItems[name] = true
if item:hasTrait(itemTraits[name]) then
playSound("key_lock_faint")
end
break
else foundItems[name] = false
end
end
else foundItems[name] = false
end
end
if foundItems["sword"] and foundItems["scroll"] and foundItems["food1"] and foundItems["food2"] and foundItems["flute"] then
reward_pedestal_1.surface:addItem(spawn("dagger").item)
reward_pedestal_2.surface:addItem(spawn("dagger").item)
for k=1,4 do
party.party:getChampion(k):gainExp(500)
end
hudPrint("Each champion has gained 500 xp.")
playSound("secret")
end
end
Re: Ask a simple question, get a simple answer
Speaking of triggering only once, the hunterFigure script awards XP and spawns rewards every time you place the last of the five items! 
I feel like all my puzzles that award XP have no 'execute only once condition'...
I added a hunterSolved = 0 before the function block, opened the function with 'if == 0 then' and changed it to 1 after the XP award and secret ding. Seems to work fine now! Now I have to go back and check how many previous ones I forgot to check for completion...

I feel like all my puzzles that award XP have no 'execute only once condition'...
I added a hunterSolved = 0 before the function block, opened the function with 'if == 0 then' and changed it to 1 after the XP award and secret ding. Seems to work fine now! Now I have to go back and check how many previous ones I forgot to check for completion...
Re: Ask a simple question, get a simple answer
Was looking through the original game's scripts for inspiration and learning purposes and saw this:
Basically, this is a very dark room with two secret doors that open monster closets, but the script stops light from bleeding out through the secret walls.
Is there any benefit or special purpose to doing it this way instead of starting with the 'light' component of the torch holders disabled and enabling that in the script instead?
Code: Select all
-- fixes light bleed
torch_holder_6.light:fadeOut(0)
torch_holder_9.light:fadeOut(0)
function lightOn1()
torch_holder_9.light:fadeIn(0.5)
end
function lightOn2()
torch_holder_6.light:fadeIn(0.5)
end
Is there any benefit or special purpose to doing it this way instead of starting with the 'light' component of the torch holders disabled and enabling that in the script instead?
Re: Ask a simple question, get a simple answer
Makes it smoothly transition from unlit to lit over 0.5 seconds, instead of instantly jumping from unlit to lit. Looks much nicer.
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: Ask a simple question, get a simple answer
Thanks, minmay! I guess I'll have to test it on a map with and without the fade to really see the difference.
I wanted to ask if we know for sure how the "level" dropdown for monsters alters their stats. Does it affect only health or does it give enemies an overall boost in ability and defence as well?
I wanted to ask if we know for sure how the "level" dropdown for monsters alters their stats. Does it affect only health or does it give enemies an overall boost in ability and defence as well?
Re: Ask a simple question, get a simple answer
Monsters get:
- 100% more health per level
- Maximum health equal to [base health at level 1]*level^2. So a level 2 monster has twice the health as a level 1 one, but four times the max health. This is relevant if something is healing your monsters (like "absorb" resistances), or if you want them to be part of a boss fight (in which case you'll have to reset their max health manually to make the boss health bar look right).
- 33.33...% more protection per level, rounded down to an integer. So a level 4 monster has twice the protection of a level 1 one.
- 33.33...% more MonsterAttackComponent attack power per level, rounded down to an integer. Note that this doesn't affect e.g. MonsterChargeComponent or projectiles fired by calling MonsterComponent:shootProjectile()!
- Experience value equal to 1.1^(level-1)
Note that there is no requirement that levels be integers, a level 1.352 monster or a level 0.3 monster will work fine. I generally recommend against using monster level because:
A. it doesn't change the tactics for fighting the monsters at all
B. it mostly just makes the monsters take longer to fight by increasing their health and protection, which is seldom fun
C. it's not even visible to the player until they kill the monster and see its XP award
Isle of Nex uses monster levels other than 1 pretty sparingly, and has almost no monsters that are higher than level 2.
- 100% more health per level
- Maximum health equal to [base health at level 1]*level^2. So a level 2 monster has twice the health as a level 1 one, but four times the max health. This is relevant if something is healing your monsters (like "absorb" resistances), or if you want them to be part of a boss fight (in which case you'll have to reset their max health manually to make the boss health bar look right).
- 33.33...% more protection per level, rounded down to an integer. So a level 4 monster has twice the protection of a level 1 one.
- 33.33...% more MonsterAttackComponent attack power per level, rounded down to an integer. Note that this doesn't affect e.g. MonsterChargeComponent or projectiles fired by calling MonsterComponent:shootProjectile()!
- Experience value equal to 1.1^(level-1)
Note that there is no requirement that levels be integers, a level 1.352 monster or a level 0.3 monster will work fine. I generally recommend against using monster level because:
A. it doesn't change the tactics for fighting the monsters at all
B. it mostly just makes the monsters take longer to fight by increasing their health and protection, which is seldom fun
C. it's not even visible to the player until they kill the monster and see its XP award
Isle of Nex uses monster levels other than 1 pretty sparingly, and has almost no monsters that are higher than level 2.
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: Ask a simple question, get a simple answer
Thank you for the detailed information! I was planning to use higher level monsters to re-populate early game areas that the player returns to later on, as the progression of the mod sort of calls for that, but I may simply populate older areas with new enemies.
One more thing - there is no real way to collect user keyboard input and make the user type in strings that a script can process, right?
One more thing - there is no real way to collect user keyboard input and make the user type in strings that a script can process, right?