Underscores in function names

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!
Post Reply
User avatar
Zo Kath Ra
Posts: 944
Joined: Sat Apr 21, 2012 9:57 am
Location: Germany

Underscores in function names

Post by Zo Kath Ra »

Put this code inside a script entity:

Code: Select all

function test_me()
	hudPrint("test")
end
When I point a connector at the script entity, the function doesn't show up in the connector's drop-down menu.
Is there a reason for this?
minmay
Posts: 2790
Joined: Mon Sep 23, 2013 2:24 am

Re: Underscores in function names

Post by minmay »

A common convention in Lua is to begin "private" function names with underscores, like "_myFunction", to imitate class encapsulation without actually enforcing it (since actually enforcing it takes some work and has a performance cost). To help with this, any function containing an underscore is not shown in the dropdown menu for connector actions. I suggest using camelCase for your function and variable names and reserving underscores for the aforementioned purpose.
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: Underscores in function names

Post by Isaac »

Petri has a post calling a feature.
viewtopic.php?f=14&t=4780&p=50536&hilit ... ore#p50536

**Not exactly related, but somewhat worth mentioning... is this: viewtopic.php?f=22&t=8542&p=86752&hilit ... ore#p86752
Post Reply