[MOD 0.14] Text Plates

Topics and discussion about specific mods
Anson
Fast Inserter
Fast Inserter
Posts: 249
Joined: Sun May 22, 2016 4:41 pm
Contact:

Re: [MOD 0.14] Text Plates

Post by Anson »

a really nice mod, and nice graphics, and i also like your other mods eg the biomes or the new programmable vehicles (not yet tested myself, but it looks great) ... BUT:

i got a crash when placing "text plates" with a blueprint while i had the "bluebuild" mod installed.
i don't know which of these two mods causes the problem, or maybe both of them together.
that's why i report this to both mods ...

when i tried to place a blueprint with some textplates (and no other items), factorio crashed on me with this Notice:
- Error while running event on_tick (ID 0)
- LuaEntity API call when LuaEntity was invalid.
- stack traceback:
- __Bluebuild__/control.lua:113: in function 'bluebuild'
- __Bluebuild__/control.lua:51: in function 'bluecheck'
- __Bluebuild__/control.lua:36: in function 'playerloop'
- __Bluebuild__/control.lua:198: in function <__Bluebuild__/control.lua:197>


another problem with this mod:
when i have started to enter some text and want to abort placing tiles, i often don't succeed. using "q" is only possible before i have started entering text, and a simple esc doesn't close the GUI and instead gives me the system menu (for load, save, etc).
best method is to place a tile and remove it, so that i am no longer in "text entering mode". is there a better way to abort the gui?
User avatar
Earendel
Factorio Staff
Factorio Staff
Posts: 716
Joined: Sun Nov 23, 2014 11:57 am
Contact:

Re: [MOD 0.14] Text Plates

Post by Earendel »

Anson wrote:a really nice mod, and nice graphics, and i also like your other mods eg the biomes or the new programmable vehicles (not yet tested myself, but it looks great) ... BUT:

i got a crash when placing "text plates" with a blueprint while i had the "bluebuild" mod installed.
i don't know which of these two mods causes the problem, or maybe both of them together.
that's why i report this to both mods ...

when i tried to place a blueprint with some textplates (and no other items), factorio crashed on me with this Notice:
- Error while running event on_tick (ID 0)
- LuaEntity API call when LuaEntity was invalid.
- stack traceback:
- __Bluebuild__/control.lua:113: in function 'bluebuild'
- __Bluebuild__/control.lua:51: in function 'bluecheck'
- __Bluebuild__/control.lua:36: in function 'playerloop'
- __Bluebuild__/control.lua:198: in function <__Bluebuild__/control.lua:197>


another problem with this mod:
when i have started to enter some text and want to abort placing tiles, i often don't succeed. using "q" is only possible before i have started entering text, and a simple esc doesn't close the GUI and instead gives me the system menu (for load, save, etc).
best method is to place a tile and remove it, so that i am no longer in "text entering mode". is there a better way to abort the gui?
Text plates uses a single item to build any end shape to avoid clogging your inventory, but to do this it swaps an entity with another entity. It looks like bluebuild keeps a reference to the entity but the reference becomes invalid. It should just be a case of adding a entity.valid check before the line that's causing the crash.

The easiest way to escape text entry is just to click somewhere else on the interface, like the background, or anywhere else on the screen for that matter.
Anson
Fast Inserter
Fast Inserter
Posts: 249
Joined: Sun May 22, 2016 4:41 pm
Contact:

Re: [MOD 0.14] Text Plates

Post by Anson »

Earendel wrote:It looks like bluebuild keeps a reference to the entity but the reference becomes invalid. It should just be a case of adding a entity.valid check before the line that's causing the crash.
that probably hit the bug on its head :-)
for another bug report on bluebuild (on the mod portal), its author Mylon wrote:
"Some of my other mods (like concreep) always check if entities are still valid before doing anything"

seems as if those missing checks are a cause for many problems in many mods, and especially in blueprint mods ...
Earendel wrote:The easiest way to escape text entry is just to click somewhere else on the interface, like the background, or anywhere else on the screen for that matter.
by doing that, text entry is canceled, and i can use WASD to walk, etc, but i still can't use Q to cancel putting down a plate and close the gui. that function of Q is only reenabled after i put a plate down.

