The John Smith Asks Questions Thread

Talk about creating Grimrock 1 levels and mods here. Warning: forum contains spoilers!
User avatar
John Smith
Posts: 29
Joined: Sat Dec 22, 2012 5:28 am

The John Smith Asks Questions Thread

Post by John Smith »

I was wondering what line of code I would use in a lua script to reassign a different name to an item. An example would be a longsword in an alcove would be renamed "John's Longsword". Adding onto that, if you can change the name then surely you can change the description as well.
Last edited by John Smith on Wed Dec 26, 2012 12:42 am, edited 2 times in total.
My personal website: 38chan.net
I am the writer for H.O.T.D.Abridged. You can check it out by clicking there.
Ixnatifual

Re: Renaming Items

Post by Ixnatifual »

Edit the items.lua in your scripts folder and add a clone that uses the regular longsword as a base.

Example:

Code: Select all

cloneObject {
  name = "cracked_short_bow",
  baseObject = "short_bow",
  uiName = "Cracked Short Bow",
  attackPower = 9,
  description = "While retaining some basic functionality, this weapon has seen better days. Perhaps you can find a similar bow in better condition."
}
When you clone the item, all the stuff you don't specify remains the same as per the original item.
For more details, check the item section here.
User avatar
John Smith
Posts: 29
Joined: Sat Dec 22, 2012 5:28 am

Re: Renaming Items

Post by John Smith »

Ixnatifual wrote:Edit the items.lua in your scripts folder and add a clone that uses the regular longsword as a base.

Example:

Code: Select all

cloneObject {
  name = "cracked_short_bow",
  baseObject = "short_bow",
  uiName = "Cracked Short Bow",
  attackPower = 9,
  description = "While retaining some basic functionality, this weapon has seen better days. Perhaps you can find a similar bow in better condition."
}
When you clone the item, all the stuff you don't specify remains the same as per the original item.
For more details, check the item section here.
Awesome. Thank you for the help.
My personal website: 38chan.net
I am the writer for H.O.T.D.Abridged. You can check it out by clicking there.
User avatar
John Smith
Posts: 29
Joined: Sat Dec 22, 2012 5:28 am

Re: The John Smith Asks Questions Thread

Post by John Smith »

I want a player to enter a room where once they step in they are locked inside until they kill all of the monsters. How would I go about having a lua script check to see if all the monsters in that room are dead? I would think it goes a little something like this:

Code: Select all

if 
crowern_4:getHealth(0) and
crowern_5:getHealth(0) and
crowern_6:getHealth(0) and
crowern_7:getHealth(0) and
crowern_8:getHealth(0) and
crowern_9:getHealth(0) then 
	dungeon_door_wooden_5:open()
else 
	dungeon_door_wooden_5:closed()
end
Only the door will be open before players get to that part of the dungeon when it should have been closed. The variable for the monster health must be off. How would I define a dead monster?
My personal website: 38chan.net
I am the writer for H.O.T.D.Abridged. You can check it out by clicking there.
User avatar
Komag
Posts: 3659
Joined: Sat Jul 28, 2012 4:55 pm
Location: Boston, USA

Re: The John Smith Asks Questions Thread

Post by Komag »

a couple things:
close() not closed()
getHealth() == 0 not getHealth(0)
Finished Dungeons - complete mods to play
User avatar
John Smith
Posts: 29
Joined: Sat Dec 22, 2012 5:28 am

Re: The John Smith Asks Questions Thread

Post by John Smith »

Komag wrote:a couple things:
close() not closed()
getHealth() == 0 not getHealth(0)
Oh. Silly mistakes. Thank you.
My personal website: 38chan.net
I am the writer for H.O.T.D.Abridged. You can check it out by clicking there.
User avatar
John Smith
Posts: 29
Joined: Sat Dec 22, 2012 5:28 am

Re: The John Smith Asks Questions Thread

Post by John Smith »

Huh. I made the fixes but the door still doesn't seem to open, even when I kill the crowerns.

Image

You're meant to hit the wall button to open the door, you step on the invisible pleasure plate and the door closes behind you. When all the monsters die the door should open.
My personal website: 38chan.net
I am the writer for H.O.T.D.Abridged. You can check it out by clicking there.
User avatar
Komag
Posts: 3659
Joined: Sat Jul 28, 2012 4:55 pm
Location: Boston, USA

Re: The John Smith Asks Questions Thread

Post by Komag »

hmm, I didn't really think this through, just corrected those small errors. The real problem is that those monsters no longer exist after you have killed them, so any script can't find any monster to get the health from in the first place. You'll need to check for the existence of the monsters. If you want the door to open at the death of the last monster, it might be easiest to set up a custom monster (clone) with an onDie hook to run the script, and have the script work only if it never finds the monsters (only returns nil)
Finished Dungeons - complete mods to play
User avatar
Neikun
Posts: 2457
Joined: Thu Sep 13, 2012 1:06 pm
Location: New Brunswick, Canada
Contact:

Re: The John Smith Asks Questions Thread

Post by Neikun »

I think it'd be easier to place a counter, have ondie hooks that reference the counter, have the counter open the door when it reaches 0.
Each monster could decrement the counter on it's death.
"I'm okay with being referred to as a goddess."
Community Model Request Thread
See what I'm working on right now: Neikun's Workshop
Lead Coordinator for Legends of the Northern Realms Project
  • Message me to join in!
Hariolor
Posts: 42
Joined: Sun Apr 15, 2012 5:59 am

Re: The John Smith Asks Questions Thread

Post by Hariolor »

John Smith wrote:Huh. I made the fixes but the door still doesn't seem to open, even when I kill the crowerns.

Image

You're meant to hit the wall button to open the door, you step on the invisible pleasure plate and the door closes behind you. When all the monsters die the door should open.
viewtopic.php?p=31998#p31998

I think in this link, Shroom wanted to do almost exactly what you're doing. Might be a good starting point.

Replace "snail" with "crowern" and that should just about get you there. xMin/xMax and yMin/yMax will define a box around your room. Then replace his door name with your own.

*edit: alternative idea...

might also try:

Code: Select all

if crowern_x == nil
and crowern_y == nil
and crowern_z == nil

then door_foo:open()
end
Post Reply