another question about syntax

Ask for help about creating mods and scripts for Grimrock 2 or share your tips, scripts, tools and assets with other modders here. Warning: forum contains spoilers!
User avatar
Isaac
Posts: 3192
Joined: Fri Mar 02, 2012 10:02 pm

Re: another question about syntax

Post by Isaac »

The same in this (and most) context, but one has to use bracket/quotes if the key name is for any reason ambiguous.

Code: Select all

objectIDs = {}
object["151781"] = {...}
minmay
Posts: 2790
Joined: Mon Sep 23, 2013 2:24 am

Re: another question about syntax

Post by minmay »

Isaac wrote:The same in this (and most) context, but one has to use bracket/quotes if the key name is for any reason ambiguous.

Code: Select all

objectIDs = {}
object["151781"] = {...}
Sure. However, the issue isn't just ambiguity. The reason these don't work:

Code: Select all

table.1cow = 3
table.dead beef = 5
table.while = 7
is that the shortcut syntax follows the same rules as identifier naming: only letters, digits, and underscores are allowed, and it cannot begin with a digit or be a reserved keyword like while. The string table.while would not be ambiguous, but it's still syntactically forbidden because while isn't a valid variable name.
Grimrock 1 dungeon
Grimrock 2 resources
I no longer answer scripting questions in private messages. Please ask in a forum topic or this Discord server.
User avatar
FeMaiden
Posts: 290
Joined: Wed Jan 16, 2013 8:16 am

Re: another question about syntax

Post by FeMaiden »

all right. understood.
apparently, at least one of you thinks I'm spending too much time asking questions.
I appreciate your answers and will take it as a learning experience.

I guess it's just partly that i just wanted to talk to someone, rather than digging around pages and pages and pages of year old forum posts...
minmay
Posts: 2790
Joined: Mon Sep 23, 2013 2:24 am

Re: another question about syntax

Post by minmay »

FeMaiden wrote:all right. understood.
apparently, at least one of you thinks I'm spending too much time asking questions.
If anyone thinks that, they're nuts, because the whole point of this subforum is to answer questions.
Grimrock 1 dungeon
Grimrock 2 resources
I no longer answer scripting questions in private messages. Please ask in a forum topic or this Discord server.
Azel
Posts: 808
Joined: Thu Nov 06, 2014 10:40 pm

Re: another question about syntax

Post by Azel »

I don't think you're asking too many questions, FeMaiden. I just think that you're selling yourself short by asking before engaging in the trial/error process. Getting answers to questions isn't as valuable as discovering something on your own.

But by all means, ask away!
User avatar
FeMaiden
Posts: 290
Joined: Wed Jan 16, 2013 8:16 am

Re: another question about syntax

Post by FeMaiden »

Azel wrote:I don't think you're asking too many questions, FeMaiden. I just think that you're selling yourself short by asking before engaging in the trial/error process. Getting answers to questions isn't as valuable as discovering something on your own.

But by all means, ask away!
if you guys noticed in some of my posts i asked a question and then 10 minutes later, found the answer out on my own.
If i could have deleted those posts, I would have, but I couldn't figure out how to get rid of them once they were created
I appreciate all the help that was given to me.


I admit I did sometimes get the impression you guys were annoyed with me.

I can see where minmay is coming from sometimes. he did frequently respond to me by giving me links to the scripting reference and lua manuals and stuff.

however,
I am a believer in the saying "give someone a fish and you feed them for a day, teach them how to fish and you feed them for a lifetime" . I am not religious (I know that's from the bible), I just think it's a good philosophy

I think the point was that
if you guys just wrote all my scripts for me, i would have ended up copy pasting them in my mod and then having no idea how to fix them if anything went wrong.

the lua manual confused me because many of the commands and syntax rules seemed to be different from what I see in the editor.
The lua manual seems to be more instructions on the basic generalized lua programming language, while lua that is in the editor is slighty more specific to this game.

I admit i was overwhelmend when minmay linked me to the asset pack and I looked at it and I didn't know what to do with it.
but I refer to the asset pack a lot now, that's where i get all my custom monster defintions and item defintions from.

when he told me to go to the scripting refernce page, I looked at it and it was just a wall of text (all greek to me). it looked like just a list of all the commands but with no explanation of the syntax, how was i supped to use it?

but now, I can answer many of my own questions just by looking in there.

I've opened up the dungeon editor file from the main campaign and lifted scripts from there to use in my own mod.
I was able to look in there and see how the devs did some of the stuff, like those 3 throwing knives stuck in the tree at the beginning of the game, they used setWorldPosition to move them up in the air.
I saw how they did the script for the alcove puzzle, their script was much more efficient than the one i'm currently using in mod and I'm gonna use that in the future.
I saw how they scripted the viper roots boss fight, the viper roots were an extremely frustrating mob for me to work with because I couldn't figure out how to make them sit still until the party gets close to them to activate the boss fight. even trapped inside a force field they just sink down and then pop up next to the party before i'm ready.

The links minmay gave me turned out to be very helpful after all.


I tried looking through the forum for a lot of the answers before asking them. I guess I'm just not that good at it. I type in keywords and it either brings up dozens of posts people made all containing the keywords i searched for...or it comes up with nothing at all.
alot of my questions, I don't think they have been asked before because they are so elementary, nobody else had the problems i had.
I've learned a lot over the past 3 weeks.

none of you were *obligated* to answer any of my questions and I probably would have just gotten bored and moved on.

the thing is, that it seems like the devs released this game with this dungeon editor, which is awesome! but then provided the bare minimum of instructions on how to use it, and I suspect that most people who open up the editor look at it and they're like "wtf is this" and don't even bother to come register on the forums to ask questions, they just move on, and then the few that figure out how to paint on the tiles then find out they have to learn lua and "eff this" and move on.

The idea of being able to create our own dungeons is so spectacular. if the community was large enough, this game would have infinite replayabiity.

looking back at all the earlier posts for the past couple of years it looks like all you guys started having to figure out everything as you went along. but I suspect you all mostly like isaac and minmay have computer programming background, probably been "hacking" since ya's were 12 years old. and therefore you were able to *puzzle* your way through.
in many parts of skuggasveinn's tutorials, he obviously knows what he is doing but he commented that at the time he had not "figured everything out yet".


maybe I was just looking for a "community". other likeminded gamers to talk to.
yeah, i could have stayed silent and just googled searched all my answers...probably would have given up and just played something else.
Azel
Posts: 808
Joined: Thu Nov 06, 2014 10:40 pm

Re: another question about syntax

Post by Azel »

if you guys just wrote all my scripts for me, i would have ended up copy pasting them in my mod and then having no idea how to fix them if anything went wrong.
I faced a similar challenge. To remedy that, I resorted to taking small steps:

1) Connect a lever to a secret door
2) Create a simple button puzzle that uses Counters
3) Spawn a monster