maybe the problem is also related to several functions that all have a keybind to Q, like vanilla "cancel cursor", vanilla "change weapon", and some mods which use Q too, eg to pick an item from inventory when the cursor points to an item on the map, to make the item when the item is not available in the inventory, etc.

anyway, no big problem to quickly leftclick and rightclick someplace to put and remove a plate.
from now on, this mod and nixies will be included on all my maps :-)
Anson
Fast Inserter
Fast Inserter
Posts: 249
Joined: Sun May 22, 2016 4:41 pm
Contact:

Re: [MOD 0.14] Text Plates

Post by Anson »

the crashing problem with bluebuild seems to be solved now, but there is one more problem when using both mods :

when textplates are placed as ghosts (either as blueprints or by shift-clicking), they appear on the ground with a nice little icon that indicates what the ghost really should be. and when robots build that entity, everything works fine and i get the proper plate.

BUT when the ghost is not built by robots, but by a simple revive in bluebuild, and thus the "normal" on (player) built entity is called, you seem to do all kinds of checks for cursor, replacing the item, etc. while the item is not really built by the player either and thus the last used plate is placed instead for all ghosts.

in this special case, using the same method as on robot built entity would probably give the correct plate, but since i am no lua or factorio programmer, i have no idea how this result can be achieved, either by adding some function to textplates, or by changing the method to create entities from ghosts in bluebuild which currently does a simple revive.

although the problem is not gamebreaking, and also can be avoided relatively easily by temporarily disabling that method to revive ghosts (with a simple hotkey) thus letting only bots do the work, i would be interested in learning how to program properly, and of course i also would like to use both mods without restrictions :-)
User avatar
Earendel
Factorio Staff
Factorio Staff
Posts: 716
Joined: Sun Nov 23, 2014 11:57 am
Contact:

Re: [MOD 0.14] Text Plates

Post by Earendel »

Anson wrote:the crashing problem with bluebuild seems to be solved now, but there is one more problem when using both mods :

when textplates are placed as ghosts (either as blueprints or by shift-clicking), they appear on the ground with a nice little icon that indicates what the ghost really should be. and when robots build that entity, everything works fine and i get the proper plate.

BUT when the ghost is not built by robots, but by a simple revive in bluebuild, and thus the "normal" on (player) built entity is called, you seem to do all kinds of checks for cursor, replacing the item, etc. while the item is not really built by the player either and thus the last used plate is placed instead for all ghosts.

in this special case, using the same method as on robot built entity would probably give the correct plate, but since i am no lua or factorio programmer, i have no idea how this result can be achieved, either by adding some function to textplates, or by changing the method to create entities from ghosts in bluebuild which currently does a simple revive.

although the problem is not gamebreaking, and also can be avoided relatively easily by temporarily disabling that method to revive ghosts (with a simple hotkey) thus letting only bots do the work, i would be interested in learning how to program properly, and of course i also would like to use both mods without restrictions :-)
When a robot or player places an entity an event is fired which allows a script to react to the placement. In this case the reaction is to replace a placeholder plate with a real plate. If a different script places an entity then no event is fired.

Either bluebuild would specifically need to support textplates and do the conversion itself (the intended text plate type is stored as a signal in the placeholder), or bluebuild would need to call and event or remote interface when it places or revives an entity so that other mods can be set up to react to that event, in which case those mods need to be updated too.

I can look into the issue in more detail later but I'm in the middle of a big update for AAI Programmable Vehicles right now.
Anson
Fast Inserter
Fast Inserter
Posts: 249
Joined: Sun May 22, 2016 4:41 pm
Contact:

Re: [MOD 0.14] Text Plates

Post by Anson »

