Page 273 of 400

Re: Ask a simple question, get a simple answer

Posted: Thu Dec 27, 2018 6:42 am
by minmay
You can also use

Code: Select all

if Dungeon.getMaxLevels() == 0 then
to tell whether you're in the character creation screen.
7Soul wrote: Thu Dec 27, 2018 6:10 amAnd worth pointing out this should be put after standard assets and before mod assets
Only if you don't want your hook to be added to the standard assets' items...

Re: Ask a simple question, get a simple answer

Posted: Fri Dec 28, 2018 2:24 am
by 7Soul
minmay wrote: Thu Dec 27, 2018 6:42 am
7Soul wrote: Thu Dec 27, 2018 6:10 amAnd worth pointing out this should be put after standard assets and before mod assets
Only if you don't want your hook to be added to the standard assets' items...
When I did that it gave me an error "attempting to index 'c' (a boolean value)" or something like that

Re: Ask a simple question, get a simple answer

Posted: Fri Dec 28, 2018 4:22 am
by minmay
Oh, I see. There are a couple of mistakes in the standard assets where non-table values were inadvertently put in component tables. I didn't realize that when I wrote the code.
So here's an augmented version that detects and reports this problem:

Code: Select all

local orig_defineObject = defineObject
local onEquipItemHook = function(self, champion, slot)
	print("asdfasdf")
end
defineObject = function(def)
	if def.components then
		for k,c in pairs(def.components) do
			if type(c) ~= "table" then
				print(string.format("non-table value (%s = %s) encountered in component table for %s",
					tostring(k),tostring(c),tostring(def.name)))
			elseif c.class == "EquipmentItem" then
				c.onEquipItem = onEquipItemHook
			end
		end
	end
	orig_defineObject(def)
end

Re: Ask a simple question, get a simple answer

Posted: Sat Dec 29, 2018 12:53 pm
by Lorial
Hello there.

I require a helping hand concerning some problems I ran into after the release of my mod and I assume this would be easy to fix. It is important to be able to change it ingame using the console since a re-release would render all save games corrupt - not an option anymore at this point.

1) Alchemy:
I forgot to make a custom potion stackable (missing item list entry "stackable = true") which, of course, crashes the game upon creation. Is there a command line I can use ingame to fix that problem? Just to get an idea what I was thinking of:
"custom_potion".go.setStackable()

2) Teleporter Target Destination:
Due to map changes made after a certain teleporter, the party is now teleported to the wrong spot. I already listed a "safe haven" as a workaround when the party is stuck, but in this case the destination is essential to proceed.
Is there a way to change the destination ingame? My idea was to approach the "teleporter" submenu like the "controller" one, but no command seems to work. I can enable or disable the teleporter using teleporter_1.controller:disable(), (or deactivate) but how to change the teleport settings with console commands?
Something along these lines "teleporter_1.teleporter:setTarget (1,2,3,4,5)", but it tells me setTarget is invalid, what else.


3) While I am at it, is there a quick way to kill a specific monster with a console command? "monster_123".monster:destroy() or something.
4) And can I change the baseDamageStat (so the stat scaling of an item) ingame as well? I accidently made dex the scaling stat, but strength is what it should be.

Thank you in advance.

Re: Ask a simple question, get a simple answer

Posted: Mon Dec 31, 2018 3:11 pm
by SluisE
About problem 2: the correct method is setTeleportTarget(level, x, y, elevation).

You can find this and much more information at the modding-page of this site, under 'scripting reference'. It has a lot of useful information 8-)

Re: Ask a simple question, get a simple answer

Posted: Mon Dec 31, 2018 4:09 pm
by Zo Kath Ra
Lorial wrote: Sat Dec 29, 2018 12:53 pm I require a helping hand concerning some problems I ran into after the release of my mod and I assume this would be easy to fix. It is important to be able to change it ingame using the console since a re-release would render all save games corrupt - not an option anymore at this point.
1) This will make every "custom_potion" stackable, as long as it's in the game world (not in a champion inventory, not in a container)

Code: Select all

