[MOD 0.15.29+] Creative Mode 0.3.12 - Infinite resources

Topics and discussion about specific mods
User avatar
aubergine18
Smart Inserter
Smart Inserter
Posts: 1264
Joined: Fri Jul 22, 2016 8:51 pm
Contact:

Re: [MOD 0.14.4+] Creative Mode 0.1.5 - WIP Beta Test for 0.2.0

Post by aubergine18 »

I change both :)

The built entity (offshore-pump) gets replaced with pipe-to-ground, and the cursor stack gets replaced with a pipe-to-ground so that the next item placed by player will be that instead of an offshore-pump. I also latch that cursor stack to prevent player from dropping/inventorying the otherwise unobtainable item viewtopic.php?p=213517#p213517

Also, I can't remember whether I had the 'keep last item' cheat enabled or not... That could have conflicted with my cursor antics. Is there way for a mod to toggle CM's 'keep last item' for a specific player? If so, I could wire that in to my cursor stack library to prevent error in future.
Better forum search for modders: Enclose your search term in quotes, eg. "font_color" or "custom-input" - it prevents the forum search from splitting on hypens and underscores, resulting in much more accurate results.

User avatar
Mooncat
Smart Inserter
Smart Inserter
Posts: 1190
Joined: Wed May 18, 2016 4:55 pm
Contact:

Re: [MOD 0.14.4+] Creative Mode 0.1.5 - WIP Beta Test for 0.2.0

Post by Mooncat »

aubergine18 wrote:I change both :)

The built entity (offshore-pump) gets replaced with pipe-to-ground, and the cursor stack gets replaced with a pipe-to-ground so that the next item placed by player will be that instead of an offshore-pump. I also latch that cursor stack to prevent player from dropping/inventorying the otherwise unobtainable item viewtopic.php?p=213517#p213517

Also, I can't remember whether I had the 'keep last item' cheat enabled or not... That could have conflicted with my cursor antics. Is there way for a mod to toggle CM's 'keep last item' for a specific player? If so, I could wire that in to my cursor stack library to prevent error in future.
oh, wow. So you use LuaItemStack.set_stack to change cursor stack? Interesting. I thought it is already a hack that I changed its stack count. :lol:

No remote function for that yet, and I don't think I will make one. Instead, how about I make it to not work on "hidden" items? (with my Creative items being whitelisted of course. :) )
Edit: a remote function for registering items to be ignored by keep last item should be better.

User avatar
aubergine18
Smart Inserter
Smart Inserter
Posts: 1264
Joined: Fri Jul 22, 2016 8:51 pm
Contact:

Re: [MOD 0.14.4+] Creative Mode 0.1.5 - WIP Beta Test for 0.2.0

Post by aubergine18 »

Mooncat wrote:No remote function for that yet, and I don't think I will make one. Instead, how about I make it to not work on "hidden" items? (with my Creative items being whitelisted of course. )
Edit: a remote function for registering items to be ignored by keep last item should be better.
;)

I would have explained what happens when player returns a latched cursor item stack to their personal inventory or quickbar, which is deemed "cancellation of build", at which point my mod changes the stack back to the original (non-hidden) item...
Better forum search for modders: Enclose your search term in quotes, eg. "font_color" or "custom-input" - it prevents the forum search from splitting on hypens and underscores, resulting in much more accurate results.

User avatar
Mooncat
Smart Inserter
Smart Inserter
Posts: 1190
Joined: Wed May 18, 2016 4:55 pm
Contact:

Re: [MOD 0.14.4+] Creative Mode 0.1.5 - WIP Beta Test for 0.2.0

Post by Mooncat »

Uploaded the second test version to the first page, replacing the previous one.
Do NOT load any save that have the previous test version, or error will occur.

