Difference between revisions of "Lua Command Line"

From Sapiens Wiki
Jump to navigation Jump to search
m (→‎Spawnable Game Objects: "branch" was replaced with "<tree>Branch")
(→‎Spawnable Game Objects: add →‎Update this List: guide for extracting game IDs)
Line 138: Line 138:
| woolskin
| woolskin
|}
|}
=== Update this List ===
Paste <code>for i=1,20000 do printType(i) end</code> into the console. This will lag!
Navigate to <code>AppData/Roaming/majicjungle/sapiens/players/<playerid>/worlds/<active world>/logs/</code> and parse <code>mainLog.log</code> to extract all the "gameObject.XYZ". Remove the "gameObject.", these are all the spawnable entities.
A lot of these are things like "placed_XYZ" (these will end up as their item variant), "place_XYZ" (these will be glitched), and "build_XYZ" (might not do anything). Those prefixes can be used for categorization:
For every "build_XYZ" there will be a "XYZ" which seems to spawn that building as a movable entity (which is fun). For every "placed_XYZ" is an "XYZ" which is a placeable item.
Using that, filter for all build_, extract them, remove the prefix, check all are present in the original list and remove them from it. A command for that might look like <code>cat sapiens | grep "^build_" | sed 's/build_//m' | sort > sapiens_build; comm -23 sapiens sapiens_build | grep -v "^build_" | sort > sapiens2</code>. Repeat for build_, place_ (should be identical to placed_), plant_ (should be identical to sapling_).
After that filtering there are buildings, plants, items, and a few leftovers that are other game entities, like large (minable) rocks, animals, decoration, ...

Revision as of 23:40, 10 July 2025

The Lua Command Line

Overview

The Lua Command Line is an in-game command line tool that allows direct interaction with the Sapiens Lua game engine. It can be accessed by pressing '`'. Once the command line has started (the prompt should turn to "lua>"), Lua commands can be executed directly allowing the player to modify various game behaviors. The Lua Command Line can be exited by typing /exit.

Commands

Command Description
completeCheat() Enables instant build mode.
setDebugObject() There is an option in the game menu that turns on debug mode. With that enabled, new buttons appear in the UI when you select any object in the world. If you click the debug button for that object, it logs all of the details about that object to every log, and is now set to be the target object for objectLog. These mj:objectLogs are scattered throughout the code base, in particular around the sapiens AI, so this is useful for tracking exactly what one particular sapien is doing. This command allows you to set a debug object from the lua command line.
setSunrise() Advances the game time of day to sunrise.
setSunset() Advances the game time of day to sunset.
printType() Allows you to find the typeIndex or typeKey for an object.

Example:
lua>printType("gameObject.wheat")
typeKey:gameObject.wheat = 338
lua>printType(338)
typeIndex:338 = gameObject.wheat
lua>spawn(338)

spawn(object, count) Spawn an item in the game.

To spawn an item in the game type:

spawn("apple",1)

Please note if the quantity is omitted, 1 will default. In other words...

spawn("apple",1)

and

spawn("apple")

...produce the same result. List of Spawnable Game Objects

tp() Teleport to a location.

Spawnable Game Objects

The following is a list of the spawnable game objects that can be used in conjunction with the "spawn()" command:

1 2 3 4
aloeLeaf aloeLeafRotten alpacaMeat alpacaMeatCooked
apple appleRotten aspenBigSeed aspenBigSeedRotten
aspenSeed aspenSeedRotten balafon bambooSeed
bambooSeedRotten banana bananaRotten beetroot
beetrootCooked beetrootRotten beetrootSeed beetrootSeedRotten
birchSeed birchSeedRotten bone boneFlute
bone_hatchet boneKnife boneSpear boneSpearHead
appleBranch, peachBranch, ... branchRotten breadDough breadDoughRotten
burntBranch chickenMeat chickenMeatCooked clay
coconut coconutRotten deadAlpaca deadChicken
deadChickenRotten dirt echinaceaFlower echinaceaFlowerRotten
elderberry elderberryRotten firedBowl firedBowlBurnMedicine
firedBowlFoodPoisoningMedicine firedBowlInjuryMedicine firedBowlMedicineRotten firedBowlVirusMedicine
firedBrick firedTile firedUrn firedUrnFlour
firedUrnFlourRotten firedUrnHulledWheat firedUrnHulledWheatRotten flax
flaxDried flaxRotten flaxSeed flaxSeedRotten
flaxTwine flint flintAxeHead flintHatchet
flintKnife flintPickaxe flintPickaxeHead flintSpear
flintSpearHead flatbread flatbreadRotten garlic
garlicRotten giant_bone gingerRoot gingerRootRotten
gooseberry gooseberryRotten grass hay
hayRotten log logDrum mammothMeat
mammothMeatCooked marigoldFlower marigoldFlowerRotten mudBrickDry
mudBrickWet mudTileDry mudTileWet orange
orangeRotten peach peachRotten pineCone
pineConeBig pineConeBigRotten pineConeRotten poppyFlower
poppyFlowerRotten pumpkin pumpkinCooked pumpkinRotten
quernstone raspberry raspberryRotten rock
rockSmall sand splitLog stoneAxeHead
stoneHatchet stoneKnife stonePickaxe stonePickaxeHead
stoneSpear stoneSpearHead sunflowerSeed sunflowerSeedRotten
turmericRoot turmericRootRotten unfiredBowlBurnMedicine unfiredBowlDry
unfiredBowlFoodPoisoningMedicine unfiredBowlInjuryMedicine unfiredBowlMedicineRotten unfiredBowlVirusMedicine
unfiredBowlWet unfiredUrnDry unfiredUrnFlour unfiredUrnFlourRotten
unfiredUrnHulledWheat unfiredUrnHulledWheatRotten unfiredUrnWet wheat
wheatRotten willowSeed willowSeedRotten woodenPole
woolskin

Update this List

Paste for i=1,20000 do printType(i) end into the console. This will lag!

Navigate to AppData/Roaming/majicjungle/sapiens/players/<playerid>/worlds/<active world>/logs/ and parse mainLog.log to extract all the "gameObject.XYZ". Remove the "gameObject.", these are all the spawnable entities.

A lot of these are things like "placed_XYZ" (these will end up as their item variant), "place_XYZ" (these will be glitched), and "build_XYZ" (might not do anything). Those prefixes can be used for categorization:

For every "build_XYZ" there will be a "XYZ" which seems to spawn that building as a movable entity (which is fun). For every "placed_XYZ" is an "XYZ" which is a placeable item.

Using that, filter for all build_, extract them, remove the prefix, check all are present in the original list and remove them from it. A command for that might look like cat sapiens | grep "^build_" | sed 's/build_//m' | sort > sapiens_build; comm -23 sapiens sapiens_build | grep -v "^build_" | sort > sapiens2. Repeat for build_, place_ (should be identical to placed_), plant_ (should be identical to sapling_).

After that filtering there are buildings, plants, items, and a few leftovers that are other game entities, like large (minable) rocks, animals, decoration, ...