Skip to content

Commit 63d7181

Browse files
committed
Add dev spells list and implement CurseItem; expose Lua globals for callbacks
- Remove commented TestSpell from Necromancy, add new Dev category with TestSpell and CurseItem - Implement cursing logic using setCursed/setCursedKnown and user feedback/effects - Expose LuaEngine.getGlobals() and switch GameLoop to use it for ItemSelectionCallbacks lookup to avoid getfenv dependence
1 parent f0d9e4d commit 63d7181

File tree

4 files changed

+12
-3
lines changed

4 files changed

+12
-3
lines changed

RemixedDungeon/src/main/assets/scripts/spells/CurseItem.lua

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@ return spell.init{
3232
RPD.glog("That item is already cursed!")
3333
else
3434
-- Curse the selected item
35-
item:curse()
35+
item:setCursed(true);
36+
item:setCursedKnown(true);
37+
3638
RPD.glog("You have cursed your " .. item:name() .. "!")
3739

3840
-- Apply a visual effect

RemixedDungeon/src/main/assets/scripts/spells/CustomSpellsList.lua

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
---
66

77
local spells = {}
8-
spells["Necromancy"] = {"RaiseDead","Exhumation", "DarkSacrifice","Possess",--[["TestSpell"]]}
8+
spells["Necromancy"] = {"RaiseDead","Exhumation", "DarkSacrifice","Possess"}
99
spells["Common"] = {"TownPortal","Heal","RaiseDead","Cloak","Calm","Charm"}
1010

1111
spells["Combat"] = {"DieHard","Dash","BodyArmor","Smash"}
@@ -15,4 +15,7 @@ spells["Huntress"] = {"Calm","Charm","ShootInEye","SummonBeast"}
1515
spells["Elf"] = {"MagicArrow","Sprout","HideInGrass","NatureArmor"}
1616
spells["Priest"] = {"Heal","Calm","Charm","Order"}
1717
spells["PlagueDoctor"] = {"Heal","Calm","Charm","Order"}
18+
19+
spells["Dev"] = {"TestSpell", "CurseItem"}
20+
1821
return spells

RemixedDungeon/src/main/java/com/nyrds/lua/LuaEngine.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,10 @@ static public void runScriptFile(@NotNull String fileName) {
163163
getEngine().globals.loadfile(fileName).call();
164164
}
165165

166+
static public Globals getGlobals() {
167+
return getEngine().globals;
168+
}
169+
166170
@Override
167171
public InputStream findResource(String filename) {
168172
return new BOMInputStream(ModdingMode.getInputStream(filename));

RemixedDungeon/src/main/java/com/nyrds/pixeldungeon/game/GameLoop.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ public static void setDifficulty(int difficulty) {
292292
@LuaInterface
293293
public static void callByGlobalId(int callbackId, Object... params) {
294294
// Get the global callbacks table from Lua
295-
LuaValue callbacks = LuaEngine.call("getfenv").get("ItemSelectionCallbacks");
295+
LuaValue callbacks = LuaEngine.getGlobals().get("ItemSelectionCallbacks");
296296

297297
// If the callbacks table exists and has the callback ID
298298
if (callbacks != null && callbacks.istable()) {

0 commit comments

Comments
 (0)