Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -935,6 +935,9 @@
[submodule "vendor/grammars/logtalk.tmbundle"]
path = vendor/grammars/logtalk.tmbundle
url = https://github.com/textmate/logtalk.tmbundle
[submodule "vendor/grammars/lpc-language-server"]
path = vendor/grammars/lpc-language-server
url = https://github.com/jlchmura/lpc-language-server.git
[submodule "vendor/grammars/lua.tmbundle"]
path = vendor/grammars/lua.tmbundle
url = https://github.com/LuaLS/lua.tmbundle.git
Expand Down
3 changes: 3 additions & 0 deletions grammars.yml
Original file line number Diff line number Diff line change
Expand Up @@ -886,6 +886,9 @@ vendor/grammars/logos:
- source.logos
vendor/grammars/logtalk.tmbundle:
- source.logtalk
vendor/grammars/lpc-language-server:
- documentation.injection.lpc
- source.lpc.lang-server
vendor/grammars/lua.tmbundle:
- source.lua
vendor/grammars/m3:
Expand Down
15 changes: 14 additions & 1 deletion lib/linguist/heuristics.yml
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,11 @@ disambiguations:
rules:
- language: XML
pattern: '^(\s*)(?i:<Project|<Import|<Property|<?xml|xmlns)'
- extensions: ['.c']
rules:
- language: LPC
named_pattern: lpc
- language: C
- extensions: ['.cairo']
rules:
- language: Cairo Zero
Expand Down Expand Up @@ -378,7 +383,9 @@ disambiguations:
- language: Objective-C
named_pattern: objectivec
- language: C++
named_pattern: cpp
named_pattern: cpp
- language: LPC
named_pattern: lpc
- language: C
- extensions: ['.hh']
rules:
Expand Down Expand Up @@ -1081,6 +1088,12 @@ named_patterns:
- '^[ \t]*#[ \t]*(?:precache|using_animtree)[ \t]*\('
json: '\A\s*[{\[]'
key_equals_value: '^[^#!;][^=]*='
lpc:
- '(?m)^[ \t]*inherit\s+"[^"\r\n]+"'
- '\b(?:this_player|this_object|previous_object|clone_object|call_out|remove_call_out|notify_fail|seteuid|getuid|find_player|tell_object|objectp|environment|present)\s*\('
- '(?m)^[ \t]*(?:private|public|protected)\s+(?:static\s+)?object\b'
- '(?m)^[ \t]*(?:(?:public|private|protected)\s*)?(?:(?:mixed|object|int|string|mapping)\s*)?\*?(?:[A-Za-z_][A-Za-z0-9_]*\s*=)\s*\(\{.*\}\)'
- '(?mi)"[a-z0-9_/]+"\s*->\s*[a-z][a-z0-9_]*\s*\('
m68k:
- '(?im)\bmoveq(?:\.l)?\s+#(?:\$-?[0-9a-f]{1,3}|%[0-1]{1,8}|-?[0-9]{1,3}),\s*d[0-7]\b'
- '(?im)^\s*move(?:\.[bwl])?\s+(?:sr|usp),\s*[^\s]+'
Expand Down
9 changes: 9 additions & 0 deletions lib/linguist/languages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4046,6 +4046,15 @@ LOLCODE:
tm_scope: source.lolcode
ace_mode: text
language_id: 192
LPC:
type: programming
extensions:
- ".c"
- ".h"
tm_scope: source.lpc.lang-server
ace_mode: c_cpp
language_id: 397797394
color: "#ffb100"
LSL:
type: programming
tm_scope: source.lsl
Expand Down
16 changes: 16 additions & 0 deletions samples/LPC/area_env.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
int minLevel;

public int query_minLevel() {
return minLevel;
}
public void set_minLevel(int level) {
minLevel = level;
}

public string query_label() {
return "Area Label";
}

public string canEnterArea() {
return this_player()->query_level() < minLevel ? "You are not experienced enough to enter this area." : 0;
}
11 changes: 11 additions & 0 deletions samples/LPC/connection.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/**
* query connection properties for a player
* @return a union type of either an int or an array of strings
*/
public <int|string*>* queryConnectionProperties() {
object p = this_player();
if (!p) return 0;

object conn = p->queryConnection();
return conn->queryProperties();
}
123 changes: 123 additions & 0 deletions samples/LPC/convo.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
/*
* LDMud mob dialog system
* Copyright 2022-2024 John Chmura
*
*/
#include "../../jgambit.h"
#include "./convo.h"

private object owner;
private object parentConvo;
private object *childConvos = ({});
private int auto_start = 1;
private int queue_status = 0;
private mixed *queue = ({});
private int lastIdx=0;
private int convoId = random(10000)+1;
private int destructOnEnd = 0;

private object currentPromptSet;
/** the last player to interact with this convo */
private object lastPlayer;
private int waitForConvoToFinish = 0;

private object onFinishOb;

/* function declarations */
public int execOp(mixed op);


/* debug output */
private void debug(string s) {
if (CONVO_DEBUG) {
object j = find_player("jgambit");
if (j) {
tell_object(j,COLORSTRING(sprintf("$PF[debug] %s\n", s), j));
}
}
}

/** returns 1 if the convo queue is running, otherwise 0*/
public query_isRunning() {
return queue_status;
}

public set_lastPlayer(object p) {
if (!living(p)) {
debug("Tried to set last player but wasn't living");
return 0;
}

debug(sprintf("Set last player to %s", p->query_name()));
lastPlayer = p;
return p;
}
public query_lastPlayer() {
return (!lastPlayer && parentConvo)
? parentConvo->query_lastPlayer()
: lastPlayer;
}

