problem with lua learning
Moderator: Forum Moderators
- hermestrismi
- Posts: 634
- Joined: February 6th, 2016, 11:28 pm
- Location: Tunisia
- Contact:
problem with lua learning
Hi,
this is my first attempt to learn and use Lua coding
I used the Ei event (found a boss at a random village and I tried to make it 6 bosses at 6 random villages (other villages will give you bandits)
now,
1- I turned to (from boolean to numerical)
2- I replaced to , and to
the error I get is that and are missing.
any ideas?
PS: BfW 1.16.2
the events are here
this is my first attempt to learn and use Lua coding
I used the Ei event (found a boss at a random village and I tried to make it 6 bosses at 6 random villages (other villages will give you bandits)
now,
1- I turned
Code: Select all
vars.boss_found = false
Code: Select all
vars.boss_found = 0
2- I replaced
Code: Select all
if not boss_found and visited > 2 then
Code: Select all
if boss_found < 6 and visited > 2 then
Code: Select all
vars.boss_found = true
Code: Select all
vars.boss_found > 6
"the original code"
Code: Select all
spread_bandit_villages
Code: Select all
bandit_village_capture
any ideas?
PS: BfW 1.16.2
the events are here
events
The Dark Master, The Dark Hordes (Unofficial version), Return of the Legion , Eternal Kingdom, An Elvish Scout,Unrest in Elfland , Hidden War ...
The Dark Master Project, Arabic tra. maintainer
"But he loves you" G. Carlin
The Dark Master Project, Arabic tra. maintainer
"But he loves you" G. Carlin
- hermestrismi
- Posts: 634
- Joined: February 6th, 2016, 11:28 pm
- Location: Tunisia
- Contact:
Re: problem with lua learning
edit
Horray
it works
my first ever lua manipulation lol
but still, can I prevent more than 6 bosses by?
edit tested and so far worked.
still, I really want to know the background of the first error :/
Horray
Code: Select all
if visited > 2 then
Code: Select all
if rand3 <= boss_chance or #bandit_villages < 6 then
vars.boss_found = 1
my first ever lua manipulation lol
but still, can I prevent more than 6 bosses by
Code: Select all
if rand3 <= boss_chance or #bandit_villages < 6 or 6 <= boss_found then
vars.boss_found = 1
edit
Code: Select all
if rand3 <= boss_chance or #bandit_villages < 6 and 6 <= boss_found then
still, I really want to know the background of the first error :/
The Dark Master, The Dark Hordes (Unofficial version), Return of the Legion , Eternal Kingdom, An Elvish Scout,Unrest in Elfland , Hidden War ...
The Dark Master Project, Arabic tra. maintainer
"But he loves you" G. Carlin
The Dark Master Project, Arabic tra. maintainer
"But he loves you" G. Carlin
- Celtic_Minstrel
- Developer
- Posts: 2290
- Joined: August 3rd, 2012, 11:26 pm
- Location: Canada
- Contact:
Re: problem with lua learning
Uhhh… how on earth does that make any sense? I don't think it's even valid code? You can't just replace an assignment with an expression. Probably what you actually want there ishermestrismi wrote: ↑June 14th, 2022, 5:52 pmtoCode: Select all
vars.boss_found = true
Code: Select all
vars.boss_found > 6
vars.boss_found = vars.boss_found + 1
.I think that would explain the error you mention, as using an expression where a statement is expected is a syntax error, and a syntax error in a Lua file will prevent everything in that file from being loaded.
- hermestrismi
- Posts: 634
- Joined: February 6th, 2016, 11:28 pm
- Location: Tunisia
- Contact:
Re: problem with lua learning
I said this my first ever try on lua so 'stupid' errors are normal I supposeCeltic_Minstrel wrote: ↑June 15th, 2022, 12:50 pmUhhh… how on earth does that make any sense? I don't think it's even valid code? You can't just replace an assignment with an expression. Probably what you actually want there ishermestrismi wrote: ↑June 14th, 2022, 5:52 pmtoCode: Select all
vars.boss_found = true
Code: Select all
vars.boss_found > 6
vars.boss_found = vars.boss_found + 1
.
I think that would explain the error you mention, as using an expression where a statement is expected is a syntax error, and a syntax error in a Lua file will prevent everything in that file from being loaded.
anyway, I understand now the nature of the mistake (from statement to number) and while fixing it , i figured out many new thing (how or, and, for, for not works, how equals =, less than <, greater than > , less than greater <= -the variable ... works, ..., the things that must be defined before working like nature of variables' values... ).
Now, it works fine except my fear that, under some circumstances , the player may encounter more than 6 bosses but i tested it and that never happen actually
The Dark Master, The Dark Hordes (Unofficial version), Return of the Legion , Eternal Kingdom, An Elvish Scout,Unrest in Elfland , Hidden War ...
The Dark Master Project, Arabic tra. maintainer
"But he loves you" G. Carlin
The Dark Master Project, Arabic tra. maintainer
"But he loves you" G. Carlin
- hermestrismi
- Posts: 634
- Joined: February 6th, 2016, 11:28 pm
- Location: Tunisia
- Contact:
Re: problem with lua learning
the full new code
The Dark Master, The Dark Hordes (Unofficial version), Return of the Legion , Eternal Kingdom, An Elvish Scout,Unrest in Elfland , Hidden War ...
The Dark Master Project, Arabic tra. maintainer
"But he loves you" G. Carlin
The Dark Master Project, Arabic tra. maintainer
"But he loves you" G. Carlin
- hermestrismi
- Posts: 634
- Joined: February 6th, 2016, 11:28 pm
- Location: Tunisia
- Contact:
Re: problem with lua learning
and, for information, i did some campaigns before but real variables and other wml manipulation was really began on last april as for lua learning (my first ever encounter with programming ) began 2 days ago. otherwise , i usually learn by mistakes and searching, and this is hard for me. so, be easy on me
The Dark Master, The Dark Hordes (Unofficial version), Return of the Legion , Eternal Kingdom, An Elvish Scout,Unrest in Elfland , Hidden War ...
The Dark Master Project, Arabic tra. maintainer
"But he loves you" G. Carlin
The Dark Master Project, Arabic tra. maintainer
"But he loves you" G. Carlin