Page 31 of 396

Re: Ask a simple question, get a simple answer

Posted: Sun Dec 14, 2014 5:51 pm
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

Re: Ask a simple question, get a simple answer

Posted: Sun Dec 14, 2014 8:00 pm
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

Re: Ask a simple question, get a simple answer

Posted: Sun Dec 14, 2014 8:15 pm
by Aisuu
Thank you, work as intended :mrgreen:

Re: Ask a simple question, get a simple answer

Posted: Sun Dec 14, 2014 11:27 pm
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.

Re: Ask a simple question, get a simple answer

Posted: Mon Dec 15, 2014 2:02 am
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

Re: Ask a simple question, get a simple answer

Posted: Mon Dec 15, 2014 3:19 am
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

Re: Ask a simple question, get a simple answer

Posted: Mon Dec 15, 2014 4:21 am
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

Re: Ask a simple question, get a simple answer

Posted: Mon Dec 15, 2014 5:43 am
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

Re: Ask a simple question, get a simple answer

Posted: Mon Dec 15, 2014 12:12 pm
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!

Re: Ask a simple question, get a simple answer

Posted: Mon Dec 15, 2014 12:45 pm
by Soaponarope
I don't think you can teleport them, but you can destroy them and spawn new ones in the original positions.