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: 3179
Joined: Fri Mar 02, 2012 10:02 pm

Re: Ask a simple question, get a simple answer

Post by Isaac »

CrEaToXx wrote:

Code: Select all

function extraSkillPoints()
	for i = 1,4 do
		local cChampion = party.party:getChampion(i)
		hudPrint(tostring(cChampion:getName()))
    	local cRace = cChampion:getRace()
		hudPrint(tostring(cChampion:getRace()))	
		if cRace == "dwarf" then
			cChampion:addSkillPoints(1)			
		end
	end	
end
Now I just need to find a way to initialize the script without the press of a button. Counter? Connect the script to opening the cage gate? Any other suggestions?
There is a simpler way...

Code: Select all

function extraSkillPoints()
	for i = 1,4 do
		local cChampion = party.party:getChampion(i)
		hudPrint(tostring(cChampion:getName()))
    	local cRace = cChampion:getRace()
		hudPrint(tostring(cChampion:getRace()))	
		if cRace == "dwarf" then
			cChampion:addSkillPoints(1)			
		end
	end	
end
extraSkillPoints()
Grimfan
Posts: 369
Joined: Wed Jan 02, 2013 7:48 am

Re: Ask a simple question, get a simple answer

Post by Grimfan »

Quick question,

I placed an item in an alcove that I altered with setWorldPosition and the item became irretrievable. Do I have to set the vector of the item on the surface as well (this thought just occurred to me)?
User avatar
zimberzimber
Posts: 432
Joined: Fri Feb 08, 2013 8:06 pm

Re: Ask a simple question, get a simple answer

Post by zimberzimber »

Grimfan wrote:Quick question,

I placed an item in an alcove that I altered with setWorldPosition and the item became irretrievable. Do I have to set the vector of the item on the surface as well (this thought just occurred to me)?
You don't have to change the surfaces world position for this, because it only serves as a clickbox for new items to be added, and if an item was already added and the position of the surface altered, the item will not move with it.
You'll have to adjust the items world position instead, or move the surface object and only then add the item.
Make sure you do not attempt to unlink the item from the surface, there is no clean error free way you can do this.
My asset pack [v1.10]
Features a bit of everything! :D
CrEaToXx
Posts: 25
Joined: Thu Jan 19, 2017 9:58 pm

Re: Ask a simple question, get a simple answer

Post by CrEaToXx »

Isaac wrote:
CrEaToXx wrote:

Code: Select all

function extraSkillPoints()
	for i = 1,4 do
		local cChampion = party.party:getChampion(i)
		hudPrint(tostring(cChampion:getName()))
    	local cRace = cChampion:getRace()
		hudPrint(tostring(cChampion:getRace()))	
		if cRace == "dwarf" then
			cChampion:addSkillPoints(1)			
		end
	end	
end
Now I just need to find a way to initialize the script without the press of a button. Counter? Connect the script to opening the cage gate? Any other suggestions?
There is a simpler way...

Code: Select all

function extraSkillPoints()
	for i = 1,4 do
		local cChampion = party.party:getChampion(i)
		hudPrint(tostring(cChampion:getName()))
    	local cRace = cChampion:getRace()
		hudPrint(tostring(cChampion:getRace()))	
		if cRace == "dwarf" then
			cChampion:addSkillPoints(1)			
		end
	end	
end
extraSkillPoints()
I'm not sure I exactly understand what you mean? Does your code with the extraSkillPoints() snippet by the end, trigger the skillpoint increase without the need for a timer? Which would be cool, this way I could entirely avoid to edit the original dungeon.
User avatar
zimberzimber
Posts: 432
Joined: Fri Feb 08, 2013 8:06 pm

Re: Ask a simple question, get a simple answer

Post by zimberzimber »

Yup, that exactly what it does.
My asset pack [v1.10]
Features a bit of everything! :D
CrEaToXx
Posts: 25
Joined: Thu Jan 19, 2017 9:58 pm

Re: Ask a simple question, get a simple answer

Post by CrEaToXx »

zimberzimber wrote:Yup, that exactly what it does.
Uhhh, works flawlessly... 8-)

But I can't get around triggering the script without placing a script entity into the dungeon, correct? Like f.e. triggering it from inside the init.lua? Or placing a script entity via .lua without the need to edit the original dungeon?

Edit: Ha, guess I've found something...

viewtopic.php?p=41932#p41932

Edit 2:

Or maybe this...

viewtopic.php?f=22&t=8147#p82771
User avatar
zimberzimber
Posts: 432
Joined: Fri Feb 08, 2013 8:06 pm

Re: Ask a simple question, get a simple answer

Post by zimberzimber »