I may have forgotten some, but here are the updated things:
Added Creative Cargo Wagon, Duplicating Cargo Wagon, Void Cargo Wagon (that's why I created the Wagon Color mod :) )
Added Void Storage Chest
Added Surface cheat - remove all enemies
Added Surface cheat - don't generate enemies
Added remote function for registering your own remote function to the modding UI so it can be called with simple button click: remote.call("creative-mode", "register_remote_function_to_modding_ui", "<interface-name>", "<function_name>")
Added remote function for deregistering your remote function from the modding UI: remote.call("creative-mode", "deregister_remote_function_from_modding_ui", "<interface-name>", "<function_name>")
Added remote function for registering your items so they will be ignored by the keep-last-item cheat: remote.call("creative-mode", "blacklist_item_from_keep_last_item", "<item-name>")

Slightly reordered the recipes.

Fixed the bug that keep-last-item didn't work on non-stackable items, like the missile silo.
Fixed the bug that switching from/to god mode will lose blueprint contents and reset item durabilities.
Fixed the bug that tiles could not be correctly marked for deconstruction by the deconstruction planner when instant deconstruction was enabled.
Fixed some typo.
Removed some unnecessary locale strings.

(File size is greatly increased... possibility due to the cargo wagon images. :? )


Still not finished: the Healer and Modifier (former Property Changer) magic wand.
Working on them. I think I can release the official update within next week. :lol:

User avatar
aubergine18
Smart Inserter
Smart Inserter
Posts: 1264
Joined: Fri Jul 22, 2016 8:51 pm
Contact:

Re: [MOD 0.14.4+] Creative Mode 0.1.5 - WIP Beta Test for 0.2.0

Post by aubergine18 »

Mooncat wrote:Added remote function for registering your own remote function to the modding UI so it can be called with simple button click:
I assume there's some way to localise the button text?
Mooncat wrote:Added remote function for registering your items so they will be ignored by the keep-last-item cheat:
Could this:

Code: Select all

remote.call("creative-mode", "blacklist_item_from_keep_last_item", "<item-name>")
Be changed to:

Code: Select all

remote.call("creative-mode", "exclude_from_keep_last_item", {
  "item-name1" = true,
  "item-name2" = false
})
That way I can do multiple items in single call, and also toggle whether items are excluded or not.
Mooncat wrote:(File size is greatly increased... possibility due to the cargo wagon images. :? )
Is it not possible to use base sprites for cargo wagon and simply tint them? That way file size can be greatly decreased.
Better forum search for modders: Enclose your search term in quotes, eg. "font_color" or "custom-input" - it prevents the forum search from splitting on hypens and underscores, resulting in much more accurate results.

User avatar
Mooncat
Smart Inserter
Smart Inserter
Posts: 1190
Joined: Wed May 18, 2016 4:55 pm
Contact:

Re: [MOD 0.14.4+] Creative Mode 0.1.5 - WIP Beta Test for 0.2.0

Post by Mooncat »

aubergine18 wrote:
Mooncat wrote:Added remote function for registering your own remote function to the modding UI so it can be called with simple button click:
I assume there's some way to localise the button text?
No. It is the function name.
Its goal is to let you quickly test something, not for fancy stuff, so I don't want to make it to be complicated. :mrgreen:
aubergine18 wrote:
Mooncat wrote:Added remote function for registering your items so they will be ignored by the keep-last-item cheat:
Could this:

Code: Select all

remote.call("creative-mode", "blacklist_item_from_keep_last_item", "<item-name>")
Be changed to:

Code: Select all

remote.call("creative-mode", "exclude_from_keep_last_item", {
  "item-name1" = true,
  "item-name2" = false
})
That way I can do multiple items in single call, and also toggle whether items are excluded or not.
Unless there are good reasons, I won't make it to accept multiple items at once because it makes things inconsistent.
Like, if I change this, how about register_remote_function_to_modding_ui and deregister_remote_function_from_modding_ui?

But I can change its name. "exclude_from_keep_last_item" sounds better. ;)
I can also make "add_back_to_keep_last_item", just wonder why you need that.
By the way, the items are not saved in game state, so you will need to register the items on game load.

