New modder, need help (Default party, custom class)

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
bazuso
Posts: 15
Joined: Sat Jul 29, 2017 12:40 pm

Re: New modder, need help (Default party, custom class)

Post by bazuso »

Isaac wrote:That means it ~seems~ to work for me, and not for you. What happens if you start a new project, and add my script & floor_trigger? (Test it in-game using the custom map.)

* Check the About Box in the editor's Help menu. Ensure that the editor version is 2.2.4.
The script works in the new test dungeon, and the editor version is 2.2.4. I'm assuming my issue is tied to the fact I'm trying to force custom portraits then?
User avatar
Isaac
Posts: 3172
Joined: Fri Mar 02, 2012 10:02 pm

Re: New modder, need help (Default party, custom class)

Post by Isaac »

The script is intended to force custom portraits. This of itself should not be a problem.

How deep are you into developing your map? How many scripts do you have? The only place the problem can be... is in one of those scripts; it works in a new map.

The course is to scrutinize the scripts you have; and possibly re-implement it from scratch. Pick through it until something stands out. The second time around is often the better design anyway.
Last edited by Isaac on Sun Jul 30, 2017 3:48 am, edited 1 time in total.
User avatar
bazuso
Posts: 15
Joined: Sat Jul 29, 2017 12:40 pm

Re: New modder, need help (Default party, custom class)

Post by bazuso »

I'm only around two hours into making the current map. I don't have any other scripts on the map besides the one that activates when the players spawn, which changes their name and race.
User avatar
Isaac
Posts: 3172
Joined: Fri Mar 02, 2012 10:02 pm

Re: New modder, need help (Default party, custom class)

Post by Isaac »

Post your script, and I will look at it.
User avatar
bazuso
Posts: 15
Joined: Sat Jul 29, 2017 12:40 pm

Re: New modder, need help (Default party, custom class)

Post by bazuso »

Isaac wrote:Post your script, and I will look at it.

Code: Select all

function setPortraits()
   local images = {
                  "minotaur_male_11",
               "minotaur_male_10",
               "human_female_10",
               "human_male_10"
               }
   for x = 1, #images do
      local champ = party.party:getChampion(x)
      local path = "assets/textures/portraits/"
      local file = images[x]..".tga"
      if champ:getEnabled() then 
         champ:setPortrait(path..file)
      end   
   end
end
setPortraits() 

party.party:getChampion(1):setName("test1")
party.party:getChampion(1):setRace("minotaur")
party.party:getChampion(1):setSex("male")
party.party:getChampion(2):setName("test2")
party.party:getChampion(2):setRace("minotaur")
party.party:getChampion(2):setSex("male")
party.party:getChampion(3):setName("test3")
party.party:getChampion(3):setRace("human")
party.party:getChampion(3):setSex("female")
party.party:getChampion(4):setName("test4")
party.party:getChampion(4):setRace("human")
party.party:getChampion(4):setSex("male")
I also tried separating them into separate script entities to no avail.
User avatar
Isaac
Posts: 3172
Joined: Fri Mar 02, 2012 10:02 pm

Re: New modder, need help (Default party, custom class)

Post by Isaac »

The problem is that the floor_trigger cannot call your statements unless they are in a function block.

Outside of a function, it runs earlier, and doubtless gets overwritten later. When the floor_trigger runs, it never calls them.

Code: Select all

function setCustomPC()
   party.party:getChampion(1):setName("test1")
   party.party:getChampion(1):setRace("minotaur")
   party.party:getChampion(1):setSex("male")
   party.party:getChampion(2):setName("test2")
   party.party:getChampion(2):setRace("minotaur")
   party.party:getChampion(2):setSex("male")
   party.party:getChampion(3):setName("test3")
   party.party:getChampion(3):setRace("human")
   party.party:getChampion(3):setSex("female")
   party.party:getChampion(4):setName("test4")
   party.party:getChampion(4):setRace("human")
   party.party:getChampion(4):setSex("male")
end
User avatar
bazuso
Posts: 15
Joined: Sat Jul 29, 2017 12:40 pm

Re: New modder, need help (Default party, custom class)

Post by bazuso »

Isaac wrote:The problem is that the floor_trigger cannot call your statements unless they are in a function block.

Outside of a function, it runs earlier, and doubtless gets overwritten later. When the floor_trigger runs, it never calls them.

Code: Select all

function setCustomPC()
   party.party:getChampion(1):setName("test1")
   party.party:getChampion(1):setRace("minotaur")
   party.party:getChampion(1):setSex("male")
   party.party:getChampion(2):setName("test2")
   party.party:getChampion(2):setRace("minotaur")
   party.party:getChampion(2):setSex("male")
   party.party:getChampion(3):setName("test3")
   party.party:getChampion(3):setRace("human")
   party.party:getChampion(3):setSex("female")
   party.party:getChampion(4):setName("test4")
   party.party:getChampion(4):setRace("human")
   party.party:getChampion(4):setSex("male")
end
I tried using this script but now neither the races or names are altered, therefore it's back to the default party. I made a new dungeon to test it and the issue persists.
User avatar
Isaac
Posts: 3172
Joined: Fri Mar 02, 2012 10:02 pm

Re: New modder, need help (Default party, custom class)

Post by Isaac »

Just to be sure... Did you choose the setCustomPC function as the target in the floor_trigger connection menu? Connectors only call one function. If one is set to call setPortraits(), you need a second connector to call setCustomPC().

Optionally, other functions can be called from within the called function, using only one connector; but that's not how your script is presently written.
User avatar
bazuso
Posts: 15
Joined: Sat Jul 29, 2017 12:40 pm

Re: New modder, need help (Default party, custom class)

Post by bazuso »

Isaac wrote:Just to be sure... Did you choose the setCustomPC function as the target in the floor_trigger connection menu? Connectors only call one function. If one is set to call setPortraits(), you need a second connector to call setCustomPC().

Optionally, other functions can be called from within the called function, using only one connector; but that's not how your script is presently written.
Image

Is this what it should look like? This is the connector menu and how I have had it in which it's still causing the problem.
User avatar
Isaac
Posts: 3172
Joined: Fri Mar 02, 2012 10:02 pm

Re: New modder, need help (Default party, custom class)

Post by Isaac »

That could work. It does not have to be separate scripts, but it shouldn't cause any problem.

Does it cause this problem in a new project? (as before, with setPortraits)
Post Reply