Page 365 of 374

Re: Ask a simple question, get a simple answer

Posted: Wed Nov 25, 2020 4:57 am
by 7Soul
ratman wrote:
Tue Nov 24, 2020 11:59 pm
How would I make a script so it gets all the party's items in their inventory, removes them, then spawns them in a chest?
Updated with the tips in the post below

Code: Select all

function removeItems()
	local items = {}
	for c = 1, 4 do
		local champion = party.party:getChampion(c)
		if champion:getEnabled() then
			for slot = ItemSlot.BackpackFirst, ItemSlot.BackpackLast do
				local item = champion:getItem(slot)
				if item then
					table.insert(items, item)
					champion:removeItem(item)
				end
			end
		end
	end
	for _,item in pairs(items) do
		chest_37.surface:addItem(item)
	end
end
If you want to also include the equipped items, replace ItemSlot.BackpackFirst with ItemSlot.Weapon
And replace chest_1 with the id of your chest

Re: Ask a simple question, get a simple answer

Posted: Wed Nov 25, 2020 5:25 pm
by Zo Kath Ra
7Soul wrote:
Wed Nov 25, 2020 4:57 am
ratman wrote:
Tue Nov 24, 2020 11:59 pm
How would I make a script so it gets all the party's items in their inventory, removes them, then spawns them in a chest?

Code: Select all

function removeItems()
	local items = {}
	for c = 1, 4 do
		local champion = party.party:getChampion(c)
		for slot = ItemSlot.BackpackFirst, ItemSlot.BackpackLast do
			local item = champion:getItem(slot)
			if item then
				table.insert(items, item.go.name)
				champion:removeItem(item)
			end
		end
	end
	for _,id in pairs(items) do
		local newItem = spawn(id).item
		chest_1.surface:addItem(newItem)
	end
end
If you want to also include the equipped items, replace ItemSlot.BackpackFirst with ItemSlot.Weapon
And replace chest_1 with the id of your chest
I'd like to suggest two enhancements:
1) Check the champion with Champion:getEnabled()
2) Instead of spawning new items, add the existing items to the surface.
You can do this before or after removing them from their inventory slot.

Re: Ask a simple question, get a simple answer

Posted: Thu Nov 26, 2020 7:32 am
by IttaBitta
[string "Arch.lua"]:0: undefined object: castle_ceiling_shaft_0000

I've gotten this error multiple times for seemingly random reasons. What gives?

Re: Ask a simple question, get a simple answer

Posted: Thu Nov 26, 2020 7:44 am
by 7Soul
IttaBitta wrote:
Thu Nov 26, 2020 7:32 am
[string "Arch.lua"]:0: undefined object: castle_ceiling_shaft_0000

I've gotten this error multiple times for seemingly random reasons. What gives?
I got that before too, but I don't remember why. The solution I found was to copy "castle_ceiling_shaft" and rename it

Code: Select all

defineObject{
	name = "castle_ceiling_shaft_0000",
	baseObject = "base_ceiling_shaft",
	components = {
		{
			class = "Model",
			model = "assets/models/env/castle_ceiling_shaft_01.fbx",
			staticShadow = true,
		}
	},
	minimalSaveState = true,
}
Just put this anywhere in your init file or a file with other object definitions

Re: Ask a simple question, get a simple answer

Posted: Thu Nov 26, 2020 9:57 am
by Zo Kath Ra
IttaBitta wrote:
Thu Nov 26, 2020 7:32 am
[string "Arch.lua"]:0: undefined object: castle_ceiling_shaft_0000

I've gotten this error multiple times for seemingly random reasons. What gives?
Is that the entire error?

Re: Ask a simple question, get a simple answer

Posted: Thu Nov 26, 2020 10:28 am
by minmay
You've placed a PitComponent above a castle_floor or castle_floor_water tile. These tiles don't have a ceiling shaft that fits with them. You could either make ceiling shaft models for it yourself (see the dungeon tileset ceiling shafts for an example), or switch to using castle_floor_tall tiles, and define a water version of castle_floor_tall if necessary.

Re: Ask a simple question, get a simple answer

Posted: Thu Nov 26, 2020 1:50 pm
by bongobeat
I got an issue while testing my mod:

Is it ok or not recommended to block the party while spawning objects in the level?

The tester didn't have a chest and a wooden box which are spawned in the level. It seems that everything is fine in the editor/and script, but this time he didn't have these objects while playing that level.

These objects are part of a whole external lua script, that spawn every items, chest and possibly alcove with items, monsters, etc.., it is called when the player enter the level, but in the same time I use.

Code: Select all

	GameMode.setGameFlag("DisableMovement", true)
	GameMode.setGameFlag("DisableMouseLook", true)
	GameMode.setGameFlag("DisableKeyboardShortcuts", true)
to block the party, and pop up a dialogue via hudprint, then after a few seconds the party movement is re-enabled.

Edit: it was a mistake, the object weren't spawned for another reason.

Re: Ask a simple question, get a simple answer

Posted: Thu Nov 26, 2020 11:22 pm
by minmay
Those game flags won't affect anything like that.
It sounds like your problem is instead related to saving and loading the game; perhaps you've put minimalSaveState on an object that you shouldn't have, or something like that? Have you tested this outside the editor?

Re: Ask a simple question, get a simple answer

Posted: Thu Nov 26, 2020 11:49 pm
by bongobeat
I have not checked if there is minimal save state on these objects, but I doubt it. It's a chest and a wooden box, I certainly didn't put minimalsavestate = true on these one. <<- will check it. In a moment of distraction, maybe I have copied something in the wrong area.



Also these objects have been tested, many times since i published many version, and I or the testers didn't notice something like that.


Edit:

I just try a new game, and I didn't notice anything wrong. Don't know what caused that.

Re: Ask a simple question, get a simple answer

Posted: Fri Nov 27, 2020 8:37 am
by Zo Kath Ra
bongobeat wrote:
Thu Nov 26, 2020 11:49 pm
Also these objects have been tested, many times since i published many version, and I or the testers didn't notice something like that.
How many objects does your mod have in total?
Maybe there are so many that the game decides to just drop some of them...