aubergine18 wrote:
Mooncat wrote:(File size is greatly increased... possibility due to the cargo wagon images. :? )
Is it not possible to use base sprites for cargo wagon and simply tint them? That way file size can be greatly decreased.
Looks like this is the only solution. The cargo wagon images are really big. :(

User avatar
aubergine18
Smart Inserter
Smart Inserter
Posts: 1264
Joined: Fri Jul 22, 2016 8:51 pm
Contact:

Re: [MOD 0.14.4+] Creative Mode 0.1.5 - WIP Beta Test for 0.2.0

Post by aubergine18 »

Mooncat wrote:No. It is the function name.
set button caption to { interface_name .. "." function_name } and localisation is sorted... Even if the mod doesn't provide a locale string for that key, it's still useful as now it will be clear what the button does because its caption will tell me the interface and method that it will trigger.
Mooncat wrote:But I can change its name. "exclude_from_keep_last_item" sounds better.
I can also make "add_back_to_keep_last_item", just wonder why you need that.
Yes, that would be good and handle all my use cases.
Better forum search for modders: Enclose your search term in quotes, eg. "font_color" or "custom-input" - it prevents the forum search from splitting on hypens and underscores, resulting in much more accurate results.

User avatar
Mooncat
Smart Inserter
Smart Inserter
Posts: 1190
Joined: Wed May 18, 2016 4:55 pm
Contact:

Re: [MOD 0.14.4+] Creative Mode 0.1.5 - WIP Beta Test for 0.2.0

Post by Mooncat »

aubergine18 wrote:set button caption to { interface_name .. "." function_name } and localisation is sorted... Even if the mod doesn't provide a locale string for that key, it's still useful as now it will be clear what the button does because its caption will tell me the interface and method that it will trigger.
I really don't want to change the caption. It will look weird if the other fields are function names and then suddenly there is readable text.
I can add tooltip however. It will be an additional optional parameter.

Edit: ok, I change my mind. It is up to you to change its caption and tooltip. :)

rubberduck
Burner Inserter
Burner Inserter
Posts: 15
Joined: Mon Apr 18, 2016 12:27 pm
Contact:

Re: [MOD 0.14.4+] Creative Mode 0.1.5 - WIP Beta Test for 0.2.0

Post by rubberduck »

anytime i try to move any of the new wagons with a train a shuttle train or farl i get

Error while running event on_tick (ID 0)
__creative-mode__/scripts/creative-chest-util.lua:150: attempt to get length of local 'inventory' (a nil value)
visit https://factorioprints.com/ for all your blueprint needs

User avatar
aubergine18
Smart Inserter
Smart Inserter
Posts: 1264
Joined: Fri Jul 22, 2016 8:51 pm
Contact:

Re: [MOD 0.14.4+] Creative Mode 0.1.5 - WIP Beta Test for 0.2.0

Post by aubergine18 »

Just got this error again:

Code: Select all

 538.688 Error MainLoop.cpp:788: Exception at tick 29482: Error while running event on_put_item (ID 9)
LuaItemStack API call when LuaItemStack was invalid.
stack traceback:
	__creative-mode__/scripts/cheats.lua:1481: in function 'on_put_item'
	__creative-mode__/scripts/events.lua:141: in function '?'
	__creative-mode__/scripts/events.lua:540: in function <__creative-mode__/scripts/events.lua:503>
CM was in "Yes, with cheats" mode. I'm running most recent beta from OP. I didn't have anything in cursor stack. I crafted a car, then tried to place it on map.

It only ever seems to happen with the car for some reason.
Better forum search for modders: Enclose your search term in quotes, eg. "font_color" or "custom-input" - it prevents the forum search from splitting on hypens and underscores, resulting in much more accurate results.

User avatar
Mooncat
Smart Inserter
Smart Inserter
Posts: 1190
Joined: Wed May 18, 2016 4:55 pm
Contact:

Re: [MOD 0.14.4+] Creative Mode 0.1.5 - WIP Beta Test for 0.2.0

Post by Mooncat »

rubberduck wrote:anytime i try to move any of the new wagons with a train a shuttle train or farl i get

Error while running event on_tick (ID 0)
__creative-mode__/scripts/creative-chest-util.lua:150: attempt to get length of local 'inventory' (a nil value)
Thanks for the report. I forgot to make wheels for the wagons. :lol:
(Haven't checked to move them)
I will fix that soon. ;)
aubergine18 wrote:Just got this error again:

