Merry Christmas!

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
JohnWordsworth
Posts: 1397
Joined: Fri Sep 14, 2012 4:19 pm
Location: Devon, United Kingdom
Contact:

Re: Merry Christmas!

Post by JohnWordsworth »

petri wrote: Sat Dec 26, 2020 8:21 am Hi! That is an interesting idea! However, umods code must be disributed as plain text files. That rules out any native extensions like that, the licensing terms explicitly forbid precompiled code. This is for security reasons so that anyone can check that the mod is not doing bad things if needed, and also so that the mod can (at least in theory) work on any platform where Grimrock can run.
Makes complete sense of course for the safety of the user. I guess for the most simple interop, the mod could just periodically write a text file that an external application could then be used to parse and render a map from. It's mostly theoretical anyway, as I really shouldn't pick up another side-project right now!
My Grimrock Projects Page with links to the Grimrock Model Toolkit, GrimFBX, Atlas Toolkit, QuickBar, NoteBook and the Oriental Weapons Pack.
User avatar
JohnWordsworth
Posts: 1397
Joined: Fri Sep 14, 2012 4:19 pm
Location: Devon, United Kingdom
Contact:

Re: Merry Christmas!

Post by JohnWordsworth »

antti wrote: Sat Dec 26, 2020 11:42 am I'm keen to hear what kinds of ideas pop into YOUR heads with a system like this or what kinds of limitations have caused you frustration with the Dungeon Editor?
I think what's most exciting about umods is the ability to make more changes to the main game / default "dungeon". Some ideas that immediately spring to mind as things I would love to spend a bit of time on;

* Crafting: I know the game has alchemy, but you could dismantle and craft weapons/armour in a similar way.
* Roguelike: I quite like the idea (from an experimental point of view) of being able to visit a place on the island that will randomly generate a different small dungeon every time you enter.
* Spellcrafting: I'm contemplating a system where you could generate spells by picking "range", "effect" and "intensity"...
My Grimrock Projects Page with links to the Grimrock Model Toolkit, GrimFBX, Atlas Toolkit, QuickBar, NoteBook and the Oriental Weapons Pack.
User avatar
THOM
Posts: 1266
Joined: Wed Nov 20, 2013 11:35 pm
Location: Germany - Cologne
Contact:

Re: Merry Christmas!

Post by THOM »

What's about monsters attacking monsters?
THOM formaly known as tschrage
_______________________________________________
My MOD (LoG1): Castle Ringfort Thread
My MOD (LoG2): Journey To Justice Thread | Download
User avatar
Isaac
Posts: 3172
Joined: Fri Mar 02, 2012 10:02 pm

Re: Merry Christmas!

Post by Isaac »

THOM wrote: Sat Dec 26, 2020 4:26 pm What's about monsters attacking monsters?
Doom & Heretic style(?), or factions, or defined targets? I would like that kind of option.
User avatar
petri
Posts: 1917
Joined: Thu Mar 01, 2012 4:58 pm
Location: Finland

Re: Merry Christmas!

Post by petri »

The experimental release in the nutcracker branch has been updated to version 2.3.3.

Changes:
- bug fix: dungeon exporting crashes
- removed easter egg
- added updated umod pack to extras folder (new: Dungeon Editor sources)

If you find any new bugs, please report them here.
User avatar
THOM
Posts: 1266
Joined: Wed Nov 20, 2013 11:35 pm
Location: Germany - Cologne
Contact:

Re: Merry Christmas!

Post by THOM »

Still only on steam?
THOM formaly known as tschrage
_______________________________________________
My MOD (LoG1): Castle Ringfort Thread
My MOD (LoG2): Journey To Justice Thread | Download
User avatar
Zo Kath Ra
Posts: 931
Joined: Sat Apr 21, 2012 9:57 am
Location: Germany

Re: Merry Christmas!

Post by Zo Kath Ra »

petri wrote: Sun Dec 27, 2020 10:10 am - added updated umod pack to extras folder (new: Dungeon Editor sources)
Thank you for giving us more to mod!
petri wrote: Sun Dec 27, 2020 10:10 am If you find any new bugs, please report them here.
Dungeon Editor:
When I reload, it doesn't apply the changes made to umods after starting the editor.
I have to go back to the main menu and restart the Dungeon Editor.

