NoCheat, Alpha 2

NoCheat, Alpha 2

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

Moderator: Moderators

Post Reply
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

NoCheat, Alpha 2

Post by Argh »

I've finally figured out how to shut down non-mod Widgets (I think) and just load game Widgets, in an easy-to-install package for game developers.

This is obviously a big step up in security from WhiteList, and will probably not be suitable for everybody's project (in which case, use WhiteList, or reverse its logic to make it a blacklist application, and remove the part where it shuts down the Widget Selector- sometimes all you'd want is to shut certain things off by default, and obviously this is a lot more rigid- if it's not in you mod/game, it just doesn't load at all).

This must be added as a dependency to your mod / game in order to work. I.E., go into modinfo.tdf, and add it in there. If somebody is clueless and wants an example, lemme know, it's pretty straightforward imo.

100% of the credit for this code goes to Lurker, Trepan and Regret. This version uses Regret's suggested changes, which were based on Lurker's comments in the White List thread and Trepan's original source. I just typed some stuff and copy-pasted.

Please let me know if my fumble-fingered programming broke anything really permanently. Thus far, it seems to be passing all tests- my Widgets load, nothing else does. And it finally works with World Builder!

So, the next step is deciding on a list of non-cheating-but-useful Widgets that may be run with my game, and throwing them into an archive, or into World Builder (might be handy to just make a compilation of stuff that's useful, isn't a cheat, and doesn't break UIs).

Here's the file.
Last edited by Argh on 22 Jan 2009, 00:15, edited 3 times in total.
Regret
Posts: 2086
Joined: 18 Aug 2007, 19:04

Re: NoCheat, Alpha 1

Post by Regret »

How to force loading of only mod widgets.

1) Place a file named LockLuaUI.txt into gamedata

2) Copy widget.lua into your mods LuaUI folder, delete the segment that has a comment "-- stuff the raw widgets into unsortedWidgets"

3) Copy main.lua into your mods LuaUI folder
replace the line "include("widgets.lua",nil,VFS.ZIP_ONLY) -- the widget handler"
with "loadstring(VFS.LoadFile(LUAUI_DIRNAME .. 'widgets.lua', VFS.ZIP_ONLY))()"

4) Create a luaui.lua directly in your mod folder
luaui.lua contents:

Code: Select all

LUAUI_VERSION = "LuaUI v0.2"

if (gl) then
  Spring.Draw = gl  --  backwards compatibility, 0.74b3 did not have 'gl'
end

LUAUI_DIRNAME   = 'LuaUI/'
MODUI_DIRNAME   = 'ModUI/'

USER_FILENAME   = LUAUI_DIRNAME .. 'main.lua'

VFS.DEF_MODE = VFS.ZIP_FIRST

local text

do
	text = VFS.LoadFile(USER_FILENAME, VFS.ZIP_ONLY)
	if (text == nil) then
		Script.Kill('Failed to load ' .. USER_FILENAME)
	end
	local chunk, err = loadstring(text)
	if (chunk == nil) then
		Script.Kill('Failed to load ' .. USER_FILENAME .. ' (' .. err .. ')')
	else
		USER_FILENAME   = nil
		chunk()
		return
	end
end
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Re: NoCheat, Alpha 1

Post by Argh »

Lemme test that, it would be less messy than this is, and probably vastly easier to maintain going forward.

[EDIT]Step 3 doesn't apply to current widgets.lua, but I'll try the replacement.[/EDIT]
Regret
Posts: 2086
Joined: 18 Aug 2007, 19:04

Re: NoCheat, Alpha 1

Post by Regret »

Argh wrote:[EDIT]Step 3 doesn't apply to current widgets.lua, but I'll try the replacement.[/EDIT]
Step 3 is about editing main.lua, not widgets.lua.
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Re: NoCheat, Alpha 1

Post by Argh »

Ok, it works. Archive has been updated, and isn't full of irrelevant code. I'm keeping it as an add-on module, like World Builder, so that I can have mutator versions of P.U.R.E. that allow Widgets to operate, etc., so that everybody's happy. If people want to play with stuff that may be a cheat, that's great, I'm actually ok with that, so long as everybody knows that that's what they're doing... but they can run "pure mode" for competitive play, etc.
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Re: NoCheat, Alpha 2

Post by Argh »

Do we actually need this line? I mean... nobody is ever going to run P.U.R.E. with 0.74b3...

Code: Select all

if (gl) then
  Spring.Draw = gl  --  backwards compatibility, 0.74b3 did not have 'gl'
end
[EDIT]No, we don't. I guess that was left in for older Widget support. Removed it in my version, I'll update the archive.[/EDIT]
User avatar
lurker
Posts: 3842
Joined: 08 Jan 2007, 06:13

Re: NoCheat, Alpha 2

Post by lurker »

I can't even get 2 (per)cents of credit for flat-out telling you to do this in your whitelist widget thread?
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Re: NoCheat, Alpha 2

Post by Argh »

Absolutely. My fault, fixed.
User avatar
lurker
Posts: 3842
Joined: 08 Jan 2007, 06:13

Re: NoCheat, Alpha 2

Post by lurker »

:roll:

On the bright side, basic no longer has to try to do this himself as I, distracted by other programs, don't quite help in pm.
User avatar
Forboding Angel
Evolution RTS Developer
Posts: 14673
Joined: 17 Nov 2005, 02:43

Re: NoCheat, Alpha 2

Post by Forboding Angel »

This is excellent. Would be nice if via modrules we could just tell the mod to override the user lua. Why it is the other way around is stupid.

Oh btw, to anyone who uses this, extract it and put it in an sd7 Using 7Zip. Windows IE likes to rename files. Additionally, calling this "No Cheat" is silly. It has a lot more uses.
Last edited by Forboding Angel on 26 Feb 2009, 02:05, edited 1 time in total.
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Re: NoCheat, Alpha 2

Post by Argh »

Yeah, it would probably be more appropriate to call it "GameOnlyWidgets" or something.
Post Reply

Return to “Lua Scripts”