/** indicates if the convo should destruct when it is finished */
public set_destructOnEnd(int flag) {
destructOnEnd = flag;
}

set_parentConvo(object c) {
parentConvo=c;
}
object query_parentConvo() { return parentConvo; }

/** The owner is the actor this convo corresponds to. Usually a monster. */
set_owner(object o) {
owner = o;
return o;
}
object query_owner() { return owner; }

/** the operation queue for this conversation. don't mess with this */
set_queue(mixed *q) {
queue = q;
return q;
}
query_queue() { return queue; }

/**
* sets the autostart flag.
* the default (1) will cause the convo to autostart when an operation is added
* otherwise you will have to manually call convo->start()
*/
set_auto_start(int s) {
auto_start = s;
return 1;
}
int query_auto_start() { return auto_start; }

/**
* (Optional)
* Sets the object in which the "on_convoFinished(convoId)" function
* function will be called when the conversation ends.
* @param ob - object or string
*/
set_onFinishOb(mixed ob) {
if (objectp(ob))
onFinishOb = object_name(ob);
else
onFinishOb = ob;
return convoId;
}
query_onFinishOb() { return onFinishOb; }

query_convoId() { return convoId; }

/**
* does some cleanup by destructing all child convos
*/
public destructConvos() {
foreach(object c in childConvos) {
if (c) c->destructConvos();
destruct(c);
}

childConvos -= ({ 0 });
}
28 changes: 28 additions & 0 deletions samples/LPC/convoMatchset.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* LDMud mob dialog system
* Copyright 2022-2024 John Chmura
*
*/
#include "../../jgambit.h"

private mixed *responses = ({});
private int ttl = 0;
private mixed ttl_op;

public match(string pattern, mixed response) {
responses += ({
({ pattern, response })
});

return TO;
}

public varargs timeout(int n, mixed op) {
ttl = n;
ttl_op = op;
return TO;
}

public query_ttl() { return ttl; }
public query_ttl_op() { return ttl_op; }
public query_matchset() { return responses; }
15 changes: 15 additions & 0 deletions samples/LPC/globals.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@

#ifndef GLOBAL_H

#define GLOBAL_H

#include <mudlib.h>
#include "../area.h"

#define SETWRAP set_wrap_long(1)
#define WRAP(x) wrap_text(x)
#define AREAPATH "/d/area/"
#define ROOMPATH AREAPATH "rooms/"
#define TO this_object()

#endif
30 changes: 30 additions & 0 deletions samples/LPC/level_list.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
string short() {
return "A list of the top players" ;
}

void long() {
cat("/SORT_LEVEL");
}

void init() {
add_action("read", "read");
}

int id(string str) {
return str == "list" || str == "top" || str == "top players" ||
str == "list of top players" || str == "top list";
}

int read(string str) {
if (!id(str))
return 0;
say(this_player()->query_name() + " reads the top list.\n");
long();
return 1;
}

int query_weight() { return 1; }

int get() { return 1; }

int query_value() { return 5; }
12 changes: 12 additions & 0 deletions samples/LPC/players.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@

function getPlayersByLevel(int minLevel) {
object* players = users();
return filter(players, (: $1->query_level() >= minLevel :));
}

/** Schedule a shutdown for the near future. */
void slow_shut_down (int minutes) {
filter(users(), #'tell_object,
"Game driver shouts: The memory is getting low !\n");
"obj/shut"->shut(minutes);
}
53 changes: 53 additions & 0 deletions samples/LPC/startroom.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
inherit "room/room";

#include "globals.h"

void reset(int arg) {
::reset(arg);

SETWRAP;

if(!arg) {

set_light(1);
no_castle_flag = 1;

short_desc = "Along the edge of a field.";
long_desc =
"You are standing along the western edge of the fields where the " +
"city grows its crops. " +
"A long, straight path heading east has been cut deep in to the middle " +
"of the crops. " +
"Far off to the west you see the tree line of a forest."
;

dest_dir = ({
"room/crop", "east",
ROOMPATH + "treeline.c", "west"
});

items = ({
({"crops", "crop","field"}),
WRAP(
"A large field of crops that extends east as far as the eye can see. "+
"There is a path heading east, in to the field."
),
({"tree", "trees", "tree line"}),
"The edge of a forest made up of some species of pine tree."
});

search_items = ({
({"crop", "crops", "field"}), "It looks like corn.",
});

sounds =
({
"", "You can hear the breeze rustling through the stalks in the field.",
});

if (!present("bulletin board")) {
move_object(AREAPATH+"obj/board.c", TO);
}
}
}

1 change: 1 addition & 0 deletions vendor/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,7 @@ This is a list of grammars that Linguist selects to provide syntax highlighting
- **LFE:** [textmate/lisp.tmbundle](https://github.com/textmate/lisp.tmbundle)
- **LLVM:** [whitequark/llvm.tmbundle](https://github.com/whitequark/llvm.tmbundle)
- **LOLCODE:** [KrazIvan/LOLCODE-grammar-vscode](https://github.com/KrazIvan/LOLCODE-grammar-vscode)
- **LPC:** [jlchmura/lpc-language-server](https://github.com/jlchmura/lpc-language-server)
- **LSL:** [textmate/secondlife-lsl.tmbundle](https://github.com/textmate/secondlife-lsl.tmbundle)
- **LTspice Symbol:** [Alhadis/language-pcb](https://github.com/Alhadis/language-pcb)
- **LabVIEW:** [textmate/xml.tmbundle](https://github.com/textmate/xml.tmbundle)
Expand Down
1 change: 1 addition & 0 deletions vendor/grammars/lpc-language-server
Submodule lpc-language-server added at 9ed1d0
Loading