Scripting about Alcoved Items ( not solved yet )

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
User avatar
AdrTru
Posts: 223
Joined: Sat Jan 19, 2013 10:10 pm
Location: Trutnov, Czech Republic

Scripting about Alcoved Items ( not solved yet )

Post by AdrTru »

Hi, I have some question for adapt my scripts to new system.

1/ Do you known someone how use alcove scipting?
I mean :containedItems() and :getItemCount() functions.

2/ Is there some function for easy item manipulation?
In LOG1 is need make copy all parameters of item to new one. Is there some function like copyItem or assign?
Or is possible move item between positions directly? e.g. From floor to mouse.

3/ Is there some variable for identifiing status were player look into chest?
For custom gui during player loot some items.

Thank you for help.
Last edited by AdrTru on Mon Oct 20, 2014 10:22 pm, edited 1 time in total.
My LOG2 projects: virtual money, Forge recipes, liquid potions and
MultiAlcoveManager, Toolbox, Graphic text,
User avatar
SnowyOwl47
Posts: 148
Joined: Fri Sep 12, 2014 10:41 pm

Re: Scripting about Alcoved Items

Post by SnowyOwl47 »

AdrTru wrote:Hi, I have some question for adapt my scripts to new system.

1/ Do you known someone how use alcove scipting?
I mean :containedItems() and :getItemCount() functions.

2/ Is there some function for easy item manipulation?
In LOG1 is need make copy all parameters of item to new one. Is there some function like copyItem or assign?
Or is possible move item between positions directly? e.g. From floor to mouse.

3/ Is there some variable for identifiing status were player look into chest?
For custom gui during player loot some items.

Thank you for help.
1) Yes I do me,

2) Yes there is,

3) Not Sure, and custom Gui will be hard to do.
User avatar
AdrTru
Posts: 223
Joined: Sat Jan 19, 2013 10:10 pm
Location: Trutnov, Czech Republic

Re: Scripting about Alcoved Items

Post by AdrTru »

SnowyOwl47 wrote:
1) Yes I do me,

2) Yes there is,

3) Not Sure, and custom Gui will be hard to do.
Can you write me how I use this functionality?
My LOG2 projects: virtual money, Forge recipes, liquid potions and
MultiAlcoveManager, Toolbox, Graphic text,
User avatar
SnowyOwl47
Posts: 148
Joined: Fri Sep 12, 2014 10:41 pm

Re: Scripting about Alcoved Items

Post by SnowyOwl47 »

AdrTru wrote:
SnowyOwl47 wrote:
1) Yes I do me,

2) Yes there is,

3) Not Sure, and custom Gui will be hard to do.
Can you write me how I use this functionality?

Code: Select all

-- This Adds an item to an alcove: alcove_name.surface:addItem(item)
--
-- This will get the items in an alcove: alcove_name.surface:getItems()
--
-- As far as I know you'll have you make some of your own code for counting the number of items.
User avatar
AdrTru
Posts: 223
Joined: Sat Jan 19, 2013 10:10 pm
Location: Trutnov, Czech Republic

Re: Scripting about Alcoved Items

Post by AdrTru »

I try make connector for onRemoveItem from altar_1.
1/ correct working - write altar.name and removed item.name
2/ correct working - spawn ax to this altar
incorect -> when is this function called as onInsertItem - script make loop to stack overflow - becouse function onInsertItem is called every time when is some item created in altar.
3/ :getItems() dont worked ( isnt exist this function in surface )

Code: Select all

function test(alc)
-- 1/
  print(alc.go.name.." - "..getMouseItem().go.name)
-- 2/
  alc.go.surface:addItem(spawn("ax").item)
-- 3/
--  for item in altar_1.surface:getItems() do   -- = alc.go.surface:getItems()
--
--  end
end
My LOG2 projects: virtual money, Forge recipes, liquid potions and
MultiAlcoveManager, Toolbox, Graphic text,
User avatar
SnowyOwl47
Posts: 148
Joined: Fri Sep 12, 2014 10:41 pm

Re: Scripting about Alcoved Items

Post by SnowyOwl47 »

AdrTru wrote:I try make connector for onRemoveItem from altar_1.
1/ correct working - write altar.name and removed item.name
2/ correct working - spawn ax to this altar
incorect -> when is this function called as onInsertItem - script make loop to stack overflow - becouse function onInsertItem is called every time when is some item created in altar.
3/ :getItems() dont worked ( isnt exist this function in surface )
If I'm getting this right...

Here is what you need to do...

Code: Select all

function test(entity)
      print(entity.surface:addItem("axe")
      entity.surface:addItem("axe")
end
-- Now you can use this as a method simply call the script_entity something like game, and do the following:
--
-- game.script:test("entity/alcove")
I'm not sure what your trying to do here but thats it.
User avatar
AdrTru
Posts: 223
Joined: Sat Jan 19, 2013 10:10 pm
Location: Trutnov, Czech Republic

Re: Scripting about Alcoved Items ( not solved yet )

Post by AdrTru »

When your connector calls function in script, this function have sefl parameter
e.g. onInsertItem from alcove to test script: in script is test(self). Where self is Alcove entity.
My LOG2 projects: virtual money, Forge recipes, liquid potions and
MultiAlcoveManager, Toolbox, Graphic text,
Post Reply