What's wrong with adding a script entity that triggers itself?
My asset pack [v1.10]
Features a bit of everything! :D
CrEaToXx
Posts: 25
Joined: Thu Jan 19, 2017 9:58 pm

Re: Ask a simple question, get a simple answer

Post by CrEaToXx »

zimberzimber wrote:What's wrong with adding a script entity that triggers itself?
Nothing. I just want to prevent editing the original dungeon, to raise compatibility with other mods.

As far as I understand, if I would want to make the race mod compatible with others, I'd need to merge changes from both mods made in the original dungeon?
User avatar
zimberzimber
Posts: 432
Joined: Fri Feb 08, 2013 8:06 pm

Re: Ask a simple question, get a simple answer

Post by zimberzimber »

CrEaToXx wrote:Nothing. I just want to prevent editing the original dungeon, to raise compatibility with other mods.

As far as I understand, if I would want to make the race mod compatible with others, I'd need to merge changes from both mods made in the original dungeon?
So far, you're the second person to mod on the vanilla map. It highly unlikely someone will use the vanilla map for their mod because people prefer making their own unique adventure. (Thats better in my opinion)

If you are to add a script file on the map, it won't cause any incompatibility issues with anything. But if you are to share your custom classes with people, you will have to provide the script for the required thing.
Like in some asset packs where scripts are required, you can write the script in an external file (not in the editor, but on a .lua file and place it in the mod folder), define a single object that will spawn script_entities, and link them to an external script files.

Kinda like this:

Code: Select all

defineObject{			-- Spawns all necessary scripts and objects
	name = "myExternalScriptLinker",
	components = {
		{
			class = "Null",
			onInit = function(self)
				spawn("script_entity", 1, 0, 0, 0, 0, "id_for_this_object_for_future_reference").script:loadFile("mod_assets/external_scripts/my_external_script.lua")
				self.go:destroy()
			end
		},
	},
	placement = "floor",
	editorIcon = 148,
}
My asset pack [v1.10]
Features a bit of everything! :D
CrEaToXx
Posts: 25
Joined: Thu Jan 19, 2017 9:58 pm

Re: Ask a simple question, get a simple answer

Post by CrEaToXx »

So far, you're the second person to mod on the vanilla map. It highly unlikely someone will use the vanilla map for their mod because people prefer making their own unique adventure. (Thats better in my opinion)
I agree, though I'd wish there'd be more people expanding vanilla content. The one person you're refering to might not have much endorsements over at the Nexus, but I consider his highly unterrated magic mod to be vital for my next playthrough, and I want to provide compatibility. On the other hand, I'm doing this race pack just to understand the engine and figure how to fully utilize it for another project, which will create a completely new realm outside of LoG. It's named Stearnreik - Tales of Antorom. I already created hand drawn sketches for the world, and the next stage after the race pack, will be providing a teaser trailer cinematic for Stearnreik. It's a new planet, inside a new star system. I'm planing a lot for it. New continents, new kingdoms, new races, new magical system based on earth like physics/chemicals rather then "real" magic.

There's more then 100 sketches to fiddle around with the idea, so far the only things I'm planing to use from LoG are the tile sets and monsters, because, though I'm quite capable with Nifskope, I never created new models for all the other games I'm modding (primarly Skyrim, Fallout 4, Minecraft and Civilization 5). I'm currently made mods for 7 different games, and all mods are in a stage of ongoing expansion. I'm more or less fluid in Java, Python(and it's less powerful brother Papyrus), .html and C++. Lua is the newest addition, though I messed with it in Half-Life 2 a decade ago. I'm also quite capable with Gimp and provided tools. Ontop of that I'm a musician and have all the tools at my hand to create any possible audio content.
If you are to add a script file on the map, it won't cause any incompatibility issues with anything.
Yeah, but you can't run two dungeon based mods at the same time? So I'm aiming for a version of the race pack that will merge my changes with @leindels dungeon file. I will release the complete source as well, so people can add it to their mods/dungeons. It's going to take some time though, because I still don't have all the permissions for portrait files, taken from Deviant art and other sources. I'm capable to make my own portraits, but then the race pack would probably taken month to finish.

However, the race pack will have this content:

- races: Elfs, Half-Elfs, Dwarfs, Orcs, Wolflings, Catlings, Arachnoid, Birdlings, Fishlings, Batlings, Bearlings, Horse People and Snake People
- classes: Ranger, Mage, Archer, Bard, Spellsword, Monk, Scout, Sorcerer, Thief, Warrior, Warlock, Witchhunter
- Gender Diversity (already messed a little with it, but the results were far to complicated to provide acceptable gameplay, so this idea might be abandoned)
- limit playble races when other races are already in the party

Thanks for your tremendous input guys, I know newbies can be quite irritating. Whatever, I'm digressing... :?
Post Reply