ASSERT_DLUA


Questions, Explanations, Howtos

Halls Hopper

Posts: 68

Joined: Friday, 3rd January 2014, 22:52

Post Thursday, 11th December 2014, 16:29

ASSERT_DLUA

So, I was trying to get some lua magic online, but smashed in the brick wall ASSERT_DLUA. This macro kills my scripts, and I don't understand why
  Code:
// Some dLua convenience functions.
IDEF(base_type)
{
    ASSERT_DLUA;
    lua_pushstring(ls, base_type_string(*item).c_str());
    return 1;
}
So... am I not allowed to use functions like base_type, identified, is_cursed and such in my scripts? These look harmless to me.
I try to use them like this:
  Code:
if not item.is_cursed() then ...
and get
  Code:
Operation forbidden in end-user script
I tried to place the lua file in different folders in dat/* and include it via init.txt:
  Code:
lua_file = lua/party/master.lua
That's a silly name!

Vestibule Violator

Posts: 1567

Joined: Friday, 21st January 2011, 22:56

Post Thursday, 11th December 2014, 17:02

Re: ASSERT_DLUA

There's two classes of lua functions in crawl, dlua and clua. Dlua is for the game to use, for example for vaults. Clua is for user scripts. Dlua functions might manipulate the game state or provide information that is usually not available to the user. Clua functions can only do things the user could just as well do himself.

I don't know why the functions you are trying to use are dlua. If you are sure there aren't any information leaks you could ask why they are dlua in ##crawl-dev and ask for them to be moved to clua.

Including the script from somewhere else is not going to help by the way.
User avatar

Dungeon Master

Posts: 502

Joined: Wednesday, 7th March 2012, 13:25

Location: Lexington, KY, US

Post Thursday, 11th December 2014, 17:55

Re: ASSERT_DLUA

Insead of is_cursed() you want cursed(). is_cursed() is dlua-only because it tells you about unidentified curses.

I'm not sure why base_type() is dlua-only, but clua has a similar .class(). It takes an optional boolean to indicate terse mode. In terse mode, the strings are *almost* what base_type returns, except "staff" becomes "magical staff" and "miscellaneous" becomes "misc". No clue why. Without terse mode, the strings are what appear in menus ("Comestibles", "Magical Staves", etc.)

sub_type() has the same problem as is_cursed() (it can give unidentified information about potions/scrolls/etc). The clua equivalent is .subtype(), but that doesn't actually work with most kinds of items. That could stand to be improved.

For this message the author neil has received thanks:
Slap and stab

Return to Coding

Who is online

Users browsing this forum: No registered users and 2 guests

cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.