• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

[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