Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expression2 Lua error #3256

Open
TreePyro opened this issue Feb 2, 2025 · 4 comments
Open

Expression2 Lua error #3256

TreePyro opened this issue Feb 2, 2025 · 4 comments

Comments

@TreePyro
Copy link

TreePyro commented Feb 2, 2025

Happens with an E2 that creates many holograms in a sequence of 200 ticks using tables to modify their colors, scales, etc. Timers are done via clk() functions
I can be contacted on discord at "thetreedemoknight" for more details and/or code.

sv: Expression 2 (shittlecan/Shittlecan_ED-FE25.1): Internal error 'entities/gmod_wire_expression2/core/array.lua:100: attempt to index local 'array' (a nil value)' at line 458, char 12

@Vurv78
Copy link
Contributor

Vurv78 commented Feb 2, 2025

Send the code here, that can only error if some extension gives you a nil value for an array (which isn't correct)

@TreePyro
Copy link
Author

TreePyro commented Feb 2, 2025

@name shittlecan/Shittlecan_ED-FE25.1
@inputs Base:entity
@outputs RunningNumber:string
@persist [Prefix Version CFG_Version]:string CompatabilityVersion CFG_CompatabilityVersion
@persist [Objects DevObjs]:table
@persist O:entity P I BuildPitch
@persist [BaseBG BaseSubmat]:table
@persist Debug
#@strict
@model models/props_junk/PopCan01a.mdl
function talkShit(Shit:string,TalkDebug:number){
    if(!Debug){
    printColor(vec(0,161,255),"Shittlecan "+Version+ ": ",vec(255),Shit)
    }
    if(TalkDebug & Debug){
    printColor(vec(255,0,0),"Shittlecan "+Version+ ": ",vec(255),Shit)
    }
}

 
if(dupefinished()){reset()}
if(~Base){reset()}
if(first()){






#[
//////////////////////////////////////
////////////CONFIGURATION/////////////
//////////////////////////////////////
]#
    



    #Dictates how long (Miliseconds) the E2 will wait between adding objects. A sane person will keep it above 100, and the default value is 200.
    BuildInterval = 200
    #Please don't set this to any value below 100. You will get tick quota'd. And I might lift your house 3 feet and 5 inches off the ground.
    
    #Dictates what character you type first for a chat command to be iterated. Default value "."
    Prefix = "."
    
    #Dictates if dev props will spawn at your crosshair or, in rattlecan fashion, above the locomotive.
    #Default is 0 (Spawn at crosshair)
    DevPropSpawnMode = 0
    
    #Select your save below. If you don't have one, create a new one using the blank one as a base.
    #include "shittlecan/saves/CSX_GP40_ED-FE25.1"
    
    
    #You should not edit anything else below this line unless you are making a community edit.
    #By editing below this line you void your ability to write a bug report, but you open yourself up to the possibility of contacting me.

    Version = "ED-FE25.1"
    CompatabilityVersion = 1
    
    #Enabling Debug will tell Shittlecan to print to you what it's doing. WILL BE SPAMMY, DO NOT USE IN NORMAL OPERATION!
    Debug = 1
    O = owner()
    P = 0
    
    if(!->Base){talkShit("Base is not wired! The E2 will break. Please wire Shittlecan to the base entity and it will begin working.",0) soundPlay(0,0,"buttons/combine_button_locked.wav")}else{
        talkShit("Good to go! Loading save file via #include.",0)
        if(Version!=CFG_Version){
            if(CompatabilityVersion!=CFG_CompatabilityVersion){
                error("Your version of Shittlecan is on a different Major version than the scheme. Please update your scheme, or use a different one.")
            }else{
                O:soundPlay(5,0,"buttons/button6.wav") 
                talkShit(
"WARNING // Your version of Shittlecan ("+Version+") differs from the save's version ("+CFG_Version+"). The loaded file may bug out, and files may not write properly.",0)
            }
        }
        timer("sectioninit",50)
    }
}

    function scrub(){
        propDeleteAll()
        talkShit("E2 removed, nuking all entities.",0)
    }
#[
//////////////////////////////////////
////////////BASIC OBJECTS/////////////
//////////////////////////////////////
]#

