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
Duncan1246
Posts: 404
Joined: Mon Jan 19, 2015 7:42 pm

Re: Ask a simple question, get a simple answer

Post by Duncan1246 »

Isaac wrote:I would model a ray that was several tiles long, and add it as a model component to the party when fired. With an offset & rotation that originates from whichever slot the champion occupies.[totally faking] the PC's poor firearm accuracy at range.
minmay wrote:I assume Duncan1246 wanted to display the beam for more than a single frame. Even if they were okay with that, it'd still break if the party is turning.
Thanks for your replies, you go further than I and I have to test some of your proposals. My idea for now is to create a beam between two points, several tiles long, spawned from the first to the second, and the beam must last until some party's action. It's not a party's weapon, so no problem for free look and I choose the position from where the party will see the beam. I think that the second proposal of Minmay is the most convenient in this case. In a second time, the possibility of beam rotation is interesting also.
Anyway, thanks, I think I have some hard work to do now, specially modeling... :mrgreen:
The Blue Monastery (LOG1)
download at:http://www.nexusmods.com/grimrock/mods/399/?

Finisterrae(LOG2)
download at:http://www.nexusmods.com/legendofgrimrock2/mods/61/?
User avatar
Isaac
Posts: 3185
Joined: Fri Mar 02, 2012 10:02 pm

Re: Ask a simple question, get a simple answer

Post by Isaac »

minmay wrote:I assume Duncan1246 wanted to display the beam for more than a single frame. Even if they were okay with that, it'd still break if the party is turning.
That happens anyway. Turn while throwing a projectile, and the item flies off to the side.
minmay
Posts: 2780
Joined: Mon Sep 23, 2013 2:24 am

Re: Ask a simple question, get a simple answer

Post by minmay »

Isaac wrote:
minmay wrote:I assume Duncan1246 wanted to display the beam for more than a single frame. Even if they were okay with that, it'd still break if the party is turning.
That happens anyway. Turn while throwing a projectile, and the item flies off to the side.
Flying off to the side is what it should do. You don't want players to be able to fire the beam at any angle, do you?

Oh and you can attack while the camera is moving back to the rest position anyway, or while standing over a pressure plate, etc. etc. so even for a single frame and no turning, attaching it to the party wouldn't work.
Grimrock 1 dungeon
Grimrock 2 resources
I no longer answer scripting questions in private messages. Please ask in a forum topic or this Discord server.
User avatar
AndakRainor
Posts: 674
Joined: Thu Nov 20, 2014 5:18 pm

Re: Ask a simple question, get a simple answer

Post by AndakRainor »

The definition of thorn_wall seems to be missing in the asset pack. Is there any way to get all its components to know its structure ?
User avatar
Isaac
Posts: 3185
Joined: Fri Mar 02, 2012 10:02 pm

Re: Ask a simple question, get a simple answer

Post by Isaac »

Certain items have a tags table in their definition. Is this accessible in a script, and if so ~how? :?
minmay
Posts: 2780
Joined: Mon Sep 23, 2013 2:24 am

Re: Ask a simple question, get a simple answer

Post by minmay »

Not that I know of. Tags are just for the convenience of dungeon editor users.
Grimrock 1 dungeon
Grimrock 2 resources
I no longer answer scripting questions in private messages. Please ask in a forum topic or this Discord server.
User avatar
AndakRainor
Posts: 674
Joined: Thu Nov 20, 2014 5:18 pm

Re: Ask a simple question, get a simple answer

Post by AndakRainor »

Code: Select all

setMouseItem(item)
Sets the given item as mouse item, or destroys the mouse item if item is nil.
If I replace the mouse item with a new spawned item, is the previous item destroyed the same way, or should I use nil before setting a new item ?

(I was wondering if it could be a good idea to add a sticky on the subject of memory leaks... I was thinking about projectiles exiting the map, items removed form inventory without a location in a game map, or any other possible trap for a modder...)
minmay
Posts: 2780
Joined: Mon Sep 23, 2013 2:24 am

Re: Ask a simple question, get a simple answer

Post by minmay »

AndakRainor wrote:

Code: Select all

setMouseItem(item)
Sets the given item as mouse item, or destroys the mouse item if item is nil.
If I replace the mouse item with a new spawned item, is the previous item destroyed the same way, or should I use nil before setting a new item ?
From my testing, it appears that component/object references lost by removing them from the mouse/inventory/whatever are not garbage collected, so there is a potential resource leak here. However, they also won't be serialized, so that resource leak disappears as soon as the player reloads the game. It's also a very small one; the object isn't on a map, so it won't be wasting time updating or rendering anything. All it really does is consume a little Lua memory. You rarely need to worry about it, unless you are losing thousands of items this way.
Grimrock 1 dungeon
Grimrock 2 resources
I no longer answer scripting questions in private messages. Please ask in a forum topic or this Discord server.
User avatar
The cube
Posts: 94
Joined: Tue Apr 23, 2013 6:09 pm
Location: Barren Desert

Re: Ask a simple question, get a simple answer

Post by The cube »

Code: Select all

function translate()
	count = 0
	for v,i in forest_altar_1.surface:contents() do
		if i.go.id == "foreign_note" then
		
			local note = spawn("note");
			note.scrollitem:setScrollText("translated_text")
			forest_altar_1.surface:addItem(note.item);                       <-------
			
			i:destroy()
		end
	end
end
this gives me a stack overflow error at the line with a smiley. What's wrong?
minmay
Posts: 2780
Joined: Mon Sep 23, 2013 2:24 am

Re: Ask a simple question, get a simple answer

Post by minmay »

looks like you're triggering the connector again every time you add an item
also, you really, really, really should not modify the contents of a surface while iterating through them, that script can break in like 5000 different ways because of that; use i:destroyDelayed() instead of i:destroy() and add the notes after you finish iterating
Grimrock 1 dungeon
Grimrock 2 resources
I no longer answer scripting questions in private messages. Please ask in a forum topic or this Discord server.
Post Reply