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
Aisuu
Posts: 61
Joined: Fri Oct 31, 2014 2:07 pm

Re: Ask a simple question, get a simple answer

Post by Aisuu »

I didnt find solution for this.

This work:
my_sack.containeritem:addItem(my_item.item)

But this do not:
my_sack.containeritem:removeItem(my_item.item)

Iam trying to make sack for specific items. So if you try to put inside wrong items, it wont let you and they spawn in front of party.
I figured everything else I just cant destroy or remove wrong item from sack :(
This is my code so far in sack item defineObejct:
SpoilerShow

Code: Select all

onInsertItem = function(self, item)
  local itmName = item.go.name
  local itm = item.go.id
  local bag = "my_sack"
  if itmName ~= "good_item" then
     hudPrint("There goes only good items.") --work
     spawn(itmName,party.level,party.x,party.y,party.facing,0)  --work
     bag.containeritem:removeItem(itm.item) -- doesnt work
  end
end
User avatar
Thorham
Posts: 80
Joined: Sat May 04, 2013 5:12 pm

Re: Ask a simple question, get a simple answer

Post by Thorham »

The problem is two fold, and it's all in this line:

Code: Select all

bag.containeritem:removeItem(itm.item)
1. bag is a string, so it basically says "my_sack".containeritem instead of self.go.containeritem.
2. Same for itm.item. itm is a string, while it should be a reference to the item object.

The line should be:

Code: Select all

self.go.containeritem:removeItem(item.go.item)
Here's a new version of the script:

Code: Select all

onInsertItem = function(self, item)
    if item.go.name ~= "good_item" then
        hudPrint("There goes only good items.")
        spawn(item.go.name, party.level, party.x, party.y, party.facing, party.elevation)
        self.go.containeritem:removeItem(item.go.item)
    end
end
User avatar
Aisuu
Posts: 61
Joined: Fri Oct 31, 2014 2:07 pm

Re: Ask a simple question, get a simple answer

Post by Aisuu »

Thank you, work as intended :mrgreen:
User avatar
Soaponarope
Posts: 180
Joined: Thu Oct 04, 2012 3:21 am

Re: Ask a simple question, get a simple answer

Post by Soaponarope »

I'm missing something here; how can I check a floor trigger for specific items like I would a surface. A .floortrigger can't have contents but blocks the actual floor.
GoldenShadowGS
Posts: 168
Joined: Thu Oct 30, 2014 1:56 am

Re: Ask a simple question, get a simple answer

Post by GoldenShadowGS »

You just need to check the entire tile.

Code: Select all

for i in floor_trigger_1.map:entitiesAt(floor_trigger_1.x,floor_trigger_1.y) do
	if i.elevation == floor_trigger_1.elevation and i.go.id == "YOURITEMHERE" then
		--DO SOMETHING HERE
	end
end
User avatar
Soaponarope
Posts: 180
Joined: Thu Oct 04, 2012 3:21 am

Re: Ask a simple question, get a simple answer

Post by Soaponarope »

Really seems like that should work but it doesn't. It says it can't index the game object field.

i.go.name doesn't work either for just an item type
GoldenShadowGS
Posts: 168
Joined: Thu Oct 30, 2014 1:56 am

Re: Ask a simple question, get a simple answer

Post by GoldenShadowGS »

Soaponarope wrote:Really seems like that should work but it doesn't. It says it can't index the game object field.

i.go.name doesn't work either for just an item type
sorry, take out the .go part.

i.id
User avatar
Soaponarope
Posts: 180
Joined: Thu Oct 04, 2012 3:21 am

Re: Ask a simple question, get a simple answer

Post by Soaponarope »

What the... when I got the .go error first thing I did was remove that, but I must of had something else messed up too.

It's working now :) Thanks
User avatar
TheLastOrder
Posts: 104
Joined: Wed Oct 17, 2012 1:56 am

Re: Ask a simple question, get a simple answer

Post by TheLastOrder »

How can I teleport to its original starting point a pushable block through a button?

I want to avoid that a player reaches a dead end where the puzzle can´t be solved... because all pushable blockers could be blocking each others.

Thanks in advance guys!
User avatar
Soaponarope
Posts: 180
Joined: Thu Oct 04, 2012 3:21 am

Re: Ask a simple question, get a simple answer

Post by Soaponarope »

I don't think you can teleport them, but you can destroy them and spawn new ones in the original positions.
Post Reply