Not logged inOpenClonk Forum
Up Topic Basic functionality for switches

This board is threaded (i.e. has a tree structure). Please use the Reply button of the specific post you are referring to, not just any random button. If you want to reply to the topic in general, use the Post button near the top and bottom of the page.

Post Reply
In Response to Sven2
Your proposal is pretty much what's already in the editor (but the actions would be the UserActions; not the EditorActions). Just the name "Signal" is weird; isn't that rather the "Slot" and the switch would be the "Signal"?

The editor interface isn't that nice to use for the simple case of connecting things without any extra parameters. The current syntax for connecting a switch to a door looks something like this:

my_switch->SetLeftAction({ Function="open_door", Target=my_door });

or if there is no setter function:

my_switch.left_action = { Function="open_door", Door=my_door };

The door definition registers its action as:

UserAction->AddEvaluator("Action", "Structure", "$DoorUp$", "$DoorUpDesc$", "open_door", [def, def.EvalAct_OpenDoor], { }, UserAction->GetObjectEvaluator("IsDoor", "$Door$", "$DoorTargetHelp$"), "Door");

And when the switch is flipped, it calls something like:

UserAction->EvaluateAction(left_action, this, clonk);

UserAction keeps a global registry of all possible action strings (like "open_door", "message", "game_over", etc.), into which object definitions register.

This is a bit different from the system you sketched, because actions in your example would always be bound to an object, which doesn't make sense e.g. for messages.

If you want to create a Minecraft-llike system where you can use e.g. wires to connect switches to doors, you could probably add a flag to the triggers and the actions to make them available for the player. There could also be a special game rule that makes all actions (including cheats like GameOver) available. In retrospect, I could also update AddEvaluator to automatically register an EditorAction if a flag is set.

Powered by mwForum 2.29.7 © 1999-2015 Markus Wichitill