if(clk("basic")){
    I++
    if(I>Objects:count()){
        soundPurge()
        Base:soundPlay(0,0,"ambient/machines/floodgate_stop1.wav")
        soundPitch(0,random(90,110))
        stoptimer("basic")
        timer("decal",BuildInterval)
        I = 0
    }else{
        if(Objects[I,table]["type",string] == "basic"){    
            local Obj = Objects[I,table]
            holoCreate(I)
            holoParent(I,Base)
            holoScale(I,Obj:exists("scl") ? Obj["scl",vector] : vec(1))
            holoPos(I,Base:toWorld(Obj:exists("pos") ? Obj["pos",vector] : vec(0)))
            holoAng(I,Base:toWorld(Obj:exists("ang") ? Obj["ang",angle] : ang(0)))
            holoColor(I,Obj:exists("rgb") ? Obj["rgb",vector] : vec(255))
            holoAlpha(I,Obj:exists("opa") ? Obj["opa",number] : 255)
            holoModel(I,Obj["mdl",string])
            
            holoEntity(I):soundPlay(I,0,"Canister.ImpactHard")
            soundPitch(I,BuildPitch + I)
            
            for(X = 1,Obj["bgs",array]:count()){
                holoBodygroup(I,X,Obj["bgs",array][X,number])
            }   #This is the only bit of code that doesn't set itself to default if undefined through the object's table. I don't think it'll cause problems.
                #-FEC 427, ED-NV24.2
                
            for(X = 0,Obj["sub",table]:count()){
                if(Obj["sub",table]:exists(X)){
                    holoEntity(I):setSubMaterial(X,Obj["sub",table][X,string])
                }
            }
            foreach(X:number,Clip:table = Obj["clp",table]){
                holoClipEnabled(I,X,1)
                holoClip(I,X,Clip["pos",vector],Clip["aim",vector],Clip:exists("ent") ? Clip["ent",entity] : holoEntity(I))
            }   #This shittle is some of the most confusing bit of code I probably have made in my entire life. It has caused many problems. I guess this aint called Shittlecan for nothing.
                #-FEC 427, ED-JA25.2, ED-JA25.3
                talkShit(Obj:toString(),1)
            }else{
                talkShit("Basic building: Skipped object " + I + " with ''type'' set to " + Objects[I,table]["type",string],0)
        timer("basic",BuildInterval)
}}}

#[
//////////////////////////////////////
////////////DECAL OBJECTS/////////////
//////////////////////////////////////
]#

if(clk("decal")){
    I++
    if(I>Objects:count()){
        soundPurge()
        Base:soundPlay(0,0,"plats/elevator_stop2.wav")
        soundPitch(0,random(50))
        soundLevel(0,80)
        stoptimer("decal")
        finalize()
        I = 0
    }else{
        if(Objects[I,table]["type",string] == "decal"){    
            local Obj = Objects[I,table]
            holoCreate(I)
            holoParent(I,Base)
            holoScale(I,Obj:exists("scl") ? Obj["scl",vector] : vec(1))
            holoPos(I,Base:toWorld(Obj:exists("pos") ? Obj["pos",vector] : vec(0)))
            holoAng(I,Base:toWorld(Obj:exists("ang") ? Obj["ang",angle] : ang(0)))
            holoColor(I,Obj:exists("rgb") ? Obj["rgb",vector] : vec(255))
            holoAlpha(I,Obj:exists("opa") ? Obj["opa",number] : 255)
            holoModel(I,"models/holograms/plane.mdl")
            
            holoEntity(I):soundPlay(I,0,"player/sprayer.wav")
            soundPitch(I,BuildPitch + I)
            for(X = 1,Obj["bgs",array]:count()){
                holoBodygroup(I,X,Obj["bgs",array][X,number])
            }   #This is the only bit of code that doesn't set itself to default if undefined through the object's table. I don't think it'll cause problems.
                #-FEC 427, ED-NV24.2
            for(X = 0,Obj["sub",table]:count()){
                if(Obj["sub",table]:exists(X)){
                    holoEntity(I):setSubMaterial(X,Obj["sub",table][X,string])
                }
            }
            foreach(X:number,Clip:table = Obj["clp",table]){
                holoClipEnabled(I,X,1)
                holoClip(I,X,Clip["pos",vector],Clip["aim",vector],Clip:exists("ent") ? Clip["ent",entity] : holoEntity(I))
            }   #This shittle is some of the most confusing bit of code I probably have made in my entire life. It has caused many problems. I guess this aint called Shittlecan for nothing.
                #-FEC 427, ED-JA25.2, ED-JA25.3
            }
        timer("decal",BuildInterval)
}}


#[
//////////////////////////////////////
////////////  SECTIONS   /////////////
//////////////////////////////////////
]#


if(clk("sectioninit")){
    soundPlay(10,0,"ambient/levels/labs/equipment_printer_loop1.wav")
    soundPitch(10,65)
    soundPitch(10,150,1)
    timer("section",1000)
}