Then I went more advanced:

1) Connect a lever to an objects properties (eg, turn a light On/Off)
2) Create buttons that play custom sounds
3) Spawn a monster with connectors and custom attributes

By the time I would ask a question on the forum, I had exhausted all avenues.

If you write something that you can't fix later, you can just post your completed script here.
when he told me to go to the scripting refernce page, I looked at it and it was just a wall of text (all greek to me). it looked like just a list of all the commands but with no explanation of the syntax, how was i supped to use it?
I completely understand. A wall of text is useless. That's why starting small always helps. The moment you start connecting objects together in the Grimrock Editor using LUA Script, the more the scripting references become less a wall of text and more an actual guide.

I tried looking through the forum for a lot of the answers before asking them. I guess I'm just not that good at it.

The forums Search feature is quite terrible I must admit. It doesn't like it when you use "common words" which greatly limits searching for syntax related content.
maybe I was just looking for a "community". other likeminded gamers to talk to.
yeah, i could have stayed silent and just googled searched all my answers...probably would have given up and just played something else.
I am the last person to advocate for complete silence lol

Performing a Google search for all your questions is likely as ineffective as posting a new Topic for all your questions. Anything done in extremes typically yields negative results; or diminishing returns at the very least. It's all about balance! :mrgreen:

Some time back I requested that a new SubForm get created, specifically for complete Modding newbs. I knew that there was a need for the constant discussion of even the most trivial of questions. Basically, some place we could talk without being spammed with links to the Scripting Reference and Asset Pack. The closest thing we have now is the Sticky Topic created by Eleven Warrior: http://grimrock.net/forum/viewtopic.php?f=22&t=10070

If you are looking to have an area dedicated to open-community ongoing discussion geared more towards Learning, then simply create a single Thread for that purpose. Similar to what Eleven Warrior did in the link above; minmay did the same with the Pitfalls discussion: http://grimrock.net/forum/viewtopic.php?f=22&t=9366

You can title it, "FeMaiden's Inquisition" - or something equally witty :-p
minmay
Posts: 2790
Joined: Mon Sep 23, 2013 2:24 am

Re: another question about syntax

Post by minmay »

For searching the forum you should probably use Google. phpBB's search is really bad.
FeMaiden wrote:the lua manual confused me because many of the commands and syntax rules seemed to be different from what I see in the editor.
The lua manual seems to be more instructions on the basic generalized lua programming language, while lua that is in the editor is slighty more specific to this game.
This is not true. It's the exact same language. Grimrock neither adds nor removes any language features that I know of. Just don't confuse language features with, say, global functions (e.g. the coroutine library is not available in Grimrock).
However, the Lua reference manual is a reference, not a tutorial; it's not great as your sole resource for learning the language, and certainly not if you don't already know imperative and structured programming concepts.
There are some pretty good programming tutorials on the Web, and probably decent Lua ones too. I don't think Grimrock needs its own Lua tutorial, because, well, like I said, it doesn't make any changes to the language. The scripting reference and most of my posts are written under the assumption that the reader is already capable of programming in Lua, because that skill isn't specific to Grimrock modding, and can be learned elsewhere much more easily from much more qualified people.
Grimrock 1 dungeon
Grimrock 2 resources
I no longer answer scripting questions in private messages. Please ask in a forum topic or this Discord server.
User avatar
Isaac
Posts: 3192
Joined: Fri Mar 02, 2012 10:02 pm

Re: another question about syntax

Post by Isaac »

If anyone's interested in seeing production Lua in a game... "Aarklash: Legacy" released with all of its lua scripts in plain text in the install folder. It was interesting to read though it. 8-)

*And not a bad game ~as a bonus.
User avatar
JohnWordsworth
Posts: 1397
Joined: Fri Sep 14, 2012 4:19 pm
Location: Devon, United Kingdom
Contact:

Re: another question about syntax

Post by JohnWordsworth »

minmay wrote:For searching the forum you should probably use Google. phpBB's search is really bad.
To be fair, that's true of about 95% of the web! Using Google search always seems to provide better results than a website's built-in search...
My Grimrock Projects Page with links to the Grimrock Model Toolkit, GrimFBX, Atlas Toolkit, QuickBar, NoteBook and the Oriental Weapons Pack.
Post Reply