Earendel wrote:When a robot or player places an entity an event is fired which allows a script to react to the placement. In this case the reaction is to replace a placeholder plate with a real plate. If a different script places an entity then no event is fired.
Either bluebuild would specifically need to support textplates and do the conversion itself (the intended text plate type is stored as a signal in the placeholder), or bluebuild would need to call and event or remote interface when it places or revives an entity so that other mods can be set up to react to that event, in which case those mods need to be updated too.
if no event is fired automatically, maybe the mod that calls revive can also raise an event to cause the same handling that would be done if the ghost would be revived by bots? or is that thought much too simple?
Earendel wrote:I can look into the issue in more detail later but I'm in the middle of a big update for AAI Programmable Vehicles right now.
hehe, that is the next item on my todo/check/test list ... how to use AAI, maybe even together with logistic trains and several other mods to get some crazy factory with lots of different transporting and mining methods, eg a beltless factory without bots, and doing mining with a different mod on each ore field :-)
AAI might be used for both of these purposes, mining and transporting, maybe even together with roads that are built from special floor tiles (got that idea when i saw the asphalt mod, and the old paved driving assist, etc)
User avatar
Earendel
Factorio Staff
Factorio Staff
Posts: 716
Joined: Sun Nov 23, 2014 11:57 am
Contact:

Re: [MOD 0.14] Text Plates

Post by Earendel »

The mod has been updated to version 0.1.13 which supports a custom event api.

Code: Select all

--[[
CUSTOM EVENTS USED

on_entity_revived
raise_event implementation: raise_event('on_entity_revived', {entity=LuaEntity, player_index=player.player_index}) 
on_event implementation: remote.add_interface("mymod", { on_entity_revived = function(data) return myfunction(data.entity, data.player_index) end})

]]--
local function raise_event(event_name, event_data) 
	local responses = {}
	for interface_name, interface_functions in pairs(remote.interfaces) do
		if interface_functions[event_name] then
			responses[interface_name] = remote.call(interface_name, event_name, event_data)
		end
	end
	return responses
end
Other mods can use the on_event implementation to trigger on_entity_revived on any mods that have implemented the interface on_entity_revived.

I'm attaching an update version of bluebuild's control.lua that is compatible with the implemented interface so bluebuild and textplates work together.

EDIT: Since version 0.1.15 the above is no longer required but will still work if you need it. Triggering on_built_entity normally is sufficient do to some code enhancements to get things working for nanobots.
Attachments
control.lua
(9.2 KiB) Downloaded 205 times
Last edited by Earendel on Sun Mar 05, 2017 10:38 pm, edited 2 times in total.
User avatar
Mooncat
Smart Inserter
Smart Inserter
Posts: 1196
Joined: Wed May 18, 2016 4:55 pm
Contact:

Re: [MOD 0.14] Text Plates

Post by Mooncat »

Hi Earendel and Anson, I am working on the update of Creative Mode, and after fixing the error caused by reviving text plates with magic wand, I just realized I hit the same issue of not getting the correct text plates.

After checking your code, I am now thinking: are we doing it wrong? "We" means modders that revive entities by script, including me of corse.
Normally, ghost entities can only be revived by robots. Shouldn't we raise on_robot_built_entity instead of on_built_entity? :geek:
Although this will lose the "player_index" parameter and also make "robot" to be nil, they are not really useful for entity revival.
And I have changed it and tested with mods. No problem so far. It solved the issue perfectly.
Ideally, we won't need the additional remote function for this issue.
I will keep an eye on it. :)


There's the solved issue. Here comes the unsolved one.
Would you mind raising on_built_entity (on_robot_built_entity) for the replacement entities after replacing the text plates that are built by blueprint, Earendel?
More specifically, inserting the following code at line 209 of your control.lua:

Code: Select all

