[Learning LUA] Lesson 3: Values and Operators is up!

Talk about creating Grimrock 1 levels and mods here. Warning: forum contains spoilers!
User avatar
SpiderFighter
Posts: 789
Joined: Thu Apr 12, 2012 4:15 pm

Re: [Learning LUA] Lesson 3: Values and Operators is up!

Post by SpiderFighter »

Neikun wrote:When's the next lesson, Spider?
Right now, my life has been crazy hectic, so I honestly don't know. I originally took time away from the Lua in order to finish my mod but I haven't even had time to do that. Now I'm preparing to re-enter school, so that's really been taking up all my time. The thread is open-ended though, so that anyone who wants to can throw in their own two cents, advice, tips, or lesson.
User avatar
Halluinoid
Posts: 165
Joined: Tue Apr 02, 2013 7:08 pm
Contact:

Re: [Learning LUA] Lesson 3: Values and Operators is up!

Post by Halluinoid »

what IS your MOD SpiderFighter? is there a thread on it? ;)

this is a great thread, it's very tempting to just use the Dungeon Editor without Lua at all :o which is what I have done so far!

but with a thread like this - maybe some simple Lua scripting can begin :D
User avatar
SpiderFighter
Posts: 789
Joined: Thu Apr 12, 2012 4:15 pm

Re: [Learning LUA] Lesson 3: Values and Operators is up!

Post by SpiderFighter »

Halluinoid wrote:what IS your MOD SpiderFighter? is there a thread on it? ;)

this is a great thread, it's very tempting to just use the Dungeon Editor without Lua at all :o which is what I have done so far!

but with a thread like this - maybe some simple Lua scripting can begin :D
My mod is at viewtopic.php?f=14&t=3638

I had to re-do the first couple of levels, as they were pretty dull to play. Now, the mapping and item/mob placement is 95% finished; at this point, all I really have left to do is finish the dialogue and boss fights; I just haven't been able to work on it the last few months. Although I'm sure no one is going to going to care when it finally gets released! lol
Thau
Posts: 3
Joined: Fri Oct 11, 2013 6:25 am

Re: [Learning LUA] Lesson 3: Values and Operators is up!

Post by Thau »

I don't know if somebody knows, there is a gloabl variable _G that contains everything, I can't use in in Grimrock, did anyone know a way to get all globals elements (would be usefull to know the potential of Grimrock) ?

Thanks in advance.

Also, I've been using lua a little for another game, and for Grimrock I quickly recreated the 3 signs riddle we can encouter in Skyrim, but I don't know how to use corectly timers ?
User avatar
Diarmuid
Posts: 807
Joined: Thu Nov 22, 2012 6:59 am
Location: Montreal, Canada
Contact:

Re: [Learning LUA] Lesson 3: Values and Operators is up!

Post by Diarmuid »

Thau wrote:I don't know if somebody knows, there is a gloabl variable _G that contains everything, I can't use in in Grimrock, did anyone know a way to get all globals elements (would be usefull to know the potential of Grimrock) ?

Thanks in advance.

Also, I've been using lua a little for another game, and for Grimrock I quickly recreated the 3 signs riddle we can encouter in Skyrim, but I don't know how to use corectly timers ?
You cannot access the _G, as each script entity only has a local scope.

Documentation for the timers is in the modding section, but if you're good with lua you might bypass it. The most accurate technique most advanced mods here use is to use the party onDrawGui hook as an update function, use getStatistic("play_time") to establish a deltaTime, then program delays & coroutines within lua.
User avatar
Frenchie
Posts: 219
Joined: Wed Oct 16, 2013 2:50 am

Re: [Learning LUA] Lesson 3: Values and Operators is up!

Post by Frenchie »

Now I was a very old school Cobol programmer in the '80 for a very short time. I learned some machine code, jsp and had already taught myself basic on the zx spectrum. I learned binary and hexadecimal systems. I used that knowledge for editing game memories. Nowadays I mostly use my skills in excel like making a calendar.

What most programmers forget or are too lazy is to make program structure diagrams or schedules (one with symbols the other takes the whole A4 width). You write your ideas like that and think about any possible direction the flow might go. Then you test your variables and see if the result in every flow is what you want it to be.

Now you start programming and you follow your paper. You define all your variables and initial values and in the end you set them to zero again. With special editors you for next loops. etc. get a tab automatically and it makes it easier to read. Some might even detect when you forget a space, point or a comma. Then you clean it up and test it. If it works you go to the next part...
Angrynoodle1
Posts: 1
Joined: Wed Dec 04, 2013 3:25 am

Re: [Learning LUA] Lesson 3: Values and Operators is up!

Post by Angrynoodle1 »

Hello
This is my first post on the site.
And similarly My first minute trying anything in lua!
i just was hoping i could get a bit of help on a failed attempt at writing something very basic.
Please be gentle
Here it is:
funcion snaildrop ()
spawn ("snail" 1, 15, 11, 2)
end


the error message '=' expected near snaildrop appears.
Last edited by Angrynoodle1 on Wed Dec 04, 2013 3:52 am, edited 1 time in total.
User avatar
Komag
Posts: 3654
Joined: Sat Jul 28, 2012 4:55 pm
Location: Boston, USA

Re: [Learning LUA] Lesson 3: Values and Operators is up!

Post by Komag »

Code: Select all

function snaildrop()
  spawn("snail", 1, 15, 11, 2)
end
Finished Dungeons - complete mods to play
User avatar
Diarmuid
Posts: 807
Joined: Thu Nov 22, 2012 6:59 am
Location: Montreal, Canada
Contact:

Re: [Learning LUA] Lesson 3: Values and Operators is up!

Post by Diarmuid »

You wrote funcion not function ;)
Glew
Posts: 74
Joined: Sat Dec 21, 2013 7:57 pm

Re: [Learning LUA] Lesson 3: Values and Operators is up!

Post by Glew »

Diarmuid wrote:Hi all,

A scripting help session with drakkan today on the LoTNR chat gave me an idea to contribute to this thread with a general programming principle, which is called

DRY - Don't Repeat Yourself
Where have you been all my life?! :o :_( Or well, where have I been all this time?!
Anyway, thankyousomuch! :!: :!: :!: :!: :!:
Words can't describe how useful this post is for me as a total noob and layperson to coding! :tearsofjoy:

Also this whole topic is a gold mine so thanks in advance for every other contributor as well and of course to SpiderFighter!
Post Reply