for i = 1, Dungeon.getMaxLevels() do 
    for e in Dungeon.getMap(i):allEntities() do 
        if e.name == "custom_potion" then 
            e.item:setStackable(true) 
            e.item:setStackSize(1) 
        end 
    end 
end 
2)

Code: Select all

teleporter_1.teleporter:setTeleportTarget(starting_location_1.level, starting_location_1.x, starting_location_1.y, starting_location_1.elevation) 
3)

Code: Select all

monster_123.monster:die() 
4)
Can you post the item definition?

Re: Ask a simple question, get a simple answer

Posted: Mon Dec 31, 2018 7:27 pm
by Pompidom
Lorial wrote: Sat Dec 29, 2018 12:53 pm Hello there.

I require a helping hand concerning some problems I ran into after the release of my mod and I assume this would be easy to fix. It is important to be able to change it ingame using the console since a re-release would render all save games corrupt - not an option anymore at this point.

Thank you in advance.
I don't see why releasing an updated version is a problem? Every mod out there has bugs and everyone releases updates for it.
Did you even upload it at https://www.nexusmods.com/legendofgrimrock2 ? Please do, so that everyone (non steam users) can enjoy your mod.

Happy new year and best wishes! :)

Re: Ask a simple question, get a simple answer

Posted: Tue Jan 01, 2019 12:37 am
by Lorial
SluisE wrote: Mon Dec 31, 2018 3:11 pm About problem 2: the correct method is setTeleportTarget(level, x, y, elevation).

You can find this and much more information at the modding-page of this site, under 'scripting reference'. It has a lot of useful information 8-)
I have been trying to wrap my head around the scripting reference forever, but I hardly ever glued things together properly. To this day I have no clue how to fuel my lantern with oil flasks even though setFuel or something is in there and recharging is a thing in the game...
Zo Kath Ra wrote: Mon Dec 31, 2018 4:09 pm
1) This will make every "custom_potion" stackable, as long as it's in the game world (not in a champion inventory, not in a container)
Via console this does not seem to work, they simply refuse to stack. Unfortunately, the crash occurs when making them, so only editing the potions.lua seems to have any effect.

The monster:die() and teleporter ones work like a charm, thank you so much, guys. Now all the fixes are one paragraph of copy&paste for players of the mod. An easy fix for 40+ hours of fun, seems like a fair deal. :P
Pompidom wrote: Mon Dec 31, 2018 7:27 pm I don't see why releasing an updated version is a problem? Every mod out there has bugs and everyone releases updates for it.
Did you even upload it at https://www.nexusmods.com/legendofgrimrock2 ? Please do, so that everyone (non steam users) can enjoy your mod.

Happy new year and best wishes! :)
Last time I updated the mod, I instantly got reports of software issues by players trying to load their previous save game. Perhaps this is a steam thing, but I did not want to ruin their fun any further. Steam overwrites old versions of subscribed mods by default, so I could not even upload a newer version and leave it to players whether they wanted to update and start over or not. I could of course upload another workshop entry, but now the main fix is a simple copy&paste.
I had not even considered releasing it on Nexusmods to be honest, will look into it tomorrow. :P

Happy new year to you too, guys.

Re: Ask a simple question, get a simple answer

Posted: Tue Jan 01, 2019 10:09 am
by Isaac
Lorial wrote: Tue Jan 01, 2019 12:37 am I have been trying to wrap my head around the scripting reference forever, but I hardly ever glued things together properly. To this day I have no clue how to fuel my lantern with oil flasks even though setFuel or something is in there and recharging is a thing in the game...
Start with this (if you haven't already): https://github.com/JKos/log2doc/wiki

Re: Ask a simple question, get a simple answer

Posted: Sat Jan 05, 2019 2:09 pm
by bongobeat
Hello and happy new year to you guys!

I need help with this script please:
I want to open a door whith the party casting a special spell, but I can't figure how to do that correctly.

This is what I tried, based on a script on another thread, but that don't do anything. Linked to a timer, the timer trigger the script each 0.001 sec.

Code: Select all

function darknessSpell()
      onCastSpell = function(party,champion,spellName)
         if spellName == "darkness" then
			hudPrint("Found!")
			darkness_door.door:open()
            return false
         end       
      end
end