• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[JASS] ExecuteFunc

Status
Not open for further replies.
Level 36
Joined
Jul 1, 2007
Messages
6,677
Hm, so just out of pure curiosity, I made this bit of code (with the event of entering a chat string that begins in "Execute ")

JASS:
call ExecuteFunc(EventPlayerChatString(), 8, StringLength(EventPlayerChatString()))

So basically what this does is when you would type, for example, "Execute CreateUnit(Player(0), 'hfoo', 0.00, 0.00, 270.00)" in game it would do that.

So what I'm wondering is if there is any way to stop it if you make an incorrect argument because right now it just fatal errors.
 
Void, the World Editor JASS Helper is meant to do that work for you, its normally not thought for calling functions out of hea ingame.

You must get EVERY single command and check the values for EVERY command :p thats alot of work.

Edit: I tried it myself but it seems not to work proberly.

(Wc3 crashes, but when I disable the execution it has the right order)


JASS:
scope Execute initializer Init

function Actions takes nothing returns nothing
    set udg_Tmp_String = SubString(GetEventPlayerChatString(), 17, ( StringLength(GetEventPlayerChatString()) - 1 ))
    call DisplayTextToForce(GetPlayersAll(),"Your action was: " + udg_Tmp_String)
    call ExecuteFunc(udg_Tmp_String)
endfunction

//===========================================================================
function Init takes nothing returns nothing
    local trigger Trig_Execute= CreateTrigger(  )
    call TriggerRegisterPlayerChatEvent( Trig_Execute, Player(0), "call ExecuteFunc", false )
    call TriggerAddAction( Trig_Execute, function Actions )
    set Trig_Execute = null
endfunction

endscope
 
Level 21
Joined
Aug 21, 2005
Messages
3,699
Still means you have to have a huge conditional statement that executes a different function based on what you typed... i.e.

JASS:
if (command == "CreateUnit") then
elseif (command == "KillUnit") then
etc
endif

Then you also have the problem that the parameters have virtually infinite possibilities... For example: KillUnit takes a unit parameter... Which unit will that be?
 
Level 21
Joined
Aug 21, 2005
Messages
3,699
And why would you want to have this kind of interface anyway? I mean, if you want to give e.g. a game master godly powers over the course of the map (i.e. killing units, etc.) then a text-based interface is probably not what you want. It'd be better to at least use a "god powers building" with abilities such as "Kill Unit" that simply kills the unit that's targeted.
Or "Create Unit" that has to target a unit (from a small spot on the map containing all possible units) and then automatically has to target a point which creates a duplicate of the targeted unit at the point...
 
Status
Not open for further replies.
Top