help with insta-death square script and other Qs

Talk about creating Grimrock 1 levels and mods here. Warning: forum contains spoilers!
User avatar
sevenbirds
Posts: 10
Joined: Wed Sep 19, 2012 9:26 am

help with insta-death square script and other Qs

Post by sevenbirds »

Komag wrote:insta-death square

example by Montis and Xzalander

- script:

Code: Select all

function instadeath()
     damageTile(party.level, party.x, party.y, party.facing, 128, "physical", 9001)
     hudPrint("You Foolish Adventurers, MWAHAHAHA!!!")
end
- create a hidden plate that is ONLY triggered by the party (not monsters or items)
- connect plate to script
- any number of plates can be similarly connected to the script
I suppose I should read more carefully when I thank someone, but thanks again for sharing the gambling script. On Montis' and Xzalander's script above, I'm trying to change it to release a very deadly poison attack. I have this:

Code: Select all

 function poisontrap()
     damageTile(level, x, y, 3, bit 1, "poison", 1000)
     hudPrint("A noxious gas fills the chamber!")
end
However, I get the follow error the second I step on the trap:
')' expected near '1'
Am I missing something or did I misread the reference?

damageTile(level, x, y, direction, flags, damageType, power)
Damages all creatures including the party in a given tile. direction specifies the direction of the attack for projectiles or melee attacks (0=north, 1=east, 2=south, 3=west). damageType must be one of the following: “physical”, “fire”, “poison”, “cold”, “poison”. Damage is rolled individually for all creatures using the power as base value. flags is a numeric bit field:

bit 0: monsters recoil from the impact
bit 1: ongoing damage such as poison cloud
bit 2: damage originated from champion with ordinal index 1
bit 3: damage originated from champion with ordinal index 2
bit 4: damage originated from champion with ordinal index 3
bit 5: damage originated from champion with ordinal index 4
bit 6: ignore immunities
bit 7: halve damage of back row party members
User avatar
Xzalander
Posts: 62
Joined: Thu Sep 13, 2012 1:27 pm
Location: Yorkshire, United Kingdom

Re: Useful scripts repository

Post by Xzalander »

Seven, as far as I can tell you don't need to write the word bit.

Just the numbers of the bits you wish to use.

So

Code: Select all

 function poisontrap()
     damageTile(level, x, y, 3,  1, "poison", 1000)
     hudPrint("A noxious gas fills the chamber!")
end
And if you were to include more bits it would be:

Code: Select all

 function poisontrap()
     damageTile(level, x, y, 3,  12, "poison", 1000)
     hudPrint("A noxious gas fills the chamber!")
end

I -think-. I'm not too sure on the bit system myself but I do know you don't need the word bit in there.
User avatar
sevenbirds
Posts: 10
Joined: Wed Sep 19, 2012 9:26 am

Re: Useful scripts repository

Post by sevenbirds »

Billick wrote:A couple of script functions I wrote to check if anybody in your party is carrying a particular type of item:

Code: Select all

function checkForItemParty(item)
	local i = 1
	repeat
		if checkForItem(party:getChampion(i), item)
			then return true
		end
		i = i + 1
	until i == 5
	return false
end

function checkForItem(champion, item)
	local i = 1
	repeat
		local itemObj = champion:getItem(i)
		if itemObj ~= nil then
			if itemObj.name == item
				then return true
			end
		end
		i = i+1
		until i == 32
	return false
end
The first function calls the second function. Pass in the name of the item you want to check for into checkForItemParty. You would use it like this:

Code: Select all

if checkForItemParty("torch")
 then print("We have a torch")
 else print("We don't have a torch")
end
Edit: fixed invalid function names
I apologize in advance but my scripting skills are minimal. I changed the above to use hudprint instead of print so that a player would see the message, but I got the follow error:
attempt to call global "hudprint" (a nil value)

Have I done something wrong?
User avatar
Xzalander
Posts: 62
Joined: Thu Sep 13, 2012 1:27 pm
Location: Yorkshire, United Kingdom

