defineObject conflict

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!
Post Reply
Emera Nova
Posts: 146
Joined: Wed Jun 11, 2014 1:31 am

defineObject conflict

Post by Emera Nova »

Ok so I'm using GTK in my latest project so that I can have the npc's talk to the party, I'm also using a script that is here on the forums that makes it required for the spell scroll to be on the player to be able to cast it.

Code: Select all

defineObject{
	name = "party",
	baseObject = "party",
	components = {
		{
			class = "Party",
			onDrawGui = function(party, g)
				
			end,
			onRest = function(party)
				if ( findEntity("GTK") ) then
					if ( GTK.Core.GUI:isPartyLocked() ) then
						return false;
					end
				end			
			end,
			onWakeUp = function(party)
				if ( findEntity("GTK") ) then
					if ( GTK.Core.GUI:isPartyLocked() ) then
						return false;
					end
				end
			end
		}
	}
}

Code: Select all

defineObject{
   name = "party",
   baseObject = "party",
   components = {
      {
         class = "Party", 
         onCastSpell =
            function(party,champion,spellName) 
                  local itemName = "scroll_"..spellName        
                  for i = 1, 32, 1 do
                         if champion:getItem(i) ~= nil and champion:getItem(i).go.name == itemName then
                             return true
                        end
                  end
                  hudPrint(champion:getName().." needs to have the spell scroll on him to be able to cast it")
                  return false 
           end
      }
      
}
}
These are the two different defineObject's that must be placed into get both of them to work.. How can I combine them so that they don't break each other. As it is if I put in them the scroll one seems t0 overrides the GTK. The GTK I had put in first and was running just fine, I drop in the scroll script and then everything that had to do with my GTK stuff broke.
User avatar
AndakRainor
Posts: 674
Joined: Thu Nov 20, 2014 5:18 pm

Re: defineObject conflict

Post by AndakRainor »

You can merge them like that:

Code: Select all

defineObject{
   name = "party",
   baseObject = "party",
   components = {
      {
         class = "Party",
         onDrawGui = function(party, g)
            
         end,
         onRest = function(party)
            if ( findEntity("GTK") ) then
               if ( GTK.Core.GUI:isPartyLocked() ) then
                  return false;
               end
            end         
         end,
         onWakeUp = function(party)
            if ( findEntity("GTK") ) then
               if ( GTK.Core.GUI:isPartyLocked() ) then
                  return false;
               end
            end
         end,
         onCastSpell = function(party,champion,spellName) 
             local itemName = "scroll_"..spellName        
             for i = 1, 32, 1 do
                    if champion:getItem(i) ~= nil and champion:getItem(i).go.name == itemName then
                        return true
                   end
             end
             hudPrint(champion:getName().." needs to have the spell scroll on him to be able to cast it")
             return false 
         end
      }
   }
Emera Nova
Posts: 146
Joined: Wed Jun 11, 2014 1:31 am

Re: defineObject conflict

Post by Emera Nova »

Thanks :D
Post Reply