if(clk("section")){
    I++
    if(I>Objects:count()){
        soundPurge()
        Base:soundPlay(10,0,"npc/roller/remote_yes.wav")
        stoptimer("section")
        timer("basic",BuildInterval)
        I = 0
    }else{
        if(Objects[I,table]["type",string]=="section"){
            soundPitch(10,100,0.75)
            Base:setAlpha(0)
            local Obj = Objects[I,table]
            talkShit(Obj:toString(),1)
            holoCreate(I)
            holoParent(I,Base)
            holoPos(I,Base:toWorld(vec(0)))
            holoAng(I,Base:toWorld(ang(0)))
            holoColor(I,Obj:exists("rgb") ? Obj["rgb",vector] : vec(255))
            holoModel(I,Base:model())
            
            Base:soundPlay(I,0,"garrysmod/balloon_pop_cute.wav")
            soundPitch(I,BuildPitch + I)
            
            for(X = 1,Obj["bgs",array]:count()){
                holoBodygroup(I,X,Obj["bgs",array][X,number])
            }   #This is the only bit of code that doesn't set itself to default if undefined through the object's table. I don't think it'll cause problems.
                #-FEC 427, ED-NV24.2
            for(X = 0,Obj["sub",table]:count()){
                if(Obj["sub",table]:exists(X)){
                    holoEntity(I):setSubMaterial(X,Obj["sub",table][X,string])
                }
            }
            foreach(X:number,Clip:table = Obj["clp",table]){
                holoClipEnabled(I,X,1)
                holoClip(I,X,Clip["pos",vector],Clip["aim",vector],Clip:exists("ent") ? Clip["ent",entity] : holoEntity(I))
            }
        }
        timer("section",BuildInterval)
    }
}


#[

//////////////////////////////////////
////////////CHAT COMMANDS/////////////
//////////////////////////////////////

]#

function isDevObject(){}

function convert(T:table,Q:string){
    if(Q == "object"){
        if(T["type",string] == "basic"){
            
        }
        if(T["type",string] == "section"){
            
        }
        if(T["type",string] == "basic"){
            
        }
    }
    if(Q == "devobj"){
        
    }
}

function isObject(Ent:entity){ #Takes an entity and returns its ID from the "Objects" table. If the entity isn't an object, return 0. // FEC 427, ED-JA25.4
    foreach(X:number,Obj:entity = DevObjs){
        if(Ent==DevObjs[X,entity]){
            return X
        }else{
            return 0
        }
    }
}

function devPropSpawn(Index:number,Type:string,Mdl:string){
    local AimPos = O:aimPos()
    DevObjs[Index,table]["ent",entity] = propSpawn(Mdl,AimPos,ang(0),1)
    DevObjs[Index,table]["type",string] = Type
}

event chat(Ply:entity,M:string,_:number){
    if(M[1] == "."){
        hideChat(1)
        M = M:lower()
        ME = M:explode(" ")
        print(M)
        print(ME)
        AimPos = O:aimPos()
        AimEnt = O:aimEntity()
    
        if(ME[1,string] == ".create"){
            P++
            if(ME[2,string] == "clip"){
                if(ME:exists(3)&ME:exists(4)){
                    devPropSpawn(P,"clip","models/hunter/plates/plate025x025.mdl")
                    local Ent = DevObjs[P,table]["ent",entity]
                    holoClipEnabled(ME[3,number],ME[4,number],1)
                    holoClip(ME[3,number],ME[4,number],vec(0),Ent:up(),Ent)
                    Ent["type",string] = "clip"
                    Ent["holoid",number] = ME[3,string]:toNumber()
                    Ent["clipid",number] = ME[4,string]:toNumber()
                    Ent:soundPlay(0,0,"Canister.ImpactSoft")
                    talkShit("Created Clip on Object ID " + ME[3,string] + " and clip ID " + ME[4,string],1)
                }else{
                    talkShit("Invalid ID for object and/or clip!",0)
                }
            }
            if(ME[2,string] == "basic"){
                devPropSpawn(P,"basic",ME[3,string])
                local Obj = DevObjs[P,table]["ent",entity]
                Obj:setMaterial("models/wireframe")
                Obj["holo",entity] = holoCreate(P*_PI,Obj:pos(),vec(1),Obj:angles(),vec(255),ME[3,string])
                local Holo = DevObjs[P,entity]["holo",entity]
                Holo:parentTo(Obj)
                talkShit("Created Basic object at index " + P,0)
            }
            if(ME[2,string] == "decal"){
                devPropSpawn(P,"decal",ME[3,string]:toNumber() ? "models/holograms/cplane.mdl" : "models/holograms/plane.mdl")
                DevObjs[P,entity]:setMaterial("models/wireframe")
                DevObjs["holo",entity] = holoCreate(P*_PI)
            }
        }
        #[
        if(ME[1,string] == ".mod"]){ #TO-DO: Change attributes of objects and dev objects
            
        }
        
        if(ME[1,string] == ".burn"){ #TO-DO: Convert the dev object into an object
            
        }
        
        if(ME[1,string] == ".burnall"){ #TO-DO: Convert all active dev objects into objects
            
        }
        
        if(ME[1,string] == ".write"){ #TO-DO: Print the Objects table to copy + paste into a save file
            
        }
        ]#
        if(ME[1,string] == ".tell"){ #TO-DO: Look at any object or dev object to print the related table
            if(ME[2,string] == "obj"){
                print(Objects[ME[3,string]:toNumber(),table])
            }
            if(ME[2,string] == "dev"){
                print(DevObjs[ME[3,string]:toNumber(),table])
            }
            talkShit("Printed " + ME[2,string] + " at index " + ME[3,string],1)
        }
    }
}