game.raise_event(defines.events.on_built_entity,
{
	tick = event.tick,
	name = defines.events.on_built_entity,
	created_entity = replacement,
	player_index = player_index
})
In Creative Mode, to increase the mod compatibility of instant blueprint, by giving time to other mods for destroying entities that shouldn't be instant-blueprinted, I have implemented a delay before the effect of instant blueprint is actually applied.
But then it cannot detect your text plates because they are replaced by the blank plates.
If you can implement this, the problem can be solved. :mrgreen:
(I have forked your repo but the last commit is 0.1.11 instead of 0.1.15, so I place the request here.)
User avatar
Earendel
Factorio Staff
Factorio Staff
Posts: 716
Joined: Sun Nov 23, 2014 11:57 am
Contact:

Re: [MOD 0.14] Text Plates

Post by Earendel »

My message above was a bit out of date because I made some changes for nanobots and the earlier changes for bluebuild became unnecessary.

@Mooncat I've made that change for v0.1.16. I've started calling on_built_entity when ever an entity is swapped, except for the one in the robot event where it uses on_robot_built_entity instead. The event data format is:

Code: Select all

game.raise_event(defines.events.on_built_entity,
{
	tick = event.tick,
	name = defines.events.on_built_entity,
	created_entity = replacement,
	player_index = player_index,
	mod = "textplates",
	is_replacement = true,
	replaced_unit_number = entity.unit_number
})
This means that other mods can check whether or not the event was called by a mod and if so which mod, also is this an entity replacement and if so what is the unit_number. It might be a useful practice to adopt so we can avoid replacement loops and/or allow entity references to link to the new entity.
User avatar
Mooncat
Smart Inserter
Smart Inserter
Posts: 1196
Joined: Wed May 18, 2016 4:55 pm
Contact:

Re: [MOD 0.14] Text Plates

Post by Mooncat »

Earendel wrote:My message above was a bit out of date because I made some changes for nanobots and the earlier changes for bluebuild became unnecessary.

@Mooncat I've made that change for v0.1.16. I've started calling on_built_entity when ever an entity is swapped, except for the one in the robot event where it uses on_robot_built_entity instead. The event data format is:

Code: Select all

game.raise_event(defines.events.on_built_entity,
{
	tick = event.tick,
	name = defines.events.on_built_entity,
	created_entity = replacement,
	player_index = player_index,
	mod = "textplates",
	is_replacement = true,
	replaced_unit_number = entity.unit_number
})
This means that other mods can check whether or not the event was called by a mod and if so which mod, also is this an entity replacement and if so what is the unit_number. It might be a useful practice to adopt so we can avoid replacement loops and/or allow entity references to link to the new entity.
Thanks a lot. :D
I like this approach and I will add this in my mod too. (Have already added "revived=true" in my events for entity revival, according to Nexela's request. It shouldn't hurt to add more useful info.)
User avatar
septemberWaves
Fast Inserter
Fast Inserter
Posts: 225
Joined: Tue Jul 26, 2016 7:49 pm
Contact:

Re: [MOD 0.14] Text Plates

Post by septemberWaves »

I have a suggestion for some inter-mod compatibility. I think it would be nice to include support for the various metals from Bob's mods. That would allow a far greater variety of coloration options for the text plates, and also give more uses for those metals.
User avatar
Likos
Burner Inserter
Burner Inserter
Posts: 11
Joined: Tue Mar 21, 2017 4:00 pm
Contact:

Re: [MOD 0.14] Text Plates

Post by Likos »

Can you add ru translation to this mod?
Translation in attachment
Attachments
locale.zip
(1.3 KiB) Downloaded 162 times
Vexos
Burner Inserter
Burner Inserter
Posts: 9
Joined: Tue Dec 13, 2016 12:25 pm
Contact:

Re: [MOD 0.14] Text Plates

Post by Vexos »

I got a crash with this error. Aparenttly it happened during an alien attack.
Attachments
error.png
error.png (63.28 KiB) Viewed 8714 times
rableniver
Manual Inserter
Manual Inserter
Posts: 1
Joined: Wed Apr 19, 2017 2:18 pm
Contact:

Re: [MOD 0.14] Text Plates

Post by rableniver »

It appears this mod causes a crash whenever either a text plate is destroyed or when a blue print is made to replace a destroyed text plate.
This happens on version .16 and .17 (from github) of the mod. It looks like there was a push a few days ago to fix this issue but it does not appear to work.

