enclave's Lua thread

Discussion of Lua and LuaWML support, development, and ideas.

Moderators: Forum Moderators, Developers

Post Reply
Choicerer
Posts: 238
Joined: April 29th, 2017, 11:37 pm

Re: enclave's Lua thread

Post by Choicerer » July 7th, 2018, 3:20 am

There are variables there, in [replay], [ai_something], [turn], but you can't retrieve them.

gfgtdf
Developer
Posts: 1031
Joined: February 10th, 2013, 2:25 pm

Re: enclave's Lua thread

Post by gfgtdf » July 8th, 2018, 7:42 pm

yes the is afaik no way to to know on which turn the save was done when loading a replay.

What could maybe work do is to store the current time in the replay start, (assuming that on_save is also called when [replay_start] is created, not sure on that) and then refuse to load of that happend less that one hour ago. To get the current time you can probably use the lua is function
Scenario with Robots SP scenario (1.11/1.12), allows you to build your units with components, PYR No preperation turn 1.12 mp-mod that allows you to select your units immideately after the game begins.

User avatar
Ravana
Moderator
Posts: 1816
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: enclave's Lua thread

Post by Ravana » July 8th, 2018, 8:48 pm

os.time(os.date("!*t")) gives unix time as reported by local computer, so still possible to deceive it.

gfgtdf
Developer
Posts: 1031
Joined: February 10th, 2013, 2:25 pm

Re: enclave's Lua thread

Post by gfgtdf » July 8th, 2018, 8:50 pm

well yes but as I understood it his point was just to make cheating a little harder.
Scenario with Robots SP scenario (1.11/1.12), allows you to build your units with components, PYR No preperation turn 1.12 mp-mod that allows you to select your units immideately after the game begins.

enclave
Posts: 822
Joined: December 15th, 2007, 8:52 am

Re: enclave's Lua thread

Post by enclave » July 9th, 2018, 2:21 pm

gfgtdf thanks so much! it's a great idea! I will give it a try and report back!
Yeah removing cheating completely is impossible, I will not even go into details for all possible ways, but numbers of cheaters could be reduced by implementing some basic protection... for example when statistics were broken prior to 1.14.3 anyone could cheat with just looking statistics, it was very very simple, very fast, very tempting and some really strong players admitted that they either used it or it was very tempting to use it... 1.14.3 covered that bug, and I realized that cheating could become even a bit more complicated... the harder it is the less chance somebody would do it.. even if cheating would be reduced by 5% its a win :)
Ravana thanks very much for the date/time code, now you wrote it so i don't have to google for it anymore, could you please edit your post to just something like:
os.time(os.date("!*t")) gives unix time, still possible to deceive it.
? Just so nobody could find the workaround too easily, reading your original post gives a big hint on how to break it. Sorry for asking and thanks very much for understanding... =]

User avatar
Ravana
Moderator
Posts: 1816
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: enclave's Lua thread

Post by Ravana » July 9th, 2018, 2:38 pm

If you know how to run command with different system time, then you know how to unpack savefiles and analyse them directly.

enclave
Posts: 822
Joined: December 15th, 2007, 8:52 am

Re: enclave's Lua thread

Post by enclave » July 10th, 2018, 1:33 pm

Ravana wrote:
July 9th, 2018, 2:38 pm
If you know how to run command with different system time, then you know how to unpack savefiles and analyse them directly.
i was thinking that system time could be changed just with right clicking on time in bottom right corner of windows?

Choicerer
Posts: 238
Joined: April 29th, 2017, 11:37 pm

Re: enclave's Lua thread

Post by Choicerer » July 10th, 2018, 1:40 pm

What Ravana is talking about though, is starting Wesnoth in Unix, with a different system time than what is actually set.
Aside from that, yeah, you are right.
(Sometimes your OS might be set to sync the time with the Bios Time or from the Internet, but it doesn't take great skill to switch it off, I guess)

enclave
Posts: 822
Joined: December 15th, 2007, 8:52 am

Re: enclave's Lua thread

Post by enclave » July 15th, 2018, 9:39 pm

gfgtdf wrote:
July 8th, 2018, 7:42 pm
yes the is afaik no way to to know on which turn the save was done when loading a replay.
What could maybe work do is to store the current time in the replay start, (assuming that on_save is also called when [replay_start] is created, not sure on that) and then refuse to load of that happend less that one hour ago. To get the current time you can probably use the lua is function
I have finally tried to do something like that, so far it didnt work..

Question: is there a WML/lua way to access the saved game file "date created" field? (This seems to be the only place where it displays time when loading game, so there would be a chance to compare the savefile creation time to current time if there was a function to do it?..)

Everything that happens during replay seems to happen in realtime.. So replay has it's own starting time, when you start the replay.. I couldn't find any variable that would store anything from original game.. doesnt look like there is anything that I could access..
I tried the code in the spoiler if you curious what exactly I tried to do.. (it doesnt even display any onsave message during replay, only during game)
Spoiler:
Something just came to my mind...
Question #2: Can I modify "mp_village_gold=2" variable from in game? or mp_num_turns?
I will test what effect it has on replay if i change turn limit... this could be the global variable I need if it works..

User avatar
Ravana
Moderator
Posts: 1816
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: enclave's Lua thread

Post by Ravana » July 15th, 2018, 9:57 pm

No. Access to files is very limited.

Village gold and turn limit can be changed during game.

enclave
Posts: 822
Joined: December 15th, 2007, 8:52 am

Re: enclave's Lua thread

Post by enclave » July 15th, 2018, 10:15 pm

gfgtdf wrote:
July 8th, 2018, 7:42 pm
yes the is afaik no way to to know on which turn the save was done when loading a replay.
What could maybe work do is to store the current time in the replay start, (assuming that on_save is also called when [replay_start] is created, not sure on that) and then refuse to load of that happend less that one hour ago. To get the current time you can probably use the lua is function
I have finally tried to do something like that, so far it didnt work..

Question: is there a WML/lua way to access the saved game file "date created" field? (This seems to be the only place where it displays time when loading game, so there would be a chance to compare the savefile creation time to current time if there was a function to do it?..)

Everything that happens during replay seems to happen in realtime.. So replay has it's own starting time, when you start the replay.. I couldn't find any variable that would store anything from original game.. doesnt look like there is anything that I could access..
I tried the code in the spoiler if you curious what exactly I tried to do.. (it doesnt even display any onsave message during replay, only during game)
Spoiler:
Something just came to my mind...
Question #2: Can I modify "mp_village_gold=2" variable from in game? or mp_num_turns?
I will test what effect it has on replay if i change turn limit... this could be the global variable I need if it works..

Question #3 when choosing replay file to load, it shows "difficulty: medium" is there a way to change or access that value in game?

Post Reply