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
Eleven Warrior
Posts: 752
Joined: Thu Apr 18, 2013 2:32 pm
Location: Australia

Re: Ask a simple question, get a simple answer

Post by Eleven Warrior »

Hi all :)

I have this Script that allows you to give a NPC a item and the item is destroyed and then you can do some other stuff. (Below)

Code: Select all

function Reward1(self, npc, item)
	if item.go.name == "rock" then
		hudPrint("Thank You.")
      return true
   end
   hudPrint("I have no need for this item.")
   return false
end
How can I add more items to this code eg: Say I have to give the NPC a Rock, Gem and sword. All the items need to be destroyed and then cool stuff happens like running a script function(s) etc....

Any help would be most appreciated thxs :)
User avatar
Vandalar
Posts: 31
Joined: Sun Jan 18, 2015 6:05 pm
Location: Montreal, Canada

Re: Ask a simple question, get a simple answer

Post by Vandalar »

Hello Eleven Warrior,

If I understand you correctly, you must :
-Check if it's the correct item
-If all three items were given to the npc, it trigger the reward function. ?

I'm not an expert in LUA scripting, so they are maybe better way to do it, but in your shoes, I would do something like this :
-Call checkItemReceived instead of Reward1.
-checkItemReceived, in the if statement, will call checkReward, it will return true if it was a proper item (and in the process, destroy the item, print something to the player, the global variable rewardCheckVar will be incremented before the second part of the statement is called) and IF rewardCheckVar is equal to 3, then it means the players gave all items to the npc
-If both condition are true, then call Reward1

Please note I didn't test the code below, but it should be close enough for your needs. If you need more help, p.m. me.

Code: Select all

function checkItemReceived(self, npc, item)
   if checkReward(self, npc, item) and rewardCheckVar  == 3 then
      Reward1(npc)
   end

end
function checkReward(self, npc, item)
 if item.go.name == "rock" then
      hudPrint("Thank You.")
      rewardCheckVar = rewardCheckVar + 1 --global var, you could use a counter too
      item.go:destroy()
      return true
end

 if item.go.name == "ancient_claymore" then
      rewardCheckVar = rewardCheckVar + 1 
      hudPrint("Thank You.")
      item.go:destroy()
      return true
   end
 if item.go.name == "power_gem" then
      rewardCheckVar = rewardCheckVar + 1 
      hudPrint("Thank You.")
      item.go:destroy()
      return true
   end

   hudPrint("I have no need for this item.")
   return false
end
function Reward1(self, npc)
--Do whatever you want, give XP or items.

end
Regards,

Vand
User avatar
Eleven Warrior
Posts: 752
Joined: Thu Apr 18, 2013 2:32 pm
Location: Australia

Re: Ask a simple question, get a simple answer

Post by Eleven Warrior »

Thank you so kindly will test it now. Thxs again man awesome :)
User avatar
Eleven Warrior
Posts: 752
Joined: Thu Apr 18, 2013 2:32 pm
Location: Australia

Re: Ask a simple question, get a simple answer

Post by Eleven Warrior »

Hi all :)

I have this object that I want to spawn directly on the party: See below Code(s). When the Object is spawned it is spawned in front of the party and not on the same square they are in.

Ye I know I can use: spawn("spider_web_fake",7,7,28,0,0,"swf7a") but the web is spawned after a certain event directly on the party. Any help as to what imam doing wrong here?

Code: Select all

function SpiderQueen7A()
	spawn("spider_web_fake", party.level, dx, dy, 0, party.elevation )
end
Object Code:

Code: Select all

defineObject{
	name = "spider_web_fake",
	baseObject = "base_floor_decoration",
	components = {
		{
		class = "Model",
		model = "mod_assets/models/spider/tow_spider_web.fbx",
		},
		},
	placement = "floor",
	editorIcon = 104,
	minimalSaveState = true,
}
EDIT: Errrr sorry about this I now know where I went wrong :oops:

It's: spawn("spider_web_fake", party.level, party.x, party.y, party.facing, party.elevation )
User avatar
Slicyr
Posts: 15
Joined: Wed Oct 22, 2014 5:30 pm

Re: Ask a simple question, get a simple answer

Post by Slicyr »

What prop object is it usually that the blob spell is shot from? It was pretty long since I played the game, and I honestly can't remember. Were there even blobs in LoG2?

Daemon Heads just seem too menacing to be shooting harmless projectiles. I can't even remember what was used in LoG1...

If it in fact is true that blob shooters weren't present in LoG2, could someone suggest a good prop to use? Right now I'll just settle for a receptor.
User avatar
THOM
Posts: 1280
Joined: Wed Nov 20, 2013 11:35 pm
Location: Germany - Cologne
Contact:

Re: Ask a simple question, get a simple answer

Post by THOM »

In Log2 you can use Daemon Faces and the spelllauncher from the mine-set. That's how it was done in the main-campaign...
THOM formaly known as tschrage
_______________________________________________
My MOD (LoG1): Castle Ringfort Thread
My MOD (LoG2): Journey To Justice Thread | Download
User avatar
Slicyr
Posts: 15
Joined: Wed Oct 22, 2014 5:30 pm

Re: Ask a simple question, get a simple answer

Post by Slicyr »

Thank you! The mine spell launcher is perfect!
User avatar
Eleven Warrior
Posts: 752
Joined: Thu Apr 18, 2013 2:32 pm
Location: Australia

Re: Ask a simple question, get a simple answer

Post by Eleven Warrior »

Hi all.

I want to create a spell that when the player casts the spell or uses the spell scroll it will open a door or run a script. I had this in log 1 but I cannot find how I did it any help pls thxs :)

PS: If the player uses the Spell Scroll it cannot be used again thxs :)
User avatar
Slicyr
Posts: 15
Joined: Wed Oct 22, 2014 5:30 pm

Re: Ask a simple question, get a simple answer

Post by Slicyr »

Sorry if this already has been answered. Neither Google or the forum's search gives me any good results...

I need a script that springs a trap once a specific item is taken from an alcove. Not when any item is taken, just the specific one.

EDIT: adding some tags so that some poor soul like yesterday-me might find this if they use the forum search function: alcove remove removed specific item take taken surface
Last edited by Slicyr on Fri Jan 29, 2016 4:19 pm, edited 1 time in total.
minmay
Posts: 2789
Joined: Mon Sep 23, 2013 2:24 am

Re: Ask a simple question, get a simple answer

Post by minmay »

Connect the surface's onRemoveItem event to a script entity function. That function will receive the surface as the first parameter, and the item as the second parameter. So for instance, if you wanted to trigger it for removing a rock:

Code: Select all

function itemRemoved(surface,item)
  if item.go.name == "rock" then
    [spring trap]
  end
end
Grimrock 1 dungeon
Grimrock 2 resources
I no longer answer scripting questions in private messages. Please ask in a forum topic or this Discord server.
Post Reply