Code: Select all

 538.688 Error MainLoop.cpp:788: Exception at tick 29482: Error while running event on_put_item (ID 9)
LuaItemStack API call when LuaItemStack was invalid.
stack traceback:
	__creative-mode__/scripts/cheats.lua:1481: in function 'on_put_item'
	__creative-mode__/scripts/events.lua:141: in function '?'
	__creative-mode__/scripts/events.lua:540: in function <__creative-mode__/scripts/events.lua:503>
CM was in "Yes, with cheats" mode. I'm running most recent beta from OP. I didn't have anything in cursor stack. I crafted a car, then tried to place it on map.

It only ever seems to happen with the car for some reason.
1481..? Do you mean 1841? :shock:
I have already checked cursor_stack.valid_for_read at line 1840. Really have no idea why it still complains about that.
I guess it is not about the car, because I have placed it too quite often. Maybe it is a bug in the game.... :geek:
Anyway, I will check on it. Thanks. :)

User avatar
aubergine18
Smart Inserter
Smart Inserter
Posts: 1264
Joined: Fri Jul 22, 2016 8:51 pm
Contact:

Re: [MOD 0.14.4+] Creative Mode 0.1.5 - WIP Beta Test for 0.2.0

Post by aubergine18 »

It's copy and paste of error from logs, so no typo in line number.

It doesn't crash every time I place car, just sometimes. I'll take a look at code tomorrow if I get chance now and see if a second pair of eyes spots the problem.

EDIT: Actually, you're not checking valid_for_read in this specific instance. If you follow the code through, there's no check prior to calling cheats.on_put_item() and there's no check within that method either:

Code: Select all

-- Applies cheats to the player when he/she uses item to build something.
function cheats.on_put_item(player)
	-- Keep last item.
	if global.creative_mode.personal_cheats.keep_last_item[player.index] then <--
^^ valid_for_read? ^^
		local cursor_stack = player.cursor_stack
		if player.get_item_count(cursor_stack.name) <= 1 then   <--- errors here
			cursor_stack.count = 2
			-- This event is invoked even if the player uses the item to build ghost entity, i.e. no item is going to be spent.
			-- In that case, we will have to get back the inserted item.
			global.creative_mode.personal_cheats.has_restored_cursor_stack[player.index] = game.tick
		end
	end
end
Last edited by aubergine18 on Tue Oct 25, 2016 3:05 am, edited 2 times in total.
Better forum search for modders: Enclose your search term in quotes, eg. "font_color" or "custom-input" - it prevents the forum search from splitting on hypens and underscores, resulting in much more accurate results.

User avatar
Mooncat
Smart Inserter
Smart Inserter
Posts: 1190
Joined: Wed May 18, 2016 4:55 pm
Contact:

Re: [MOD 0.14.4+] Creative Mode 0.1.5 - WIP Beta Test for 0.2.0

Post by Mooncat »

But 1481 is a comment... or the commented lines are not counted in the error log? :shock:
Thanks! :D

User avatar
aubergine18
Smart Inserter
Smart Inserter
Posts: 1264
Joined: Fri Jul 22, 2016 8:51 pm
Contact:

Re: [MOD 0.14.4+] Creative Mode 0.1.5 - WIP Beta Test for 0.2.0

Post by aubergine18 »

1481 might be comment in your current dev version, but in the version I'm running it's this:

Code: Select all

		if player.get_item_count(cursor_stack.name) <= 1 then
See updated comment above :)
Better forum search for modders: Enclose your search term in quotes, eg. "font_color" or "custom-input" - it prevents the forum search from splitting on hypens and underscores, resulting in much more accurate results.

User avatar
Mooncat
Smart Inserter
Smart Inserter
Posts: 1190
Joined: Wed May 18, 2016 4:55 pm
Contact:

Re: [MOD 0.14.4+] Creative Mode 0.1.5 - WIP Beta Test for 0.2.0

Post by Mooncat »

I downloaded from the first page and checked that. And I just checked it again.

Line 1481 is

Code: Select all

