Page 5 of 6
Re: Spike trap script help
Posted: Wed May 06, 2015 3:05 pm
by alois
It seems to me that you spawn the "shockburst" everywhere in a square but in the central place (x = y = 0). Maybe it is easier to do as follows:
Code: Select all
local max = 1 -- if the lever is not activated, the square is 3x3
if (chamberlever:getLeverState() == "activated") then
max = 2 -- otherwise it is 5x5
end
for x = -max,max do
for y = -max,max do
if ( (x ~= 0) or (y ~= 0) ) then -- this is false only if x = y = 0
spawn("shockburst", 1, 19 + x, 15 + y, 0)
end
end
end
Alois

Re: Spike trap script help
Posted: Thu May 07, 2015 4:38 am
by Killcannon
Thank you Alois - that looks so much cleaner than what I had. ^.^ Another small question, what is the implication (if any) of using a script on one level for traps and puzzles on other levels? For example if I have a trap on level 2 that works similarly to a trap on level 1 can I just reference the part of the script on level 1 that I need or should I just remake it for level 2? My concern of course is latency in the game world and not taxing out the capabilities of the game and machines.
Re: Spike trap script help
Posted: Thu May 07, 2015 4:58 am
by Isaac
Depends if it uses or spawns timers. Timers not on the current level (where the party is), are slowed appreciably.
Re: Spike trap script help
Posted: Thu May 07, 2015 6:50 am
by Killcannon
Thanks Issac! I guess I'm copy/pasting then as the trap uses a timer, good information to have!
On another note I managed to work out the script I needed for the third puzzle as well! Was quite simple really when I started working on it. Though it too went through several iterations before I whittled it down to the final product below. The initial version was quite ugly; though effective, and I'm not quite convinced that this is the best way to do this but one thing I'm learning is there's definitely many ways of scripting to do the same thing and they're not all bad ways of doing it either. ^.^
function doorcombo(entity, item)
for i in entity:containedItems() do
if i.name == item then
return true
end
end
return false
end
function doorcheck()
if doorcombo(frost_hook_alcove_1, "frost_blade") and
doorcombo(fire_hook_alcove_1, "fire_blade") and
doorcombo(lightning_hook_alcove_1, "lightning_blade") then
wardenapt:open()
else
wardenapt:close()
end
end
As for my final problem I'd posted earlier. I figured out what was going on; and it's not really great news. I figured out why the two scripts were behaving differently; and it was the monster. For the first I'm using a low level monster with relatively low HP. So the damage from the fall and the damage that the trap itself did was killing the monster. The second is intended to be a 'boss' and has far more HP. So while I figured out the issue; it means I'm still working on how to make the script differentiate mob from player. >.> At least I'm 2 of 3 down so far!
Re: Spike trap script help
Posted: Thu May 07, 2015 7:29 am
by Isaac
Killcannon wrote:Thanks Issac! I guess I'm copy/pasting then as the trap uses a timer, good information to have!
With care, you can script it such that timers are spawned on the Party's current level; in cases where they are not going to switch levels.
Re: Spike trap script help
Posted: Sun May 10, 2015 6:08 am
by Killcannon
That's very good to know. Fortunately I probably won't need to worry about this for now with what I'm doing. While I have a varied amount of traps that are using the damage script itself, the actual number of scripts I have is relatively low.
I'm still having issues with getting my one script differentiating the monsters from the players and applying different damage accordingly. Could I get a hand on this? I just need an example really of how to tell if an entity over a tile is a monster or the party, and deal damage to that tile.
Re: Spike trap script help
Posted: Sun May 10, 2015 11:50 am
by Isaac
Killcannon wrote:I'm still having issues with getting my one script differentiating the monsters from the players and applying different damage accordingly. Could I get a hand on this? I just need an example really of how to tell if an entity over a tile is a monster or the party, and deal damage to that tile.
connect floor-trigger to this script, and
Code: Select all
function detect(caller)
local test
for entity in caller.go.map:entitiesAt(caller.go.x, caller.go.y, caller.go.elevation) do
test = iff( entity.party, true,false) break
end
--==-------------[use test as a true/false for party detection]
hudPrint(iff(test, "Party", "Monster").." detected!")
--==---------------------------------------------------------
return test
end
Alternative:
Code: Select all
function _detect(caller)
local test
for entity in caller.go.map:entitiesAt(caller.go.x, caller.go.y, caller.go.elevation) do
test = iff( entity.party, true,false) break
end
return test
end
function trap(caller)
local damage = iff( _detect(caller), 30, 70)
damageTile(caller.go.level,caller.go.x,caller.go.y,caller.go.facing,caller.go.elevation, 64 ,"fire", damage)
--optional fireball
spawn("fireball_blast_large", caller.go.level,caller.go.x,caller.go.y,caller.go.facing,caller.go.elevation)
end
Re: Spike trap script help
Posted: Tue May 12, 2015 2:44 pm
by Killcannon
Thanks again Issac, feeling really dumb right now; was trying to get the script to detect for a monster and completely spaced that I could also detect for the party instead.

Completely dumb on my part for sure. Do forgive my slow replies, of late; I've encountered an issue where after I make a post, the website seems to go down for a few days and cannot be reached. Probably completely on my end and it's not browser/computer related, so I'm thinking it's my local ISP being well their usual self.
Re: Spike trap script help
Posted: Tue May 12, 2015 8:52 pm
by Isaac
Killcannon wrote: Do forgive my slow replies, of late; I've encountered an issue where after I make a post, the website seems to go down for a few days and cannot be reached. Probably completely on my end and it's not browser/computer related, so I'm thinking it's my local ISP being well their usual self.
That's happened for us all lately.
Re: Spike trap script help
Posted: Wed May 13, 2015 7:11 pm
by Killcannon
That's happened for us all lately.
Ah okay! so it's on the websites end. Good to know!
I did get the trap to work kinda... it works so long as there's not an open pit on the same tile. It looks like the monster is falling through the floor to the next level before the script kills it, and then it's on the wrong level so the script just deals damage to the air.
edit:
Could I also add a hook in the monster itself to check if a tile is a wall and have it die there?