enclave's Lua thread
Moderator: Forum Moderators
Re: enclave's Lua thread
There are variables there, in [replay], [ai_something], [turn], but you can't retrieve them.
Re: enclave's Lua thread
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
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.
Re: enclave's Lua thread
os.time(os.date("!*t")) gives unix time as reported by local computer, so still possible to deceive it.
Re: enclave's Lua thread
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.
Re: enclave's Lua thread
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:
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:
? 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... =]os.time(os.date("!*t")) gives unix time, still possible to deceive it.
Re: enclave's Lua thread
If you know how to run command with different system time, then you know how to unpack savefiles and analyse them directly.
Re: enclave's Lua thread
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)
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)
Re: enclave's Lua thread
I have finally tried to do something like that, so far it didnt work..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
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:
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..
Re: enclave's Lua thread
No. Access to files is very limited.
Village gold and turn limit can be changed during game.
Village gold and turn limit can be changed during game.
Re: enclave's Lua thread
I have finally tried to do something like that, so far it didnt work..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
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:
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?
Re: enclave's Lua thread
Hi, I tried to port somebody's else add-on/campaign to 1.14 (from 1.10) and it apparently gives this error message (log):
It looks to me that I just need to change the "register_wml_action" code to make it work correctly, but could you tell me if there is also a problem to perform "dofile" and I need to change the dofile code too? I can't understand lua errors well.. Thanks in advance.
Code: Select all
20181206 17:40:22 error scripting/lua: In function lua_kernel::run(): Lua Error:
When executing, Lua runtime error: ~add-ons/Cities_of_the_Frontier/lua/utils.lua:12: attempt to call a nil value (field 'register_wml_action')
stack traceback:
~add-ons/Cities_of_the_Frontier/lua/utils.lua:12: in main chunk
[C]: in field 'dofile'
[string "wesnoth.dofile '~add-ons/Cities_of_the_Fronti..."]:1: in main chunk
Invalid WML found: unknown conditional wml: [message]
20181206 17:51:34 error ai/engine/cpp: side 3 : UNKNOWN goal[protect_my_unit]
Invalid WML found: [save_map] not supported
20181206 18:13:31 error scripting/lua: In function lua_kernel::run(): Lua Error:
When executing, Lua runtime error: ~add-ons/Cities_of_the_Frontier/lua/utils.lua:12: attempt to call a nil value (field 'register_wml_action')
stack traceback:
~add-ons/Cities_of_the_Frontier/lua/utils.lua:12: in main chunk
[C]: in field 'dofile'
[string "wesnoth.dofile '~add-ons/Cities_of_the_Fronti..."]:1: in main chunk
20181206 18:13:31 warning unit: Unknown attribute 'previous_recruits' discarded.
Invalid WML found: [load_map] not supported
Re: enclave's Lua thread
This message says that something.register_wml_action should be a function, but it is nil.
Re: enclave's Lua thread
Has anyone found a fix for this bug yet?
Re: enclave's Lua thread
wesnoth.register_wml_action was deprecated and removed. Someone is going to have to patch the addon to use some other wesnoth.foo function that hasn't been removed. (Or it might be possible to reimplement register_wml_action as a wrapper around some other wesnoth.foo function.)
As a workaround, you can play the addon on 1.10. (I don't know if it works on 1.12.)
As a workaround, you can play the addon on 1.10. (I don't know if it works on 1.12.)