--					table.insert(game.item_prototypes[item].flags, "hidden")
cheats.on_put_item starts from line 1836:

Code: Select all

function cheats.on_put_item(player)
	-- Keep last item.
	if global.creative_mode.personal_cheats.keep_last_item[player.index] then
		local cursor_stack = player.cursor_stack
		if cursor_stack.valid_for_read then -- Don't know why sometimes the stack becomes invalid and causes error.
			local cursor_stack_name = cursor_stack.name
			-- Make sure the item is not blacklisted.
			if not keep_last_item_blacklist[cursor_stack_name] then
				if player.get_item_count(cursor_stack_name) <= 1 then
					local cursor_stack_prototype = cursor_stack.prototype
					if cursor_stack_prototype.stackable and cursor_stack_prototype.stack_size > 1 then
						-- The item is stackable. Simply increase the stack size on the cursor.
						cursor_stack.count = 2
						-- This event is invoked even if the player uses the item to build ghost entity, i.e. no item is going to be spent.
						-- In that case, we will have to get back the inserted item.
						global.creative_mode.personal_cheats.has_restored_cursor_stack[player.index] = game.tick
					else
						-- The item is not stackable. Insert the item to the player's inventory.
						if player.insert{name = cursor_stack_name, count = 1} > 0 then
							global.creative_mode.personal_cheats.has_restored_cursor_stack[player.index] = game.tick
						end
					end
				end
			end
		end
	end
end
So line 1841 is

Code: Select all

local cursor_stack_name = cursor_stack.name
:?

Please check info.json. The mod title should be "Creative Mode [WIP Test 2]". :)

User avatar
aubergine18
Smart Inserter
Smart Inserter
Posts: 1264
Joined: Fri Jul 22, 2016 8:51 pm
Contact:

Re: [MOD 0.14.4+] Creative Mode 0.1.5 - WIP Beta Test for 0.2.0

Post by aubergine18 »

hrm, for some reason i was running the older version. can confirm that newer version is fixed
Better forum search for modders: Enclose your search term in quotes, eg. "font_color" or "custom-input" - it prevents the forum search from splitting on hypens and underscores, resulting in much more accurate results.

User avatar
Mooncat
Smart Inserter
Smart Inserter
Posts: 1190
Joined: Wed May 18, 2016 4:55 pm
Contact:

Re: [MOD 0.14.4+] Creative Mode 0.1.5 - WIP Beta Test for 0.2.0

Post by Mooncat »

aubergine18 wrote:hrm, for some reason i was running the older version. can confirm that newer version is fixed
That's great! Thanks. :D

User avatar
aubergine18
Smart Inserter
Smart Inserter
Posts: 1264
Joined: Fri Jul 22, 2016 8:51 pm
Contact:

Re: [MOD 0.14.4+] Creative Mode 0.1.5 - WIP Beta Test for 0.2.0

Post by aubergine18 »

Better forum search for modders: Enclose your search term in quotes, eg. "font_color" or "custom-input" - it prevents the forum search from splitting on hypens and underscores, resulting in much more accurate results.

User avatar
Mooncat
Smart Inserter
Smart Inserter
Posts: 1190
Joined: Wed May 18, 2016 4:55 pm
Contact:

Re: [MOD 0.14.4+] Creative Mode 0.1.5 - WIP Beta Test for 0.2.0

Post by Mooncat »

Thanks! You have reminded me to also provide tick and name to the event. :lol:
And I like your approach of on_robot_built_entity.

User avatar
aubergine18
Smart Inserter
Smart Inserter
Posts: 1264
Joined: Fri Jul 22, 2016 8:51 pm
Contact:

Re: [MOD 0.14.4+] Creative Mode 0.1.5 - WIP Beta Test for 0.2.0

Post by aubergine18 »

How do the magic wands work? I tried creating tiles but the cursor doesn't change or anything, and clicking, shift-clicking, alt-clicking, dragging, etc., has no effect either...
Better forum search for modders: Enclose your search term in quotes, eg. "font_color" or "custom-input" - it prevents the forum search from splitting on hypens and underscores, resulting in much more accurate results.

Post Reply

Return to “Mods”