Re: Useful scripts repository

Post by Xzalander »

I had this a few times and Im guessing you forgot to quotemark the text.

Make sure your string reads

Code: Select all

hudprint("TEXTHERE")
and not

Code: Select all

 hudprint(TEXTHERE)
User avatar
sevenbirds
Posts: 10
Joined: Wed Sep 19, 2012 9:26 am

Re: Useful scripts repository

Post by sevenbirds »

actually, I'm an idiot and forgot to capitalize Print. Thanks though, especially the fast reponse.

now I have another question: how do I add the function to my dungeon? I know that I don't make a script entity for the new function and I think I need to save it as a .lua, but where does it go?
User avatar
Xzalander
Posts: 62
Joined: Thu Sep 13, 2012 1:27 pm
Location: Yorkshire, United Kingdom

Re: Useful scripts repository

Post by Xzalander »

Unfortunately I'm not sure on that. I suppose it would depend on your usage of it? (Ex. Whether you wish to tie it to an Altar or have it globally affect your dungeon)
User avatar
sevenbirds
Posts: 10
Joined: Wed Sep 19, 2012 9:26 am

Re: Useful scripts repository

Post by sevenbirds »

I just tried out the sample for the poison trap above and got this error:
bad argument #1 for 'damagetile' ( number expected, got nil)
User avatar
Xzalander
Posts: 62
Joined: Thu Sep 13, 2012 1:27 pm
Location: Yorkshire, United Kingdom

Re: Useful scripts repository

Post by Xzalander »

Code: Select all

 function poisontrap()
     damageTile(1, 14, 16, 3, 1, "poison", 1000)
     hudPrint("A noxious gas fills the chamber!")
end
Just took that code directly from your quote earlier and deleted the word Bit.
I then added the level, X and Y and it worked fine.

You must have a mistype somewhere. Check for Capitals (T and P) and that you've specified the level and quotemarked the word poison.

Do note that this code will only do a one shot of damage. And won't tick over time.
User avatar
sevenbirds
Posts: 10
Joined: Wed Sep 19, 2012 9:26 am

Re: Useful scripts repository

Post by sevenbirds »

Xzalander wrote:Unfortunately I'm not sure on that. I suppose it would depend on your usage of it? (Ex. Whether you wish to tie it to an Altar or have it globally affect your dungeon)

Well, I appreciate the help none the less. you have been a great help!

I was really just trying to use it to better understand it. As it is presented, it is two different lua scripts and the first is adding the function. When I tried to paste both into a single script, then it just prints "we don't have a torch" the second you spawn.

on the trap, I just did that as well realizing that it needed the exact coordinates of the pressure plate. now to get it to do damage over time!

I'm going to go read some lua guides so I'm not such a bother. Thanks again to everyone who is creating a awesome modding community.
User avatar
Xzalander
Posts: 62
Joined: Thu Sep 13, 2012 1:27 pm
Location: Yorkshire, United Kingdom

Re: Useful scripts repository

Post by Xzalander »

So you have a place to look at damage over time could easily be done by setting the location of the damage to

Code: Select all

party.level, party.x, party.y, party.facing
instead of specifying the level, and coords. That atleast keeps the damage following the player.

As for the over time, tie the Pressureplate to a timer first, then tie the timer to the script youre using.
Set the timer for the duration you want the "poison" to last. Remember to reduce the damage appropriately in the script and then remember to kill the timer using timer:deactivate at the end of the damage script so the poison stops.

So it would go

pressureplate > timer (30seconds) > Script




I'd help a little more but I'm about to go to bed.




Edit: Oh as for that script outputting a message as soon as you spawn:

Thats actually correct.

If you place a LUA script in a dungeon without a reference, it acts as a global script and activates immediately. Because you are in the editor you start with an everlasting_torch not a torch so you receive the output "Do not have a torch".

If you tie that Script to a pressure plate it would output when you step on the plate instead. And if you pick up a torch before stepping on the plate it would out put that you do have a torch.
Post Reply