LUA alertentity?

Discussions about ET modding (sdk code, player/weapon modeling)

Moderators: Forum moderators, developers

Post Reply
Igloo
Posts: 81
Joined: Sat Jan 07, 2006 6:23 am
Location: Poland
Contact:

LUA alertentity?

Post by Igloo »

Hello,

I'd like to know if there's a command in LUA which can be used as alertentity in mapscripting. Just with team_CTF_red/bluespawn ["kill"/"revive"]. The best would be to define by the respawn's targetname.

Greetings,
Igloo
User avatar
=FF=im2good4u
Posts: 3821
Joined: Wed Feb 05, 2003 7:30 am
Location: The Netherlands, HOLLAND
Contact:

Post by =FF=im2good4u »

i think its posable maybe u can spawn a trigger_always ?
User avatar
ReyalP
Posts: 1663
Joined: Fri Jul 25, 2003 11:44 am

Re: LUA alertentity?

Post by ReyalP »

Igloo wrote:Hello,

I'd like to know if there's a command in LUA which can be used as alertentity in mapscripting. Just with team_CTF_red/bluespawn ["kill"/"revive"]. The best would be to define by the respawn's targetname.

Greetings,
Igloo
No. However, you could find the entity and make the equivalent changes in it it's fields.
send lawyers, guns and money
Igloo
Posts: 81
Joined: Sat Jan 07, 2006 6:23 am
Location: Poland
Contact:

Post by Igloo »

What do you mean by find.. more detailed pls :D
User avatar
Luk4ward
Posts: 236
Joined: Sun Jul 30, 2006 1:55 pm
Location: Poland
Contact:

Post by Luk4ward »

mm, im the one whos interested in it, but i dnt know much about mapscripting, just lua...Reyalp maybe u were talking about such code?:

Code: Select all

for i = 64, 1021 do
        if et.gentity_get(i, "targetname") == "spawn_Axis2" then			
            do smth like wht? example: et.gentity_set( i, "targetname", arrayindex [dunno example], "newspawn_Axis3")
        end
    end
What about:

Code: Select all

et.G_SetSpawnVar( entnum, key, value )

    Sets the spawnvar key to value for entity entnum 
can i use it to spawn players random? Hmm, i have to learn more about those spawns and how to use it via lua, but dunno how :roll:
wolFTeam.pl
User avatar
Luk4ward
Posts: 236
Joined: Sun Jul 30, 2006 1:55 pm
Location: Poland
Contact:

Post by Luk4ward »

ok, i wrote a lua script to disable/remove spawn:

Code: Select all


function et_InitGame( levelTime, randomSeed, restart)

    for entnum = 64, 1021 do
    
        if et.gentity_get(entnum, "targetname") == "set1_allies_8" then		
        	
        et.trap_UnlinkEntity( entnum ) -- nothing happens, why? Trying another function:
            
        et.G_FreeEntity( entnum ) -- nothing happens, why?
        
    
        end
    end

