Page 1 of 2

A script that work for one player but not for another one...

Posted: Sat Jan 06, 2018 6:23 pm
by Khollik
Hello everyone

I'm struggling hard with a couple of bugs in my first mod (Lost Power of Nadric) and I would really appreciate help from more experienced moders.

The thing is that I have a couple of scripts that do work well with me, either in the editor or in exported version BUT sometimes, it seems not to work for other players. I can't figure out how it is possible :?:

For example, I have a floortrigger that activates a script which casts a darkness spell by using the champions energy. Here is the code of the script (quite basic actually):

Code: Select all

function darknesscast()
       for i = 1, 4 do
          party.party:getChampion(i):regainEnergy(35)
          party.party:getChampion(i):castSpell(58)
       end
end
I don't mind if the spell fizzles because no one can't cast a light/dark spell. The point is to put the party into darkness (and obviously there won't be any light spell if there is no spellcaster). Actually, I tried with a fresh new party and no spellcaster: the spell isn't cast but at least the game does not crash. Unfortunately, there is a game crash for another player, Orace.

Image

Script_entity_31 is the one with the darknesscast code.

Any advice here???

Khollik

Re: A script that work for one player but not for another on

Posted: Sat Jan 06, 2018 8:19 pm
by Zo Kath Ra
(it's ptobably not this; if it were, the error message would be different)
SpoilerShow
He's probably playing an old version of LoG2.
viewtopic.php?f=23&t=9031&p=109873&hili ... ll#p109873
Or there are less than 4 champions in his party.

Re: A script that work for one player but not for another on

Posted: Sat Jan 06, 2018 8:51 pm
by zimberzimber
Did they import the party from another mod?

Re: A script that work for one player but not for another on

Posted: Sun Jan 07, 2018 2:33 am
by Isaac
Try using one of these instead of casting the darkness spell:

Pitch black: (Blunt, but stable. Probably too harsh to actually use.)

Code: Select all

function darknessToggle()  
	if party.torch:isEnabled() then
		party.torch:disable()
	 else party.torch:enable()	
	end
end
Dimmed to near black: (Experimental; if there is a simpler/better way, I'd really love to learn it.)

Code: Select all

function dimnessToggle() --effect controller
	if party.dimmerSwitch then
		if party.dimmerSwitch:isEnabled() then
			party.dimmerSwitch:disable()
		 else party.dimmerSwitch:enable()	
		end
	 else
	 	party:createComponent('Timer', 'dimmerSwitch')
		party.dimmerSwitch:setTimerInterval(.005) --tweak lower if needed; (you will know if you need it).
		party.dimmerSwitch:addConnector('onActivate', self.go.id, 'dim')
	end
end

function dim() --dimness effect
		party.torch:setBrightness(.2) -- lower equals darker
		party.torch:setColor(vec(.05, .06, .012))
end

Re: A script that work for one player but not for another on

Posted: Sun Jan 07, 2018 4:21 pm
by Khollik
Thanks for your help.
Seemingly he plays with the same version as mine. I asked him if it was an imported party (to be sure). But I also have another player stumbling into a similar script (with a CastSpell) in another part of the mod, with the same problem.

Isaac, I also have a script which checks if the champions have a torch in hand and burn it out. This one seems to work fine, actually, but I'll try yours, though I'm not sure how the second one works ;)

Khollik

Re: A script that work for one player but not for another on

Posted: Sun Jan 07, 2018 5:33 pm
by Zo Kath Ra
Khollik wrote:Thanks for your help.
But I also have another player stumbling into a similar script (with a CastSpell) in another part of the mod, with the same problem.
Did he provide a savegame?

Re: A script that work for one player but not for another on

Posted: Sun Jan 07, 2018 9:00 pm
by Isaac
Khollik wrote:Isaac, I also have a script which checks if the champions have a torch in hand and burn it out. This one seems to work fine, actually, but I'll try yours, though I'm not sure how the second one works ;)

Khollik
Both were written with the idea that you would activate them with a floor trigger, as in your topic post. On my test map, when the party steps on a plate, the light's go out.

The function dimnessToggle() is called to make it dark, and called again to make it bright; suitable for buttons & floor_triggers... or any scripts.
A floor_trigger set to Activate or Deactivate would begin or end the effect, and if set to Toggle, would make it dark (or light) only while the plate is depressed. Levers, (even buttons) can be attached to make light switches; but these would be world-affecting. It was not originally intended for room-by-room lighting control; more like the anti-magic zones in Bard's Tale; temporarily enforced underground darkness. It doesn't work in outdoor areas.

Re: A script that work for one player but not for another on

Posted: Sun Jan 07, 2018 10:43 pm
by minmay
This error occurs when the player imports a party with a trait that doesn't exist in the mod and a champion casts a spell. This is due to how learning new spells is handled internally. There is nothing you can do to fix it.

Re: A script that work for one player but not for another on

Posted: Mon Jan 08, 2018 4:02 am
by AndakRainor

Re: A script that work for one player but not for another on

Posted: Mon Jan 08, 2018 7:44 pm
by Khollik
Hello guys

Thanks for the answers!

@Isaac: the first code is quite radical but works fine. I shall use it to prevent the castspell function which seems to cause to bug. Thanks again.

@Minmay and AndakRainor: I'm waiting for his response but if it is the case, then it is settled (and I learned something here)... :?

As for me, I prefer beginning with a new party when I play a new mod, particularly because a strong party can overkill the pleasure to struggle for the first experience levels. Maybe I should warn in the description of the mod about playing with an imported party.

Cheers
Khollik