dealing with luaui conflict in non conventional manner. - Page 2

dealing with luaui conflict in non conventional manner.

Discuss Lua based Spring scripts (LuaUI widgets, mission scripts, gaia scripts, mod-rules scripts, scripted keybindings, etc...)

Moderator: Moderators

SirMaverick
Posts: 834
Joined: 19 May 2009, 21:10

Re: dealing with luaui conflict in non conventional manner.

Post by SirMaverick »

Niobium wrote:
zwzsg wrote:Then I'd say that widgets that do nasty stuff even when disabled should be killed on sight.
Exactly this. To write a widget that messed with things mod-wide, only on particular mods, and even when disabled would require either deliberate intent or gross incompetence. Do you have the names of some of these widgets?
http://trac.caspring.org/changeset/8169
Nothing that crashes, but very annoying. Executed regardless the widget is enabled or not.
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Re: dealing with luaui conflict in non conventional manner.

Post by Argh »

Read the P.U.R.E. source, it has a working whitelist for things that are known to be safe and tested. And I wrote a blacklist that worked OK at one point as well, although I agreed with the feeling at the time that it would be more of a time-waster than not.

There aren't any other solutions.

Widgets as a concept without game filtering was a mistake. Now we're stuck with either invalidating all of the old Widgets (which, personally, I'd be fine with) until they're updated to deal with game filtering, or just customizing a game to do whitelist. There's nothing else worth bothering with.
User avatar
smoth
Posts: 22309
Joined: 13 Jan 2005, 00:46

Re: dealing with luaui conflict in non conventional manner.

Post by smoth »

I already said I don't want whitelist, i am trying to understand why the selections.lua isn't read in vfs.
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Re: dealing with luaui conflict in non conventional manner.

Post by Argh »

Oh, so you're hoping that Widget writers will, eh, "Gundam-certify" their wares?

Good luck with that. I guess that we're done here.
User avatar
FLOZi
MC: Legacy & Spring 1944 Developer
Posts: 6240
Joined: 29 Apr 2005, 01:14

Re: dealing with luaui conflict in non conventional manner.

Post by FLOZi »

Smoth's current plans have quite some merit imo. It's about (much) more than widgets.
User avatar
smoth
Posts: 22309
Joined: 13 Jan 2005, 00:46

Re: dealing with luaui conflict in non conventional manner.

Post by smoth »

widgets are the start point.
User avatar
zwzsg
Kernel Panic Co-Developer
Posts: 7049
Joined: 16 Nov 2004, 13:08

Re: dealing with luaui conflict in non conventional manner.

Post by zwzsg »

Niobium wrote:
zwzsg wrote:Then I'd say that widgets that do nasty stuff even when disabled should be killed on sight.
Exactly this. To write a widget that messed with things mod-wide, only on particular mods, and even when disabled would require either deliberate intent or gross incompetence. Do you have the names of some of these widgets? I'd like to see what was done, as I've never seen this kind of widget before, I also reckon they could be fixed with a simple copy-paste into :Initialize.
Its not deliberate intent or that gross incompetence, but many people put their initialisation code "outside of any function" instead of within Initialize(). Trepan showed the way but using variable initialization and some small "if" test on game constants, but he knew his stuff and never used command that change things. But then people started coding in the same manner, and then they started using commands there, without thinking about the consequence.

But the only exemple I remember is indeed Regret's specrun. I remember Smoth raged alot and Regret was delighted upon learning he accidentally broke GRTS. Then maybe it was Regret's weird humor, I don't know, maybe he fixed it later, well at least so I hope. :regret:
User avatar
knorke
Posts: 7971
Joined: 22 Feb 2006, 01:02

Re: dealing with luaui conflict in non conventional manner.

Post by knorke »

Its not deliberate intent or that gross incompetence, but many people put their initialisation code "outside of any function" instead of within Initialize().
Wait wat, I did that too.
Only short init stuff though.
So to understand correctly, this is basically bad because stuff outside functions gets executed even if the widget/gadget is disabled? :shock:
Tbh I thought files with enabled=false in GetInfo() are just ignored.
User avatar
Forboding Angel
Evolution RTS Developer
Posts: 14673
Joined: 17 Nov 2005, 02:43

Re: dealing with luaui conflict in non conventional manner.

Post by Forboding Angel »

Yes, that is why when I disable widgets in evo but leave them in (because I might have use for them later) I actually rename the file. Enabled = false, doesn't actually work most of the time.
User avatar
zwzsg
Kernel Panic Co-Developer
Posts: 7049
Joined: 16 Nov 2004, 13:08

Re: dealing with luaui conflict in non conventional manner.

Post by zwzsg »

Enabled = false only work for the first time a mod sees a widget. Afterward, the mod reloads the LuaUI config.
User avatar
Pxtl
Posts: 6112
Joined: 23 Oct 2004, 01:43

Re: dealing with luaui conflict in non conventional manner.

Post by Pxtl »

knorke wrote:
Its not deliberate intent or that gross incompetence, but many people put their initialisation code "outside of any function" instead of within Initialize().
Wait wat, I did that too.
Only short init stuff though.
So to understand correctly, this is basically bad because stuff outside functions gets executed even if the widget/gadget is disabled? :shock:
Tbh I thought files with enabled=false in GetInfo() are just ignored.
No.

Remember Lua is an interpreted language. The object and the GetInfo() function are created by executing the whole file. So the logic is "execute file, take resulting object, call GetInfo on resulting object... .when enabled, call Initialize on that object".

See? If you have any code in the file, it gets hit in the first step.
User avatar
jK
Spring Developer
Posts: 2299
Joined: 28 Jun 2007, 07:30

Re: dealing with luaui conflict in non conventional manner.

Post by jK »

hmmm I see I didn't mentioned it yet here, but I have a new widgetHandler in work, it will make configuration easier and will add sandboxing to the first loading of the widgets (GetInfo thingy) and maybe add a new trepan-style widget format (with backward support for the old one). Estimated time till it's finished 1-2months.
User avatar
smoth
Posts: 22309
Joined: 13 Jan 2005, 00:46

Re: dealing with luaui conflict in non conventional manner.

Post by smoth »

so apparently it WAS
local text = VFS.LoadFile(filename, fromZip and VFS.ZIP or VFS.RAW)

simple fix was.
local text = VFS.LoadFile(filename)

Flozi helped me debug it last night. Chest bump bro!
Post Reply

Return to “Lua Scripts”