end
and no results :(
wolFTeam.pl
User avatar
ReyalP
Posts: 1663
Joined: Fri Jul 25, 2003 11:44 am

Post by ReyalP »

You need to find out why it doesn't work. Is the entity being found at all ?

My usual approach to things like this is to spam prints until it's obvious where the problem is. The other thing to do is to look at the corresponding code in the C gamecode. You CANNOT use the lua API effectively unless you do this.

You could also set the entity to disabled rather than removing it. If there are scripts or other entities that refer to that target name, you may run into trouble if you only remove some of them.
send lawyers, guns and money
User avatar
Luk4ward
Posts: 236
Joined: Sun Jul 30, 2006 1:55 pm
Location: Poland
Contact:

Post by Luk4ward »

ReyalP wrote:You need to find out why it doesn't work. Is the entity being found at all ?

My usual approach to things like this is to spam prints until it's obvious where the problem is. The other thing to do is to look at the corresponding code in the C gamecode. You CANNOT use the lua API effectively unless you do this.

You could also set the entity to disabled rather than removing it. If there are scripts or other entities that refer to that target name, you may run into trouble if you only remove some of them.
yes, im doing it also to see whats going on, its a pity there is no compilator for this ;p. It found 165 value for entnum without any errors, full code:

Code: Select all

--------------------------------------------------------------------------------
-- called at map start
function et_InitGame( levelTime, randomSeed, restart)
--------------------------------------------------------------------------------

    for entnum = 64, 1021 do
    
        if et.gentity_get(entnum, "targetname") == "set1_allies_8" then		
        	
        et.G_LogPrint("for targetname " .. et.gentity_get(entnum, "targetname") .. " entnum: " .. entnum .. " \n") 
        et.trap_SendConsoleCommand( et.EXEC_APPEND, "qsay for targetname ^3" .. et.gentity_get(entnum, "targetname") .. "^7 entnum: ^3" .. entnum .. "\n" )
        
        et.trap_UnlinkEntity( entnum ) -- unlink ent, 
        
        et.G_LogPrint("targetname " .. et.gentity_get(entnum, "targetname") .. " entnum: " .. entnum .. " unlinked \n") 
        et.trap_SendConsoleCommand( et.EXEC_APPEND, "qsay targetname ^3" .. et.gentity_get(entnum, "targetname") .. "^7 entnum: ^3" .. entnum .. " ^1unlinked\n" )
        
        et.G_FreeEntity( entnum ) -- no suc with unlink, so try with another funct to disable ent
        
        et.G_LogPrint("targetname " .. et.gentity_get(entnum, "targetname") .. " entnum: " .. entnum .. " is FREE \n") 
        et.trap_SendConsoleCommand( et.EXEC_APPEND, "qsay targetname ^3" .. et.gentity_get(entnum, "targetname") .. "^7 entnum: ^3" .. entnum .. " ^1is FREE\n" )
        
        spawnval = et.G_GetSpawnVar( entnum, "spawnflags" )
        
        et.trap_SendConsoleCommand( et.EXEC_APPEND, "qsay spawnval from spawnflags for ^3" .. et.gentity_get(entnum, "targetname") .. "^7 to: ^3" .. spawnval .. "\n" )
        et.G_LogPrint("spawnval from spawnflags for ^3" .. et.gentity_get(entnum, "targetname") .. "^7 to: ^3" .. spawnval .. " \n") 
        
        end
    end

end

Will try with disabling it, but then map script should be somehow enhanced for such options instead of removing? Dunno im not in map scripting...I downloaded source but cant find the corresponding .c

btw can i use it:

Code: Select all

et.G_SetSpawnVar( entnum, key, value )

    Sets the spawnvar key to value for entity entnum
to spawn somehow players random?
wolFTeam.pl
User avatar
=FF=im2good4u
Posts: 3821
Joined: Wed Feb 05, 2003 7:30 am
Location: The Netherlands, HOLLAND
Contact:

Post by =FF=im2good4u »

if u got the code u can look for
trap_UnlinkEntity
G_FreeEntity

those are actualy functions (i dunno if its case sensitive..)
User avatar
Luk4ward
Posts: 236
Joined: Sun Jul 30, 2006 1:55 pm
Location: Poland
Contact:

Post by Luk4ward »

=FF=im2good4u wrote:if u got the code u can look for
trap_UnlinkEntity
G_FreeEntity

those are actualy functions (i dunno if its case sensitive..)
yes, i tried, look @ code. Im trying everything even with setting new origin or respawning new entnum, but still no result to disable/move/change spawn:

Code: Select all

origin = { new_x, new_y, new_z }
           
        oldorigin = et.gentity_get(entnum,"origin") 
             
        et.gentity_set(entnum,"origin",origin)        
           
        neworigin = et.gentity_get(entnum,"origin")      
             
        entnum = et.G_Spawn()
        
It prints new values but nothing happens :x

edited:

scriptname and targetname cant be changed:

Code: Select all

error: tried to set read-only gentity field
wolFTeam.pl
Post Reply