Help needed with making scripts work!!

Talk about creating Grimrock 1 levels and mods here. Warning: forum contains spoilers!
Post Reply
User avatar
WaspUK1966
Posts: 135
Joined: Sat Aug 09, 2014 9:17 am

Help needed with making scripts work!!

Post by WaspUK1966 »

Forgive my ignorance, but I am in the process of creating my own custom dungeon using the editor. Basically, when the game starts, I want my party to be already equipped with certain items ie a weapon and a note/scroll (that I want to put my own text on). I have checked the scripts on here. Some I think I can modify and use, but what I need to know is: Where do I put it so that it runs when the game starts? Does it need to be put in any game folders first? How do I activate it? I`ve tried everything and nothing works..Also, how can I level up the party or increase their xp points once they find or do something eg find a secret room or kill a monster? Any help greatly appreciated. Sorry for rambling on!
User avatar
maneus
Posts: 246
Joined: Mon Jun 17, 2013 10:42 pm
Location: Switzerland

Re: Help needed with making scripts work!!

Post by maneus »

Make a script at a place you will in the editor.

In that script you can now did your code.
In my case it looks like this:

Code: Select all

-- Inserts an item to an equipment slot. Slot must be one of the following: 1 (head), 2 (torso), 3 (legs), 4 (feet), 5 (cloak), 6 (neck), 7 (left hand), 8 (right hand), 9 (gaunlets), 10 (bracers), 11-31 (backpack slots)

party:getChampion(1):insertItem(7, spawn("chainsword"))
party:getChampion(1):insertItem(8, spawn("bolter"))
party:getChampion(1):insertItem(6, spawn("marine_pauldron_left"))
party:getChampion(1):insertItem(5, spawn("marine_pauldron_right"))
party:getChampion(1):insertItem(11, spawn("marine_helmet"))
party:getChampion(1):insertItem(12, spawn("bolter_ammo"))
party:getChampion(1):insertItem(2, spawn("marine_chest_protector"))
party:getChampion(1):insertItem(9, spawn("marine_gauntlets"))
party:getChampion(1):insertItem(3, spawn("marine_leg_armor"))
party:getChampion(1):insertItem(4, spawn("marine_boots"))
party:getChampion(2):insertItem(7, spawn("bolter"))
party:getChampion(2):insertItem(6, spawn("marine_pauldron_left"))
party:getChampion(2):insertItem(5, spawn("marine_pauldron_right"))
party:getChampion(2):insertItem(1, spawn("marine_helmet"))
party:getChampion(2):insertItem(2, spawn("marine_chest_protector"))
party:getChampion(2):insertItem(9, spawn("marine_gauntlets"))
party:getChampion(2):insertItem(3, spawn("marine_leg_armor"))
party:getChampion(2):insertItem(4, spawn("marine_boots"))
party:getChampion(2):insertItem(11, spawn("bolter_ammo"))
Then you can give a champion a note with your custom text like this:

Code: Select all

party:getChampion(2):insertItem(17, spawn("note"):setScrollText("Here you can write your own text."))
That´s it.
User avatar
JohnWordsworth
Posts: 1397
Joined: Fri Sep 14, 2012 4:19 pm
Location: Devon, United Kingdom
Contact:

Re: Help needed with making scripts work!!

Post by JohnWordsworth »

Just to expand a bit on Maneus' response.

All of the scripts that exist outside of the editor (in the mod_assets folder) are run before the dungeon is created. Without getting creative, these are intended only to setup what game elements exist (defining items and the like). However, within the dungeon editor you can add a 'script_entity' to your dungeon - all of these scripts are run immediately when the game starts - which sets up any functions and the like that are needed in your dungeon. As a nice side-effect, that means you can also just create a script_entity and paste in the contents of Maneus' script above and it will pack a bunch of items into your starting party's inventory.
My Grimrock Projects Page with links to the Grimrock Model Toolkit, GrimFBX, Atlas Toolkit, QuickBar, NoteBook and the Oriental Weapons Pack.
User avatar
maneus
Posts: 246
Joined: Mon Jun 17, 2013 10:42 pm
Location: Switzerland

Re: Help needed with making scripts work!!

Post by maneus »

But first he should change the items he will spawn in my script. Otherwise he will get an error message because he hasn't a "chainsword", "bolter" etc. defined in his item.lua.
User avatar
WaspUK1966
Posts: 135
Joined: Sat Aug 09, 2014 9:17 am

Re: Help needed with making scripts work!!

Post by WaspUK1966 »

Thanks for that. Got it working! What I need now is a script that will level up or increase xp points for my party when they find something (secret room) or kill something, and then print it out on screen eg "champions name has gained experience" or "champions name has levelled up". Any ideas?
User avatar
msyblade
Posts: 792
Joined: Fri Oct 12, 2012 4:40 am
Location: New Mexico, USA
Contact:

Re: Help needed with making scripts work!!

Post by msyblade »

Here you go!

Code: Select all

function exp() 
 hudPrint ("Gained 250 exp.") 
for i=1,4 do  
party:getChampion(i):gainExp(250)    
	end
end
Connect a plate or button to this, but make sure the connector is set to "Activate once", otherwise you will have an unlimited exp bug. Also, this is just to award the entire party for a puzzle/accomplishment. Hope it helps!
Currently conspiring with many modders on the "Legends of the Northern Realms"project.

"You have been captured by a psychopathic diety who needs a new plaything to torture."
Hotel Hades
Post Reply