Is this a bug or am I doing something wrong?
I don't suppose there's a reloadUmod function that we can call in DungeonEditor.lua ?
User avatar
petri
Posts: 1917
Joined: Thu Mar 01, 2012 4:58 pm
Location: Finland

Re: Merry Christmas!

Post by petri »

Zo Kath Ra wrote: Sun Dec 27, 2020 9:32 pm When I reload, it doesn't apply the changes made to umods after starting the editor.
I have to go back to the main menu and restart the Dungeon Editor.
Unfortunately umods are loaded only when the app starts, but a resourceful modder could add a new menu option that executes: sys.restart{ "launchEditor" }
User avatar
7Soul
Posts: 199
Joined: Sun Oct 19, 2014 1:56 am
Location: Brazil

Re: Merry Christmas!

Post by 7Soul »

I added it to the shortcuts, but I had to copy the whole update() function for it and I'm scared petri will yell at me for it

Ctrl+Y restarts the editor
Ctrl+T returns to main menu
SpoilerShow

Code: Select all

function DungeonEditor:update()
	if not renderer:isReadyToRender() or (config.sleepWhenNoFocus and not mainFrame:hasFocus()) then
		sys.sleep(100)
		return
	end

	if self.pendingLoadDungeon then
		self:loadDungeon(self.pendingLoadDungeon)
		self.pendingLoadDungeon = nil
	end

	updateTime()
	updateFileChangeRequests()
	
	--sys.sleep(50)
	
	-- update input state
	local windowSizeChanged = false
	do
		local state = imgui.state
		state.doubleClick = detectDoubleClick()

		-- clear unprocessed keys
		state.keyInput = {}
		state.mouseWheel = 0
		
		-- poll events
		while true do
			local event = mainFrame:pollEvents()
			if not event then break end
			if event.type == "key" and event.down then
				--print(event.key, event.char)			
				state.keyInput[#state.keyInput+1] = event
				
				-- global keys
				local action = config:convertEditorKeyToAction(event.keyCode, event.modifiers)
				if event.key == "O" and event.modifiers == 2 then self:onOpenProject() end
				if event.key == "S" and event.modifiers == 2 then self:onSaveProject() end
				if event.key == "R" and event.modifiers == 2 then self:onReloadProject() end
				if event.key == "T" and event.modifiers == 2 then self:onBackToGame() end
				if event.key == "Y" and event.modifiers == 2 then sys.restart{ "launchEditor" } end
				if action == "start_preview" then self:playPreview() end
				if action == "stop_preview" then self:stopPreview() end
			elseif event.type == "mouse_wheel" then
				state.mouseWheel = state.mouseWheel + event.delta
			elseif event.type == "menu" then
				self:onMenuEvent(event.id)
			elseif event.type == "resize" then
				self.windowWidth = event.width	-- 0 when window is minimized
				self.windowHeight = event.height
				windowSizeChanged = true
			elseif event.type == "close" then
				self:confirmClose(function() sys.exit() end)
			end
		end		
	end

	-- early out if window is minimized
	if self.windowWidth == 0 or self.windowHeight == 0 then return end

	-- recreate render window if window was resized
	if windowSizeChanged then
		renderer:resizeRenderBuffers(self.windowWidth, self.windowHeight)
	end
		
	-- update steam
	steamContext:update()
		
	renderer:setViewport(0, 0, self.windowWidth, self.windowHeight)
	renderer:beginRender()
	
	ImmediateMode.beginDraw()
	imgui.prepare(mainFrame)

	local screenWidth = self.windowWidth
	local screenHeight = self.windowHeight

	if self.previewMode and self.fullscreen then
		-- fullscreen preview mode
		self:preview(0, 0, screenWidth, screenHeight)
	else
		ImmediateMode.fillRect(0, 0, screenWidth, screenHeight, {41,41,41,255})
		
		self:toolBar(20, 10, 200, 30)
		self:brushInfo(self.splitter1 + 2, 10, (screenWidth - self.splitter1) - self.splitter2 - 4, 30)

		-- screen height without status bar
		local screenHeight2 = screenHeight - 20
		
		-- project/asset browser splitter
		do
			local x = 0
			local y = 44
			local width = self.splitter1 - 2
			local height = screenHeight2 - y
			
			-- asset browser
			do
				local y = self.splitter4+2
				local height = screenHeight2 - y
				self:assetBrowser(x, y, width, height)
			end
			
			-- project explorer
			do
				local height = self.splitter4 - y - 2
				self:projectExplorer(x, y, width, height)
			end

			-- splitter 4
			self.splitter4 = imgui.vsplitter("splitter4", x, self.splitter4, width)
			self.splitter4 = math.clamp(self.splitter4, y + 50, screenHeight2 - 22)
		end
		
		-- map view
		do
			local x = self.splitter1 + 4
			local y = 44
			local width = (screenWidth - self.splitter2) - self.splitter1 - 8
			local height = screenHeight2 - y
			self:mapView(x, y, width, height)
		end
		
		-- preview/inspector splitter
		do
			local x = (screenWidth - self.splitter2) + 2
			local y = 44
			local width = screenWidth - x
			local height = screenHeight2 - y
			
			-- inspectors
			do
				local y = self.splitter3+2
				local height = screenHeight2 - y
				local sel = iff(#self.selection == 1, self.selection[1], nil)							
				self.inspector:inspect(sel, x, y, width, height, 0)
			end
				
			-- preview
			do
				local height = self.splitter3 - y - 2
				self:previewButtons(x, 10)
				if self.previewMode and self.fullscreen then
					self:preview(0, 0, screenWidth, screenHeight)
				else
					self:preview(x, y, width, height)
				end
			end

			-- splitter 3
			self.splitter3 = imgui.vsplitter("splitter3", x, self.splitter3, width)
			self.splitter3 = math.clamp(self.splitter3, y + 50, screenHeight2 - 22)
		end
				
		-- status bar
		do
			local h = 17
			local x = 0
			local y = screenHeight - h
			ImmediateMode.fillRect(x, y, screenWidth, h, {56,56,56,255})
			if self.status then ImmediateMode.drawText(self.status, x+4, y+2, imgui.state.font, {200,200,200,255}) end
			
			-- draw coordinates
			if self.mouseCellX and self.mouseCellY then
				local text = string.format("%d,%d", self.mouseCellX, self.mouseCellY)
				local textWidth = imgui.state.font:getTextWidth(text)
				local x = x + screenWidth - textWidth - 4
				ImmediateMode.fillRect(x-4, y, textWidth+8, h, {56,56,56,255})
				ImmediateMode.drawText(text, x, y + 2, imgui.state.font, {200,200,200,255})
			end
		end
		
		-- splitter 1 (measured from left screen edge)
		self.splitter1 = imgui.hsplitter("splitter1", self.splitter1, 0, screenHeight)
		self.splitter1 = math.clamp(self.splitter1, 10, (screenWidth - self.splitter2)-10)
		
		-- splitter 2 (measured from right screen edge)
		self.splitter2 = screenWidth - imgui.hsplitter("splitter2", screenWidth - self.splitter2, 0, screenHeight)
		self.splitter2 = math.clamp(self.splitter2, 10, (screenWidth - self.splitter1)-10)

		self:updateContextMenu()
	end
	
	if self.dialog then
		self.dialog:update()
		if self.dialog.close then self.dialog = nil end
	end

	imgui.finish()
	
	ImmediateMode.endDraw()

	renderer:endRender()

	tvec.free()
	tmat.free()
end
Join the LoG discord server: https://discord.gg/ArgAgNN :D

My Mods
User avatar
petri
Posts: 1917
Joined: Thu Mar 01, 2012 4:58 pm
Location: Finland

Re: Merry Christmas!

Post by petri »

That is indeed bad.

Note that config:convertEditorKeyToAction is called just before your addition, so you should be able to hook to Config.convertEditorKeyToAction instead of copying the whole update funtion. Could you fix this, please?

Why is this important? Multiple mods can't override update function like you've done, but multiple mods can hook up to convertEditorKeyToAction.
Post Reply