I tested this in a vanilla version of the game (with only this mod installed) without blueprints researched and I was able to destroy text plates with no issue.

Using a creative mod to get all tech research caused a game crash when a text plate was destroyed, but the crash was attributed to the creative mod for whatever reason.
Image

Haven't yet tested with gaining blueprints the vanilla way since I don't have a way to easily unlock that.
User avatar
Mooncat
Smart Inserter
Smart Inserter
Posts: 1196
Joined: Wed May 18, 2016 4:55 pm
Contact:

Re: [MOD 0.14] Text Plates

Post by Mooncat »

Because I see CM is involved, I investigated, and saw the cause.
At line 361, on_built_entity is raised with player_index = nil. According to API doc, player_index is not optional, so nil is not expected.
Maybe raise on_robot_built_entity instead, with robot = {name = "whatever", type = "whatever", valid = false} ? :)
User avatar
steinio
Smart Inserter
Smart Inserter
Posts: 2638
Joined: Sat Mar 12, 2016 4:19 pm
Contact:

Re: [MOD 0.14] Text Plates

Post by steinio »

Hello,

as described here viewtopic.php?f=7&t=45940 the colons of the research panel are not localized with this mod installed anymore.

Has anybody else this problem?

Greetings, steinio.
Image

Transport Belt Repair Man

View unread Posts
User avatar
undarl
Inserter
Inserter
Posts: 34
Joined: Mon Mar 27, 2017 8:36 pm
Contact:

Re: [MOD 0.14] Text Plates

Post by undarl »

steinio wrote:Hello,

as described here viewtopic.php?f=7&t=45940 the colons of the research panel are not localized with this mod installed anymore.

Has anybody else this problem?

Greetings, steinio.
Yup. It's not just the research, either, at least for me. Happens all over the place, including in the mod enable/disable interface.

It looks like Text Plates is setting a locale definition for the "colon" keyword, which is overriding the locale for that same keyword in __core__/locale/xx/core.cfg.

I was able to fix it by renaming the colon keyword to something else in both strings.cfg and plate_types.lua in Text Plates.
User avatar
Earendel
Factorio Staff
Factorio Staff
Posts: 716
Joined: Sun Nov 23, 2014 11:57 am
Contact:

Re: [MOD 0.14] Text Plates

Post by Earendel »

undarl wrote:
steinio wrote:Hello,

as described here viewtopic.php?f=7&t=45940 the colons of the research panel are not localized with this mod installed anymore.

Has anybody else this problem?

Greetings, steinio.
Yup. It's not just the research, either, at least for me. Happens all over the place, including in the mod enable/disable interface.

It looks like Text Plates is setting a locale definition for the "colon" keyword, which is overriding the locale for that same keyword in __core__/locale/xx/core.cfg.

I was able to fix it by renaming the colon keyword to something else in both strings.cfg and plate_types.lua in Text Plates.
That's a weird bug, but it's fixed now.
User avatar
steinio
Smart Inserter
Smart Inserter
Posts: 2638
Joined: Sat Mar 12, 2016 4:19 pm
Contact:

Re: [MOD 0.14] Text Plates

Post by steinio »

Thank you.
Image

Transport Belt Repair Man

View unread Posts
Peter34
Smart Inserter
Smart Inserter
Posts: 1100
Joined: Mon Nov 10, 2014 12:44 pm
Contact:

Re: [MOD 0.14] Text Plates

Post by Peter34 »

I'm getting some inconsistent behaviour with Blueprints. I made a bunch of Blueprints in a cheat mode game, and saved them in my general player's library. In these BPs, I sometimes included Text Plate "labels" for input and/or output Belts or Pipes, so that for instance I could know that for this structure, this Belt has to receive Iron Plate, and this Belt Copper Plate, and then out of this Belt comes Electronic Circuits.

But the Text Plates aren't reproduced when I plonk down the Blueprints in a newly started game.

What gives?
Post Reply

Return to “Mods”