@TreePyro
Copy link
Author

TreePyro commented Feb 2, 2025

And if it's needed, here's a blank include for the e2

@persist Base:entity Objects:table BuildPitch
    
    
    CFG_Version = "ED-FE25.1"
    CFG_CompatabilityVersion = 1
    RunningNumber = randint(0,100):toString()
    BuildPitch = random(95,100)

    I = 0
    local X = 1
    
    
    #Shittlecan will run the code inside of this function after it is done building the scheme. You can use it to manually modify some of the objects in your save.
    function finalize(){
        RNE = RunningNumber:explode("")
        
        
    }
    
    #[
    Types of objects:
    "basic" 
        -Has all standard attributes, including pos, clips, bodygroups, and submaterials.
    "Section":
        -Ignores "pos", "ang", "opa", "scl", "mdl" and "bgs" attributes.
            -"pos" is always vec(0)
            -"ang" is always ang(0)
            -"opa" is always vec(255)
            -"scl" is always vec(1)
            -"mdl" defaults to the base locomotive's model and cannot be re-defined by the user
            -"bgs" defaults to the base locomotive's bodygroups and cannot be re-defined by the user
    "Decal"
        -Ignores "mdl" and "sub" attributes, with an additional "mat" attribute.
            -"mdl" is always "models/holograms/plane.mdl"
            -Submaterials are not necessary for decals, since the model for them utilizes only 1 material.
            -The "mat" attribute defines the material of the decal. Note: Not necessary for "basic", since using the index 0 on submaterials does the same thing.
            
    Sub-objects:
    These are tables that exist within Object tables that define extra features about them.
        "bgs": Obj[X,table]["bgs",table][1,number]
        "sub": Obj[X,table]["sub",table][1,string]
        "clp": Obj[X,table]["clp",table][1,table]...
            ...["pos",vector]: Defines the position of the clip
            ...["aim",vector]: Sets the direction that the clip aims
            ...["ent",entity]: Defines an entity for the clip to be local to. Default is itself.
            
    Attribute index:
    "name": Does nothing on the paint scheme. Will show a customized name when doing .tell, recommended to put first thing.
    "pos": Sets the position of the object, relative to the base entity. Default vec(0), ignored by Sections.
    "ang": Sets the angles of the object, relative to the base entity. Default vec(0), ignored by Sections.
    "rgb": Defines the color, in RGB values, for the object. Default vec(255)
    "opa": Adjusts the alpha level for the object, with higher values giving a lower transparency. Default 255, ignored by Sections.
    "bgs": Modifies the bodygroups of the object. Ignored by Sections and Decals.
    "sub": Changes the submaterials for the object. Ignored by Decals.
    "mdl": Defines the object's model. Default "models/holograms/cube.mdl", ignored by Sections and Decals.
    "scl": Sizes the model of the object by ratio. Ignored by Sections.
    "clp": Adds a holoClip to the object. Should be formatted as Object[X,table]["clp",table][1,table]["pos"] with "pos" being interchangeable for "aim" for direction.
    "type": Identifies what type of object the Object is, between Basic, Section, and Decal. See above for more information.
    
    
    ]#
    
    
    
    
    

@Vurv78
Copy link
Contributor

Vurv78 commented Feb 2, 2025

Just skimming through it I don't see any use of external functions that'd return an array but not at my PC. Anyone wanting to solve this would need to look there

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants