Ask a simple question, get a simple answer

Ask for help about creating mods and scripts for Grimrock 2 or share your tips, scripts, tools and assets with other modders here. Warning: forum contains spoilers!
User avatar
Isaac
Posts: 2972
Joined: Fri Mar 02, 2012 10:02 pm

Re: Ask a simple question, get a simple answer

Post by Isaac » Mon Oct 26, 2020 2:35 am

IttaBitta wrote:
Mon Oct 26, 2020 2:07 am
what's e? is it direction because I could really use that
Elevation; valid range is -7 to 7. Maps start on elevation 0/zero by default.

ratman
Posts: 119
Joined: Fri Jan 10, 2020 1:13 am

Re: Ask a simple question, get a simple answer

Post by ratman » Mon Oct 26, 2020 2:53 am

What do you mean by direction? There is a spin, which turns you in that direction when you teleport

User avatar
Isaac
Posts: 2972
Joined: Fri Mar 02, 2012 10:02 pm

Re: Ask a simple question, get a simple answer

Post by Isaac » Mon Oct 26, 2020 3:59 am

For the teleport component there is a setSpin() function, to force the direction of the party (or objects) when they emerge at the new location.

Alternatively, one can just set the spin value in the inspector properties of the teleporter object.

ratman
Posts: 119
Joined: Fri Jan 10, 2020 1:13 am

Re: Ask a simple question, get a simple answer

Post by ratman » Tue Oct 27, 2020 7:18 pm

I have two questions: Firstly, I believe that I saw somewhere on the forum that someone had a script so that if the party was wearing metal armor they took damage, but I can't find that topic again. Secondly, how do I make custom portraits for my mod? Is there an exact size that they need to be? Thanks.

Zo Kath Ra
Posts: 850
Joined: Sat Apr 21, 2012 9:57 am
Location: Germany

Re: Ask a simple question, get a simple answer

Post by Zo Kath Ra » Tue Oct 27, 2020 9:13 pm

ratman wrote:
Tue Oct 27, 2020 7:18 pm
I have two questions: Firstly, I believe that I saw somewhere on the forum that someone had a script so that if the party was wearing metal armor they took damage, but I can't find that topic again. Secondly, how do I make custom portraits for my mod? Is there an exact size that they need to be? Thanks.
1) It must be this thead:
A thank you and a script question

2) One of the developers answered this question here:
Custom Portrait specs

User avatar
Isaac
Posts: 2972
Joined: Fri Mar 02, 2012 10:02 pm

Re: Ask a simple question, get a simple answer

Post by Isaac » Tue Oct 27, 2020 9:20 pm

ratman wrote:
Tue Oct 27, 2020 7:18 pm
... how do I make custom portraits for my mod? Is there an exact size that they need to be? Thanks.
About the format... In that linked thread Petri mentions TGA, but the asset pack portraits are in DDS format. DDS format also works, but it's not always a save option in one's image editor. *Even so... DDS portraits must be referenced as .tga files in the scripts.
So, a file named "mod_assets\textures\portraits\minotaur_female_8.dds" must be written in script as "mod_assets/textures/portraits/minotaur_female_8.tga", even though it's not a tga file.

128x128 pixels
DDS format; no compression.

An easy way to generate portraits (on Windows OS) is to use Paint.NET; it saves to DDS format without plugins. Otherwise there are GIMP & Photoshop. Paint.Net is free, and available here: https://getpaint.net

DDS Settings for Paint.NET:
Image



Here is a blank portrait if you need it for backgrounds.
Image

ratman
Posts: 119
Joined: Fri Jan 10, 2020 1:13 am

Re: Ask a simple question, get a simple answer

Post by ratman » Tue Oct 27, 2020 11:22 pm

Zo Kath Ra wrote:
Tue Oct 27, 2020 9:13 pm
1) It must be this thead:
A thank you and a script question
Yes, thank you. I'm trying to modify it so that when the party is in the snowy maps, or the desert maps, they take cold or fire damage depending on the armor they are wearing. (in the snowy map they would take less damage for cloth or leather armor, and more for metal or no armor.)

IttaBitta
Posts: 19
Joined: Thu Oct 22, 2020 12:14 am

Re: Ask a simple question, get a simple answer

Post by IttaBitta » Wed Oct 28, 2020 1:45 am

New question:
is there a way to 'aim' where an item is spawned in, say, a chest?

ratman
Posts: 119
Joined: Fri Jan 10, 2020 1:13 am

Re: Ask a simple question, get a simple answer

Post by ratman » Wed Oct 28, 2020 3:03 am

I don't believe so. But you can use these functions to change the position of the item:

Code: Select all

rock_1:setWorldRotationAngles(0, 0, 0)
rock_1:setSubtileOffset(0, 0)
rock_1:setWorldPositionY(0)

User avatar
Isaac
Posts: 2972
Joined: Fri Mar 02, 2012 10:02 pm

Re: Ask a simple question, get a simple answer

Post by Isaac » Wed Oct 28, 2020 8:10 am

It can be done, but there is a requirement to it. For it to happen at load time, the container object spawn must precede the script object's setSource lines in dungeon.lua. This can be as simple as placing the container first, then placing the script_entity, or you can open the dungeon.lua file, and manually move the lines to the end of the file.

Using the delayedCall function works without the need for the specific definitions order.

Code: Select all

function setSurfaceItemFacing(containerId, identifier, facing) --identifier can be object name or ID
	if type(containerId) ~= "table" then	
		local obj = findEntity(containerId)
		facing = iff(facing<4 and facing>-1, facing, 0)
		if obj then 
			for _,itm in chest_1.surface:contents() do	
				if  identifier == itm.go.name or identifier == itm.go.id then 
					local subtileX, subtileY = itm.go:getSubtileOffset()
					local pos = itm.go:getWorldPositionY()				
					itm.go:setPosition(obj.x,obj.y,facing,obj.elevation,obj.level)
					itm.go:setSubtileOffset(subtileX,subtileY)
					itm.go:setWorldPositionY(pos)
					return
				end	
			end  
			 print("ERROR: "..self.go.id.." : setSurfaceItemFacing  : \"item not found\"") --comment out if using with delayedCall.
			else
			 print("ERROR: "..self.go.id.." : setSurfaceItemFacing  : \"container not found\"")
		end
	 else local caller = iff(containerId.go and containerId.go.name, containerId.go.name.."s", "caller")   
		print("ERROR: "..self.go.id.." : setSurfaceItemFacing  : \"incompatible with "..caller.."\"")		
	end
end
--==========================================================================================={This line, and all lines below it are safe to comment out, or delete.}===
--usage example  parameters: <container object>, <Item object>, <intended item facing>
setSurfaceItemFacing("chest_1", "figure_skeleton_1", 0)

-- alternatively, the function is compatible with delayedCall but can cause "item not found" console spam if the item is removed
--before the event completes. The line for printing this error can be commented out if need be.
for x = 0, 3, 1 do
	delayedCall("script_entity_1", x+2, "setSurfaceItemFacing", "chest_1", "figure_skeleton_1", x)
end
Image

Post Reply