General scripting issues and questions

Talk about creating Grimrock 1 levels and mods here. Warning: forum contains spoilers!
User avatar
Isaac
Posts: 3185
Joined: Fri Mar 02, 2012 10:02 pm

Re: Useful scripts repository

Post by Isaac »

ExpDevourer wrote:Where and what do you use to edit the scripts? Do you go to the games files, under the lets say *textures* and open the file using Notepad or something? Or is there more to it then that, the explanations here seem fairly simple, but how do you open up the script itself to be modified. Sorry I am very new to scripting, I took maybe a week of schooling for it one time years ago, but I couldn't tell you how I went about it at the time.
Notepad is good; there are a few other apps that are just as good or better. You don't want to use a word processor though; just a basic text editor that doesn't add format codes to the text.

Tip: Don't save the file as [the default] .txt, unless you plan to rename them before use. Notepad allows you to save with a custom file extension (in this case .lua); select the "All Files" 'format' and write the complete file name and extension yourself.
User avatar
ExpDevourer
Posts: 60
Joined: Mon Nov 19, 2012 9:31 am
Location: Performing mad experiments in my laboratory, usually during thunder storms.

Re: Useful scripts repository

Post by ExpDevourer »

Isaac wrote:
ExpDevourer wrote:Where and what do you use to edit the scripts? Do you go to the games files, under the lets say *textures* and open the file using Notepad or something? Or is there more to it then that, the explanations here seem fairly simple, but how do you open up the script itself to be modified. Sorry I am very new to scripting, I took maybe a week of schooling for it one time years ago, but I couldn't tell you how I went about it at the time.
Notepad is good; there are a few other apps that are just as good or better. You don't want to use a word processor though; just a basic text editor that doesn't add format codes to the text.

Tip: Don't save the file as [the default] .txt, unless you plan to rename them before use. Notepad allows you to save with a custom file extension (in this case .lua); select the "All Files" 'format' and write the complete file name and extension yourself.
So notepad works then? Good good, I use it quite a bit, so I am very familiar with it. Save as lua or something else then? Ok, where do you paste the scripts you have made to get them to activate correctly, lets say changing wallset wall color, or adding an animation, monsters, interactive object etc.

P.S. Nice Beholder ;) Reminds me of the old Eye of the Beholder game I used to pull my hair out on.
I'm here to kick goblins and chew herbs, and I'm all out of herbs.
Caelik
Posts: 2
Joined: Wed Dec 05, 2012 7:47 pm

Re: General scripting issues and questions

Post by Caelik »

Hi guys, scripting newbie here with a quick question. Is there a way to heal party members when they level up? I've been searching around and I did find a command onLevelUp(Champion) but when I try to use it I get a nil value. I've tried setting local values for champions but nothing I try seems to work. Any help would be greatly appreciated.
User avatar
Isaac
Posts: 3185
Joined: Fri Mar 02, 2012 10:02 pm

Re: Useful scripts repository

Post by Isaac »

ExpDevourer wrote:P.S. Nice Beholder ;) Reminds me of the old Eye of the Beholder game I used to pull my hair out on.
It's one in the same; that is the game sprite from Eye of the Beholder. ;)
Caelik wrote:Hi guys, scripting newbie here with a quick question. Is there a way to heal party members when they level up? I've been searching around and I did find a command onLevelUp(Champion) but when I try to use it I get a nil value. I've tried setting local values for champions but nothing I try seems to work. Any help would be greatly appreciated.
The script for that is party:getChampion(x):levelUp()
Where 'x' is the ordinal of the champion; (1-4).

Make a new project and add a pressure plate, and connect it to a lua object.
Paste the following into the Lua object:

Code: Select all

function lvlUp()
 for x = 1,4 do
   party:getChampion(x):levelUp()
 end
end
Preview it. When you step on the plate all party members should level up.
User avatar
ExpDevourer
Posts: 60
Joined: Mon Nov 19, 2012 9:31 am
Location: Performing mad experiments in my laboratory, usually during thunder storms.

Re: General scripting issues and questions

Post by ExpDevourer »

Thought that looked familiar :). Also my original question in this thread is no longer valid, I figured all that out, still pulling my hair on other things, but I have the basic concept down now. 8-)
I'm here to kick goblins and chew herbs, and I'm all out of herbs.
User avatar
montagneyaya
Posts: 103
Joined: Tue May 01, 2012 11:08 pm

Re: Useful scripts repository

Post by montagneyaya »

Isaac wrote:
Caelik wrote:Hi guys, scripting newbie here with a quick question. Is there a way to heal party members when they level up? I've been searching around and I did find a command onLevelUp(Champion) but when I try to use it I get a nil value. I've tried setting local values for champions but nothing I try seems to work. Any help would be greatly appreciated.
The script for that is party:getChampion(x):levelUp()
Where 'x' is the ordinal of the champion; (1-4).

Make a new project and add a pressure plate, and connect it to a lua object.
Paste the following into the Lua object:

Code: Select all

function lvlUp()
 for x = 1,4 do
   party:getChampion(x):levelUp()
 end
end
Preview it. When you step on the plate all party members should level up.
Your script is for level up all champion, he will healing a champion on level up (with the hook onLevelUp)
User avatar
montagneyaya
Posts: 103
Joined: Tue May 01, 2012 11:08 pm

Re: General scripting issues and questions

Post by montagneyaya »

For healing a champion on level up, add in your mod_asset/scripts/object.lua

Code: Select all

defineObject{
	name = "party",
	class = "Party",
	onLevelUp = function (champion)
		champion:modifyStat("health", 99999)
	end,
	editorIcon = 32,
}
Caelik
Posts: 2
Joined: Wed Dec 05, 2012 7:47 pm

Re: General scripting issues and questions

Post by Caelik »

Thank you all for the quick responses. That did the job, thank you! I obviously have much to learn lol.
User avatar
Isaac
Posts: 3185
Joined: Fri Mar 02, 2012 10:02 pm

Re: Useful scripts repository

Post by Isaac »

montagneyaya wrote:Your script is for level up all champion, he will healing a champion on level up (with the hook onLevelUp)
Yeah; my script was just demonstrating use of the champion:levelUp(). He had mentioned getting nil from it when he used it.

*Nice script btw. 8-)
User avatar
Komag
Posts: 3658
Joined: Sat Jul 28, 2012 4:55 pm
Location: Boston, USA

Re: General scripting issues and questions

Post by Komag »

JKos wrote:Hi and thanks for releasing the beta :)

I will start with a simple question.
Why doesn't this work? is it a bug or just me?

damageTile(1, dungeon_door_iron_1.x, dungeon_door_iron_1.y, 1, 1, "physical", 2)

it gives following error: attempt to index a nil value. But only if there is a monster on that tile.

full script:
function crushEast()
if (dungeon_door_iron_1:isOpen()) then
dungeon_door_iron_1:close()
damageTile(1, dungeon_door_iron_1.x, dungeon_door_iron_1.y, 1, 1, "physical", 2)
else
dungeon_door_iron_1:open()
end
end
I'm getting this exact bug still, crash to editor with "attempt to index a nil value" if the damage type is "physical" and there is a monster in the square. Was this supposedly fixed ever, or did it slip through the cracks?

It seems pretty important for "physical" damage to be an option for something like this, as I want to have damage without any FX (lightning or fire), without the monster dying with frozen pieces (cold), and without any monster being immune (poison)

(PS the scripting reference still lists "poison" twice and omits "shock")
Finished Dungeons - complete mods to play
Post Reply